Repository navigation
fix: align custom Anthropic model discovery with native requests - #17881
AtefBellaaj wants to merge 1 commit into
Conversation
|
@codex review Please review head |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 05cdc52145
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
05cdc52 to
8ffdd95
Compare
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Custom endpoints with
provider: anthropicandmodels.fetch: truecannot use one base URL for discovery and sending. Discovery appends/modelsand sends OpenAI-style headers. The Anthropic SDK appends/v1/messages. Adding/v1to the base URL breaks sending.Discovery now uses the configured provider to append
/v1/modelsand sendx-api-keyandanthropic-version. The same root base URL works for both requests.How it works
Pass the existing provider field through discovery with shared credentials, discovery with user credentials, and token-config loading. Include the provider when sharing fetches and caching results. Preserve gateway path prefixes and the existing guards for user-supplied URLs and headers.
Type of change
Testing
Before the fix, eight new regression tests failed. After the fix, all 271 tests in the five focused suites passed.
npx jest --runInBand --coverage=false src/endpoints/models.spec.ts src/endpoints/config/models.spec.ts src/endpoints/custom/initialize.spec.ts src/endpoints/anthropic/llm.spec.ts src/endpoints/anthropic/initialize.spec.ts.NODE_OPTIONS=--max-old-space-size=8192 npx tsc --noEmit.Live checks against Anthropic confirmed the request paths and headers:
/models, HTTP 404/v1/models, HTTP 200; 14 models/v1/messages, HTTP 200The versioned base URL produced
/v1/v1/messagesand HTTP 404. Discovery at/v1/modelswith the old headers returned HTTP 400 becauseanthropic-versionwas missing. These checks used the discovery function and installed SDK, not the browser chat flow.Regression coverage includes trailing slashes, gateway prefixes, explicit providers on Ollama-like endpoint names, shared and user credentials, token-config discovery, cache separation, SDK paths and headers, OpenAI-compatible requests, and built-in Anthropic requests.
Screenshots / recordings
No visual change. The request behavior is covered by the API checks and regression tests above.
Risk / compatibility
OpenAI-compatible and built-in Anthropic discovery retain their existing paths and authentication behavior. Sending code is unchanged. No schema migration or dependency change is needed. The change can be reverted without changing stored data.
Checklist