Skip to content

feat(config, tui): Configurable path suffix for OpenAI-compat endpoints (#2089)#2508

Closed
hongqitai wants to merge 6 commits into
Hmbown:mainfrom
hongqitai:feature/path-suffix
Closed

feat(config, tui): Configurable path suffix for OpenAI-compat endpoints (#2089)#2508
hongqitai wants to merge 6 commits into
Hmbown:mainfrom
hongqitai:feature/path-suffix

Conversation

@hongqitai
Copy link
Copy Markdown
Contributor

@hongqitai hongqitai commented Jun 1, 2026

Summary

Closes #2089, Closes #1874
Add path_suffix into config, set it to change version:

  • like "/v2" to change vertion
  • empty str for api which accept only "/chat/completions"
  • none is current behavior(add "/v1" to url)

Testing

  • [ x ] cargo fmt --all -- --check
  • [ x ] cargo clippy --workspace --all-targets --all-features
  • [ x ] cargo test --workspace --all-features

Checklist

  • [ x ] Updated docs or comments as needed
  • [ x ] Added or updated tests where relevant
  • [ x ] Verified TUI behavior manually if UI changes

Greptile Summary

This PR adds a configurable path_suffix field to all OpenAI-compatible provider configs, letting users override or suppress the automatically-appended /v1 version segment in API base URLs. The feature is surfaced via TOML config, environment variables (one generic DEEPSEEK_PATH_SUFFIX / CODEWHALE_PATH_SUFFIX that routes by active provider, plus per-provider vars like OPENAI_PATH_SUFFIX), and a new --path-suffix CLI flag.

  • versioned_base_url and api_url are refactored to accept an Option<&str> path suffix; a normalize_version helper strips leading slashes so both "v2" and "/v2" are equivalent.
  • ARCEE_PATH_SUFFIX is implemented in the config crate and wired up in path_suffix_for, but is absent from the docs/CONFIGURATION.md env-var listing, leaving Arcee users with no documentation for the feature.

Confidence Score: 4/5

Safe to merge with minor documentation fixes; the core URL-building logic is well-tested and the config plumbing is mechanically sound across all providers.

The functional changes are thoroughly tested with unit tests covering empty suffix, non-empty suffix, with and without leading slash, and interaction with beta/versioned base URLs. Documentation has two gaps: missing ARCEE_PATH_SUFFIX entry and unclear description of path_suffix='' stripping behavior.

docs/CONFIGURATION.md needs ARCEE_PATH_SUFFIX added to the per-provider listing and a clearer description of the path_suffix='' stripping behaviour.

Important Files Changed

Filename Overview
crates/tui/src/client.rs Core URL-building logic refactored: versioned_base_url and api_url now accept Option<&str> path_suffix; a normalize_version helper strips leading slashes. All call sites updated and well-tested.
crates/config/src/lib.rs Adds path_suffix to all config structs with correct get/set/unset/list coverage for all providers. ARCEE_PATH_SUFFIX is wired up but missing from docs.
crates/tui/src/config.rs Adds path_suffix to Config and ProviderConfig; new path_suffix() method and env-var routing are consistent with existing patterns.
crates/tui/src/main.rs DoctorApiTarget and diagnostic output updated; merge_config and merge_provider_config correctly propagate path_suffix.
crates/cli/src/lib.rs Adds --path-suffix CLI flag, correctly routed via DEEPSEEK_PATH_SUFFIX env var to all providers.
docs/CONFIGURATION.md Documents path_suffix broadly but omits ARCEE_PATH_SUFFIX and understates the stripping behavior of path_suffix = "".
crates/tui/src/client/chat.rs Both chat completion call sites updated to pass self.path_suffix.as_deref(). Straightforward change.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User config / env var / CLI --path-suffix] --> B{Priority resolution}
    B --> |1st| C[CLI path_suffix flag]
    B --> |2nd| D[Provider-specific env var]
    B --> |3rd| E[Generic CODEWHALE_PATH_SUFFIX]
    B --> |4th| F[Provider config file]
    B --> |5th| G[Root deepseek config]
    C & D & E & F & G --> H[Resolved path_suffix]
    H --> I{api_url called}
    I --> |beta/ path| J[unversioned_base_url + path]
    I --> |other paths| K[normalize_version]
    K --> L{versioned_base_url}
    L --> |Some version| M[unversioned + / + version]
    L --> |None + /beta| N[unversioned + /v1]
    L --> |None + versioned| O[base_url as-is]
    L --> |None + bare| P[base_url + /v1]
    M & N & O & P --> Q[final URL]
Loading

Fix All in Codex Fix All in Claude Code Fix All in Cursor

Reviews (5): Last reviewed commit: "Merge branch 'main' into feature/path-su..." | Re-trigger Greptile

@Hmbown
Copy link
Copy Markdown
Owner

Hmbown commented Jun 1, 2026

Thanks @hongqitai. I reviewed this during the v0.8.50 triage pass. This is a useful direction for #2089, but I am not harvesting it into #2504 yet because the current patch is broader than the release slice and has a couple of correctness gaps.

Concrete blockers to address:

  • Normalize path_suffix before building URLs. Right now versioned_base_url(base_url, path_suffix.unwrap_or("/v1")) appends the suffix directly, so a config/env/CLI value like v2 or openai/v2 would produce https://hostv2/... instead of https://host/v2/....
  • Add config round-trip tests for get_value, set_value, unset_value, and list_values on at least providers.openai.path_suffix, including the explicit empty-string case.
  • Add docs/config examples. This adds new CLI flags, env vars for every provider, root DeepSeek compatibility behavior, and provider-table behavior, but the user-facing contract is not described yet.
  • Narrow or justify the surface area. Configurable path suffix for OpenAI-compat endpoints (closes #1874) #2089 is about OpenAI-compatible path suffixes; adding env vars and config keys for every provider may be right eventually, but for v0.8.50 it is more risk than I want to harvest without stronger tests.
  • Keep this as Refs #2089 until the above is covered end to end; it should not auto-close Configurable path suffix for OpenAI-compat endpoints (closes #1874) #2089 yet.

Once those are fixed, this could become the stronger follow-up compared with the smaller draft in #2506.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new path_suffix configuration option across CLI arguments, TOML configuration files, environment variables, and the TUI client, allowing users to customize or override the default /v1 API version suffix appended to base URLs. Feedback on the changes highlights a bug where the custom path_suffix is ignored if the base URL already contains a version suffix (e.g., /v1 or /v4). To resolve this, it is recommended to strip any existing version suffix from the base URL when a custom path_suffix is explicitly provided, and to update the corresponding test assertions to verify this behavior.

Comment thread crates/tui/src/client.rs Outdated
Comment thread crates/tui/src/client.rs
Comment thread crates/tui/src/client.rs
Comment thread crates/tui/src/client.rs Outdated
Comment thread crates/tui/src/client.rs
@hongqitai hongqitai marked this pull request as draft June 2, 2026 03:48
@hongqitai hongqitai force-pushed the feature/path-suffix branch from 3b9e328 to ade16fd Compare June 2, 2026 06:27
@hongqitai hongqitai marked this pull request as ready for review June 2, 2026 06:36
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@hongqitai hongqitai marked this pull request as draft June 3, 2026 10:24
Comment thread docs/CONFIGURATION.md
Comment thread crates/tui/src/main.rs
@hongqitai hongqitai force-pushed the feature/path-suffix branch from 65eca12 to 5286ac4 Compare June 3, 2026 10:39
@hongqitai hongqitai marked this pull request as ready for review June 3, 2026 10:49
@hongqitai
Copy link
Copy Markdown
Contributor Author

Fix all pronlems, and add suport for new changes

@Hmbown
Copy link
Copy Markdown
Owner

Hmbown commented Jun 3, 2026

Thanks @hongqitai for the update. I see the branch is now green, which is a good sign. I am keeping it out of the v0.8.52 release freeze because configurable OpenAI-compatible path suffixes are a broad provider/config/docs feature rather than a cleanup fix for the 0.8.51 fallout. This should get a focused review after 0.8.52 is published so we do not bury your work inside the emergency release lane.

@Hmbown
Copy link
Copy Markdown
Owner

Hmbown commented Jun 5, 2026

Thanks @hongqitai. I’m closing this as superseded and credited now that the narrower path-suffix implementation has landed.

The provider-local path suffix support is on \ via #2558 / commits \ + , and the v0.9 stewardship branch adds #2776 / \ to keep \ out of untrusted project-local config overrides. The shipped behavior is narrower than #2508: it only rewrites chat-completions URLs, while model listing and DeepSeek beta/FIM routes keep their built-in paths.

Verified with
running 5 tests
test client::tests::api_url_with_suffix_ignores_suffix_for_models ... ok
test client::tests::api_url_with_suffix_default_behavior_without_suffix ... ok
test client::tests::api_url_with_suffix_ignores_suffix_for_beta_paths ... ok
test client::tests::api_url_with_suffix_handles_leading_slash ... ok
test client::tests::api_url_with_suffix_strips_version_before_chat_suffix ... ok

test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 4189 filtered out; finished in 0.00s and
running 1 test
test tests::project_merge_denies_credentials_endpoints_and_provider_selection ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 92 filtered out; finished in 0.00s.

Your updated PR and review cycle materially shaped the final safer contract, and the v0.9 changelog credits @hongqitai and @cyq1017 for the path-suffix follow-up PR trail. Thank you for pushing this forward.

@Hmbown
Copy link
Copy Markdown
Owner

Hmbown commented Jun 5, 2026

Correction: the close note above was garbled by shell quoting. This is the authoritative closure note.

Thanks @hongqitai. I’m closing this as superseded and credited now that the narrower path-suffix implementation has landed.

The provider-local path suffix support is on main via #2558 / commits d2999bb40 + 8b0e1cc3, and the v0.9 stewardship branch adds #2776 / cba5537b to keep path_suffix out of untrusted project-local config overrides. The shipped behavior is narrower than #2508: it only rewrites chat-completions URLs, while model listing and DeepSeek beta/FIM routes keep their built-in paths.

Verified with:

cargo test -p codewhale-tui --bin codewhale-tui --locked api_url_with_suffix -- --nocapture
cargo test -p codewhale-config --locked project_merge_denies_credentials_endpoints_and_provider_selection -- --nocapture

Your updated PR and review cycle materially shaped the final safer contract, and the v0.9 changelog credits @hongqitai and @cyq1017 for the path-suffix follow-up PR trail. Thank you for pushing this forward.

@hongqitai hongqitai deleted the feature/path-suffix branch June 5, 2026 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants