Skip to content

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

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

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.

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