Skip to content

fix: align custom Anthropic model discovery with native requests - #17881

Draft
AtefBellaaj wants to merge 1 commit into
devfrom
codex/fix-anthropic-custom-model-discovery
Draft

AtefBellaaj wants to merge 1 commit into
devfrom
codex/fix-anthropic-custom-model-discovery

Conversation

@AtefBellaaj

Copy link
Copy Markdown
Collaborator

Summary

Custom endpoints with provider: anthropic and models.fetch: true cannot use one base URL for discovery and sending. Discovery appends /models and sends OpenAI-style headers. The Anthropic SDK appends /v1/messages. Adding /v1 to the base URL breaks sending.

Discovery now uses the configured provider to append /v1/models and send x-api-key and anthropic-version. The same root base URL works for both requests.

baseURL: https://api.anthropic.com
  discovery → GET  /v1/models
  sending   → POST /v1/messages

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

  • Bug fix
  • Tests / tooling / CI

Testing

Before the fix, eight new regression tests failed. After the fix, all 271 tests in the five focused suites passed.

  1. API workspace: 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.
  2. API workspace: NODE_OPTIONS=--max-old-space-size=8192 npx tsc --noEmit.
  3. Scoped static checks for all five changed files.
  4. Lighthouse passed: median LCP 3453 ms, CLS 0.018, TBT 44 ms.

Live checks against Anthropic confirmed the request paths and headers:

Request Before After
Discovery with the root base URL /models, HTTP 404 /v1/models, HTTP 200; 14 models
SDK sending with the root base URL /v1/messages, HTTP 200 Unchanged

The versioned base URL produced /v1/v1/messages and HTTP 404. Discovery at /v1/models with the old headers returned HTTP 400 because anthropic-version was 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

  • I reviewed my own changes
  • Relevant tests have been added or updated
  • Existing relevant tests pass
  • The change does not introduce new warnings or errors
  • User-facing or complex behavior is documented where necessary
  • Required dependency changes have been merged/published: N/A
  • Required documentation PR: N/A

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review head 05cdc5214558725a6011736fed5f72fbf524b3d6. Focus on custom Anthropic discovery paths and authentication, forwarding the configured provider through every discovery caller, and preserving OpenAI-compatible and built-in Anthropic behavior.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-07T00:48:08.512893Z 8ffdd95 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread packages/api/src/endpoints/models.ts Resolved
@AtefBellaaj

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review head 05cdc52.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

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".

@AtefBellaaj
AtefBellaaj force-pushed the codex/fix-anthropic-custom-model-discovery branch from 05cdc52 to 8ffdd95 Compare November 7, 2026 00:43
@AtefBellaaj

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review head 8ffdd95.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 8ffdd95a22

ℹ️ 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".

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant