Skip to content

feat(claude_api): list models from Anthropic's live catalogue - #79

Open
yajo wants to merge 1 commit into
CaddyGlow:mainfrom
moduon:feat/live-model-catalogue
Open

yajo wants to merge 1 commit into
CaddyGlow:mainfrom
moduon:feat/live-model-catalogue

Conversation

@yajo

@yajo yajo commented Oct 28, 2026

Copy link
Copy Markdown

Problem

GET /claude/v1/models returned 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): fetches https://api.anthropic.com/v1/models with Authorization: Bearer <token> and anthropic-version: 2023-06-01, converts every entry into the OpenAI-compatible model shape (id, created, object, owned_by, plus display_name and line when present) and caches the catalogue for one hour.
  • ccproxy/plugins/claude_api/routes.py: /v1/models returns 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 public get_access_token() so other modules can reuse the token without reaching into the private resolver.
  • ccproxy/plugins/claude_api/config.py: new live_models_enabled flag (default true) to turn the live lookup off.

Failure behaviour

The endpoint never breaks because of the upstream:

  • No usable token (not logged in, missing scope) → static cards.
  • Anthropic unreachable or returning an error → the last successful catalogue is kept, and the static cards are used if there is none yet.

Test plan

  • uv run pytest tests/plugins/claude_api -q - 53 passed
  • uv run ruff check and uv run ruff format --check on the touched files
  • uv run mypy on the touched files - no issues
  • Live check against Anthropic: 13 active models returned, merged with the static cards

Note for maintainers

/v1/models now 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

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant