Repository navigation
Conversation
The /v1/models endpoint only returned the static model cards shipped with the proxy, so newly released Claude models never showed up. Query Anthropic's Models API with the OAuth token, cache the catalogue for an hour and fall back to the static cards when upstream is unreachable or no token is available. Assisted-by: goose + MiniMax-M3.1-Flash
4 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
GET /claude/v1/modelsreturned only the static model cards shipped with the proxy (DEFAULT_CLAUDE_MODEL_CARDS). New Claude models never showed up there, even though the proxy could serve them: unknown full model IDs pass through unchanged to Anthropic.Solution
Query Anthropic's Models API with the OAuth token the adapter already manages, and merge the result with the static cards.
ccproxy/plugins/claude_api/live_models.py(new): fetcheshttps://api.anthropic.com/v1/modelswithAuthorization: Bearer <token>andanthropic-version: 2023-06-01, converts every entry into the OpenAI-compatible model shape (id,created,object,owned_by, plusdisplay_nameandlinewhen present) and caches the catalogue for one hour.ccproxy/plugins/claude_api/routes.py:/v1/modelsreturns the live catalogue merged with the static cards, so legacy models that Anthropic no longer lists stay available. Live entries win on id collisions.ccproxy/plugins/claude_api/adapter.py: adds a publicget_access_token()so other modules can reuse the token without reaching into the private resolver.ccproxy/plugins/claude_api/config.py: newlive_models_enabledflag (defaulttrue) to turn the live lookup off.Failure behaviour
The endpoint never breaks because of the upstream:
Test plan
uv run pytest tests/plugins/claude_api -q- 53 passeduv run ruff checkanduv run ruff format --checkon the touched filesuv run mypyon the touched files - no issuesNote for maintainers
/v1/modelsnow depends on an upstream call, so it is slightly slower on a cold cache. The one hour cache keeps that cost negligible and the fallback keeps the endpoint usable offline.Assisted-by: goose + MiniMax-M3.1-Flash