Feature Request
Summary
Claude Code 2.1.126+ added gateway model discovery: when ANTHROPIC_BASE_URL points at a compatible gateway, it queries {base_url}/v1/models at startup and populates the /model picker with discovered models labeled "From gateway".
However, this discovery only works with the Anthropic-native /v1/models response format — it does not parse the OpenAI-format response that LiteLLM currently returns.
Current Behavior
LiteLLM's /v1/models returns OpenAI format:
{
"data": [
{
"id": "claude-opus-4-6",
"object": "model",
"created": 1677610602,
"owned_by": "openai"
}
],
"object": "list"
}
Expected Behavior
Claude Code expects the Anthropic native format:
{
"data": [
{
"type": "model",
"id": "claude-opus-4-6",
"display_name": "Claude Opus 4.6",
"created_at": "2025-05-14T00:00:00Z"
}
],
"has_more": false,
"first_id": "claude-opus-4-6",
"last_id": "claude-haiku-4-5"
}
Key differences:
type: "model" instead of object: "model"
display_name field (used as label in the picker)
created_at (ISO 8601) instead of created (unix timestamp)
- Top-level
has_more, first_id, last_id instead of object: "list"
Claude Code's Discovery Filter
From the docs:
Only models whose ID begins with claude or anthropic are added to the picker. Results are cached to ~/.claude/cache/gateway-models.json.
Authentication: sends x-api-key header (or Bearer token via ANTHROPIC_AUTH_TOKEN), same as inference requests.
Proposed Solution
Since LiteLLM already supports the Anthropic /v1/messages pass-through endpoint for Claude Code users, adding an Anthropic-format response option for /v1/models would complete the compatibility story. Possible approaches:
- Content negotiation: Return Anthropic format when the request includes
anthropic-version header (same header Claude Code sends for /v1/messages)
- Separate endpoint: Serve Anthropic-format at
/anthropic/v1/models (similar to the existing /anthropic pass-through path)
- Config option: A setting like
model_list_format: anthropic to switch the /v1/models response format globally
Environment
- LiteLLM version: latest stable (deployed on EKS)
- Claude Code version: 2.1.128
- Config: Using
ANTHROPIC_BASE_URL pointing to LiteLLM proxy root, with /v1/messages working correctly
Additional Context
The gateway model discovery feature was added in Claude Code 2.1.126 changelog. Many Claude Code + LiteLLM users would benefit from this since it enables seamless model switching without manual configuration.
Feature Request
Summary
Claude Code 2.1.126+ added gateway model discovery: when
ANTHROPIC_BASE_URLpoints at a compatible gateway, it queries{base_url}/v1/modelsat startup and populates the/modelpicker with discovered models labeled "From gateway".However, this discovery only works with the Anthropic-native
/v1/modelsresponse format — it does not parse the OpenAI-format response that LiteLLM currently returns.Current Behavior
LiteLLM's
/v1/modelsreturns OpenAI format:{ "data": [ { "id": "claude-opus-4-6", "object": "model", "created": 1677610602, "owned_by": "openai" } ], "object": "list" }Expected Behavior
Claude Code expects the Anthropic native format:
{ "data": [ { "type": "model", "id": "claude-opus-4-6", "display_name": "Claude Opus 4.6", "created_at": "2025-05-14T00:00:00Z" } ], "has_more": false, "first_id": "claude-opus-4-6", "last_id": "claude-haiku-4-5" }Key differences:
type: "model"instead ofobject: "model"display_namefield (used as label in the picker)created_at(ISO 8601) instead ofcreated(unix timestamp)has_more,first_id,last_idinstead ofobject: "list"Claude Code's Discovery Filter
From the docs:
Authentication: sends
x-api-keyheader (or Bearer token viaANTHROPIC_AUTH_TOKEN), same as inference requests.Proposed Solution
Since LiteLLM already supports the Anthropic
/v1/messagespass-through endpoint for Claude Code users, adding an Anthropic-format response option for/v1/modelswould complete the compatibility story. Possible approaches:anthropic-versionheader (same header Claude Code sends for/v1/messages)/anthropic/v1/models(similar to the existing/anthropicpass-through path)model_list_format: anthropicto switch the/v1/modelsresponse format globallyEnvironment
ANTHROPIC_BASE_URLpointing to LiteLLM proxy root, with/v1/messagesworking correctlyAdditional Context
The gateway model discovery feature was added in Claude Code 2.1.126 changelog. Many Claude Code + LiteLLM users would benefit from this since it enables seamless model switching without manual configuration.