Conform Claude models listing to Anthropic API schema#3834
Conversation
Anthropic's List Models response (GET /v1/models) defines each model object with id, display_name, max_input_tokens, max_tokens, created_at and type. The Claude case of convertModelToMap emitted an incomplete object: it dropped max_input_tokens and max_tokens entirely and omitted display_name whenever it was unset, so the Anthropic-compatible listing did not match the schema it emulates. Emit max_input_tokens from ContextLength and max_tokens from MaxCompletionTokens (the same registry metadata the Gemini case already surfaces as inputTokenLimit/outputTokenLimit), with fallbacks, and always emit display_name, falling back to the model ID.
|
This pull request targeted The base branch has been automatically changed to |
There was a problem hiding this comment.
Code Review
This pull request adds default token limits (max_input_tokens and max_tokens) and display name fallbacks for Claude models in the model registry, along with corresponding unit tests. The review feedback suggests adjusting the default maximum output tokens for Claude from 64,000 to 8,192 to match actual model limits, and formatting the created_at field as an RFC 3339 datetime string instead of a Unix timestamp to align with the Anthropic API schema.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Anthropic's List Models schema types created_at as an RFC 3339 datetime string, but the Claude case of convertModelToMap emitted model.Created as a Unix-timestamp integer. Format it with time.RFC3339 so the listing matches the documented schema.
|
This endpoint is shared by OpenAI and Anthropic. You need to implement a mechanism to distinguish between them. |
/v1/models is shared by the OpenAI and Anthropic surfaces and was dispatched to the Claude format only for claude-cli User-Agents, so generic Anthropic API clients received the OpenAI format. Distinguish Anthropic requests by the Anthropic-Version header (sent by every Anthropic client, never by OpenAI/Codex clients) in addition to the existing claude-cli check, in both unifiedModelsHandler and handleHomeModels. Additive and non-breaking for existing clients.
I thought the change only affected the Claude path, but it sounds like you want the shared |
Anthropic's List Models response (GET /v1/models) defines each model object with id, display_name, max_input_tokens, max_tokens, created_at and type. The Claude case of convertModelToMap emitted an incomplete object: it dropped max_input_tokens and max_tokens entirely and omitted display_name whenever it was unset, so the Anthropic-compatible listing did not match the schema it emulates.
Emit max_input_tokens from ContextLength and max_tokens from MaxCompletionTokens (the same registry metadata the Gemini case already surfaces as inputTokenLimit/outputTokenLimit), with fallbacks, and always emit display_name, falling back to the model ID.
Fixes: #3833