Extend the gateway model discovery timeout
CHANGELOG · original
Added CLAUDE_CODE_GATEWAY_MODEL_DISCOVERY_TIMEOUT_MS to extend the LLM gateway /v1/models discovery timeout (default 3s) Open official changelog ↗ Documentation
Documentation excerpt
Request and response
The request is GET /v1/models?limit=1000 with a timeout of 3 seconds by default, and any redirect is treated as failure so the credential can't leak to a redirect target. A gateway that responds slower than the timeout, or one that redirects /v1/models, even http to https, fails discovery silently; serve the endpoint directly at the configured base URL.
To give a slow gateway longer, set CLAUDE_CODE_GATEWAY_MODEL_DISCOVERY_TIMEOUT_MS. The variable requires Claude Code v2.1.269 or later.
Claude Code sends the discovery request with both credential headers below and omits a header whose value doesn't resolve. Sending both headers requires Claude Code v2.1.248 or later. Earlier versions send only Authorization when ANTHROPIC_AUTH_TOKEN is set and only x-api-key otherwise.
Authorization:ANTHROPIC_AUTH_TOKENas a bearer token, otherwise theapiKeyHelpervalue as a bearer token. In that case Claude Code waits for the helper to return before sending the request.x-api-key: the API key Claude Code resolved, such asANTHROPIC_API_KEY. When a helper value is the only credential, this header carries it too, so the value arrives in both headers.
Claude Code also sends any headers from ANTHROPIC_CUSTOM_HEADERS. When a custom header has a non-empty value, Claude Code sends it in place of a built-in header of the same name, matching names case-insensitively.
When neither credential header's value resolves, Claude Code skips discovery and writes a [gatewayDiscovery] skipped line to the debug log of a claude --debug session. If you supply a credential only through ANTHROPIC_CUSTOM_HEADERS, Claude Code still skips discovery.
Claude Code reads id, the optional display_name, and the optional description from each entry in the response's data array:
{
"data": [
{
"id": "claude-sonnet-4-6",
"display_name": "Claude Sonnet 4.6",
"description": "Default model for everyday coding tasks"
},
{ "id": "claude-opus-4-8" }
]
}
Claude Code keeps an entry when its id contains claude or anthropic anywhere in the string, matched case-insensitively, and ignores the rest. Provider-prefixed IDs such as vertex_ai/claude-sonnet-4-6 or bedrock/anthropic.claude-sonnet-4-5 pass the filter; an ID that contains neither substring doesn't. Before v2.1.223, Claude Code kept an entry only when its id began with claude or anthropic, which hid provider-prefixed IDs.
Documentation snapshot · 2026-09-23