Learning resourcesReviewed · Anthropic

Claude Code gateway compatibility guide

This is Anthropic's reference page for operators who run an LLM gateway in front of Claude Code. It explains which endpoints, headers and request fields the gateway must pass through. Its catch is that much of what it describes is tied to specific Claude Code releases and changes over time. It covers the three API formats a gateway can expose (Anthropic Messages, Amazon Bedrock InvokeModel, Google Cloud Agent Platform rawPredict), request and response headers, streaming, the system prompt attribution block, per-feature beta header and body field pairs, automatic retry behaviour and model discovery.

Researched 14 Nov 2026

In short.

This is Anthropic's documentation page for people who run an LLM gateway in front of Claude Code. It says what requests the client sends and what the gateway must forward so features keep working. Its main catch is that the details are tied to specific Claude Code releases and change over time. The behaviour it describes is Anthropic's own documentation of its client, not independently measured results. The page defines two gateway duties for each header and body field: forward it unchanged, or consume it for routing, attribution or tracing. It lists three client connection methods and the exact failure symptoms when headers or fields are stripped, which are mostly HTTP 400 errors or features that quietly switch off. It also covers the retries Claude Code performs on its own and the contract for the model discovery endpoint.

Researched and written by an AI model and checked by a second AI model. How it works

Scope is the complete Claude Code gateway compatibility guide page at [https://code.claude.com/docs/en/llm-gateway-protocol.md], as of 14 November 2026. Linked pages are excluded and their content is not reflected, including rollout, connect, Claude apps gateway, errors, environment variables, beta headers and provider pages. All client and gateway behaviour described is as the page documents it; the page supplies no validation or test results for that behaviour. The page carries no licence or reuse notice, so rights are unknown.

The overview

What this resource is

This is a single documentation page on Anthropic's Claude Code site, titled Claude Code gateway compatibility guide, at [https://code.claude.com/docs/en/llm-gateway-protocol.md]. It documents the requests Claude Code sends to a gateway: the endpoints it calls, the headers and body fields the gateway must forward, and which features stop working when they are not forwarded.

The page is written for operators configuring a gateway product to work with Claude Code. It is separate from the reference served by Anthropic's own self-hosted Claude apps gateway at GET /protocol. That reference covers the Claude apps gateway's sign-in, inference, managed settings, model discovery and telemetry endpoints.

Overall assessment

This is a detailed and specific reference. It names concrete failure symptoms, such as a 400 saying Extra inputs are not permitted, along with the cause of each and the remediation. It also gives the version numbers at which behaviour changed, so it works as a debugging checklist and not just an overview.

Two cautions apply. First, the page describes a moving target: it says the set of capabilities Claude Code sends grows over releases, and it advises testing a gateway against new releases instead of pinning to an observed list. Second, every claim about client or gateway behaviour is Anthropic's own documented statement about its client, and the page does not say how those claims were validated.

Who it is for

The main audience is platform or infrastructure engineers who run or configure an LLM gateway or proxy, either their own or a third-party product, and want Claude Code to work through it. The page also suits anyone diagnosing 400 errors, stalled streams, missing prompt caching or an empty model picker when Claude Code goes through a gateway.

It is not the right starting point for an individual developer who only needs to connect with a credential they were given. The page points those readers to a separate guide, Connect Claude Code to an LLM gateway, and points organisation rollouts to Roll out an LLM gateway. Those guides are separate pages, and this page does not repeat their content.

What the guide covers

API formats: a gateway must expose at least one of three. Anthropic Messages uses /v1/messages and, optionally, /v1/messages/count_tokens. Amazon Bedrock InvokeModel uses /model/{model}/invoke and invoke-with-response-stream, with an optional count-tokens endpoint. Google Cloud Agent Platform rawPredict uses :rawPredict and :streamRawPredict, with an optional count-tokens:rawPredict. Microsoft Foundry and Claude Platform on AWS use the Anthropic Messages format, and a gateway fronting Claude Platform on AWS must also forward the anthropic-workspace-id header.

Client behaviour by connection method: model IDs, anthropic-beta values, request fields and defaults differ between the Bedrock or Agent Platform format, the Anthropic Messages format, and signing in to a Claude apps gateway. Request headers: forward anthropic-version and anthropic-beta unchanged, and forward Authorization when a claude.ai login authenticates to Anthropic. The headers x-claude-code-session-id, x-claude-code-agent-id and x-claude-code-parent-agent-id can be consumed for attribution. The page also describes optional gateway hint headers covering request class, agent type, compaction markers, previous tool durations and prompt ID. These require v2.1.273 or later, and the prompt ID header requires v2.1.283 or later.

Response headers: content-type, retry-after, x-should-retry and anthropic-ratelimit-unified-*. The retry-after value should be integer seconds, and a value above 60 stops retries outside the retry watchdog. The page also covers the system prompt attribution block and its interaction with prompt caching, a table of beta header and body field pairs with symptoms and fixes, the automatic retries Claude Code performs, the CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS switch, and model discovery through /v1/models.

Using it

What you need

To apply the guide you need a gateway that exposes at least one supported API format and that you can configure, or whose vendor lets you configure it. You also need Claude Code clients that you can point at it using environment variables or managed settings. The page does not name an overall minimum Claude Code version, but many behaviours are version-gated. Hint headers need v2.1.273 or later, the prompt ID header v2.1.283, the context management retry v2.1.304, the tool search retry v2.1.305, and retry on a rejected beta value mostly v2.1.314. The attribution block is stable from v2.1.181, and sending both credential headers during model discovery needs v2.1.248.

The page does not list required skills or prerequisite knowledge. Familiarity with HTTP proxying, streaming responses such as server-sent events, and the upstream provider's API is useful background for applying it, but the page does not state it as a prerequisite. Whether a particular gateway product can meet each requirement is not covered and is unknown.

How it works

The page's central idea is that Claude Code treats a gateway set with ANTHROPIC_BASE_URL as the Claude API itself. It sends that gateway the beta headers and body fields it would send to api.anthropic.com, apart from a few defaults reserved for direct connections. When the client speaks the Bedrock or Agent Platform format, it sends only the subset those providers accept. When it speaks Anthropic Messages, it sends the full set even if the gateway forwards to Bedrock or Agent Platform, so bridging the schema difference is the gateway's job.

Many capabilities pair an anthropic-beta value with a request body field. Stripping one half while passing the other causes 400 errors, and removing both turns the feature off quietly. For an Anthropic-format upstream, the page therefore advises forwarding anthropic-* request headers and request body fields unchanged, treating them as open lists rather than allowlisting what is seen today. It also advises inspecting bodies without modifying them. The page explicitly excepts non-Anthropic upstreams such as Amazon Bedrock or Google Cloud's Agent Platform, where bridging the schema difference is the gateway's job and fields may need to be adapted rather than passed through.

For streaming, the gateway must relay events as they arrive and deliver the full event sequence through message_delta and message_stop. It must keep SSE ping events, or emit its own, to avoid the client's idle timeout. On the Bedrock format it must return the binary application/vnd.amazon.eventstream body unmodified.

When an upstream rejects a capability, Claude Code can retry on its own. It can switch the thinking type, drop mid-conversation system messages, move a cache_control marker or remove earlier thinking blocks. It can also drop the advisor tool, effort, context_management or a named beta value, or resend without tool search fields. Most of this matches on the upstream's error wording, so error bodies should be forwarded unmodified, or wrapped in a message that carries a stable capability_rejected: token.

Setup steps the page describes

This documentation assumes a Claude Code client and a configurable gateway; it does not provide their installation instructions. Configuration is by environment variables or managed settings on the client side, plus gateway behaviour. For the Anthropic Messages format a client sets ANTHROPIC_BASE_URL. For Bedrock it sets ANTHROPIC_BEDROCK_BASE_URL with CLAUDE_CODE_USE_BEDROCK=1, and for Agent Platform it sets ANTHROPIC_VERTEX_BASE_URL with CLAUDE_CODE_USE_VERTEX=1.

The page names several optional switches. CLAUDE_CODE_GATEWAY_HINT_HEADERS=1 turns on hint headers for a custom base URL, and 0 stops them on every connection. CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 populates the model picker from /v1/models, and CLAUDE_CODE_GATEWAY_MODEL_DISCOVERY_TIMEOUT_MS extends the default 3 second discovery timeout. CLAUDE_CODE_ATTRIBUTION_HEADER=0 is for gateways that must reshape system content, and CLAUDE_CODE_AUTO_MODE_SERVER=0 turns off server-side classifier review. Per-developer credential setup is in a separate linked guide that is not part of this page.

CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 is for the narrower case where the gateway or its upstream rejects pre-release anthropic-beta values or their paired body fields, and both halves cannot be forwarded. It stops those pre-release pairs, such as context_management, beta tool fields like strict and defer_loading, output_config.format and output_config.task_budget. The page says it does not strip every anthropic-beta value: the adaptive thinking field, the top-level output_config.effort field and mid-conversation system messages stay in place. It therefore cannot generally substitute for bridging incompatible schemas.

Worked example from the page's own scenarios

This illustrative scenario is drawn from the page's feature table. A gateway accepts Anthropic Messages requests from Claude Code but forwards them to Amazon Bedrock. Claude Code sends the context_management body field with its beta header, and Bedrock rejects it with a 400 containing Extra inputs are not permitted. The page gives three ways out. The first is to forward both halves to an upstream that accepts them. The second is to have developers set CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1. The third, on v2.1.304 or later, is to let Claude Code retry on its own without the pair, provided the gateway returns the upstream's error message unmodified.

The page also shows the model discovery response shape. A GET /v1/models?limit=1000 request returns a data array whose entries have an id and, optionally, a display_name and description. One example entry has the id claude-sonnet-4-6 and the display_name Claude Sonnet 4.6. Claude Code keeps an entry only when its id contains claude or anthropic anywhere in the string, matched case-insensitively.

Assessment & evidence

Limits and caveats

Scope: this is documentation for one client's gateway traffic. It does not describe how to build a gateway, it does not cover any specific third-party gateway product, and it does not say whether a given product meets its requirements.

Staleness risk: the page says the set of headers, fields and beta values grows with Claude Code releases, and many rows depend on version numbers. Several rows are also tied to named models, for example Claude Opus 4.8, Claude Fable 5 and Claude Haiku 5.5, so model-specific guidance can change as models change.

Documented platform limits: sessions through a gateway are not eligible for the HIPAA configuration. The fast mode availability check and the WebFetch domain safety check call api.anthropic.com directly instead of following ANTHROPIC_BASE_URL. They can therefore fail on networks that block direct egress while gateway inference keeps working. Model discovery is off by default, fails silently on slow responses or redirects, and applies only to the Anthropic Messages format. Many topics are deferred to linked pages, including rollout, connect, errors, environment variables and the Claude apps gateway, and this page does not repeat their content.

Why the findings hold

The guide is a first-party source: Anthropic documenting the behaviour of its own client. It is specific rather than promotional, giving exact paths, header names, field names, error strings, retry conditions and version cut-offs. That specificity makes it checkable against a real gateway. Because the publisher is the maker of the client, its description of client behaviour is a direct first-party account.

The limits are equally clear. The page is a single source, describes intended client behaviour rather than measured results, and does not say how its claims were validated or cite independent sources. Its statements should be read as what Anthropic documents for the cited versions, not as independently measured behaviour.

Alternatives and related options

Within the page itself, one route avoids the bridging. If the upstream is Amazon Bedrock or Google Cloud's Agent Platform, the gateway can expose that provider's own format (Bedrock InvokeModel or Agent Platform rawPredict) instead of accepting Anthropic Messages. The client then sends only the subset that provider accepts.

A related option is Anthropic's self-hosted Claude apps gateway, which has its own reference at GET /protocol. When developers sign in to it, Claude Code sends only the anthropic-beta values and model-capability assumptions that Amazon Bedrock and Agent Platform also accept. The page also says the Claude apps gateway substitutes capability_rejected: tokens for cloud providers' error wording. It does not establish how much gateway-side work adopting it would save.

The page also lists related reading: a gateway overview for choosing between the Claude apps gateway and another product, an admin rollout checklist, a per-developer connection guide, the beta headers reference and the Messages API reference. Their content is not part of this page. The page makes no comparisons with specific third-party gateway products.

Evidence base

The source is a single first-party documentation page, Claude Code gateway compatibility guide, at [https://code.claude.com/docs/en/llm-gateway-protocol.md] on Anthropic's Claude Code documentation site. Its claims are backed by specifics: exact endpoint paths, header and body field names, error strings, retry conditions, version cut-offs and a sample /v1/models response. The page cites no benchmarks, test results or independent sources. It links to related pages (rollout, connect, errors, environment variables, beta headers, provider pages) for detail it does not include itself.

Access & freshness

Costs

The page states no prices or subscription terms for Claude Code, any gateway product, or upstream model usage, so those costs are unknown. It also does not say whether reading the page itself is free.

It does flag one cost-related failure mode. If a gateway converts system or message content to plain strings, or strips cache_control, prompt caching stops working with no error. The conversation then bills as uncached input on every turn, which shows up as high input_tokens with little or no cache activity in usage. The page does not quantify the size of that effect.

Rights and licence

The page text contains no licence statement, copyright notice or terms of reuse, so its reuse and redistribution rights are unknown. The page is documentation rather than a software package, and it grants no permission to reuse or redistribute its contents.

Freshness

This description reflects the page as of 14 November 2026. The page shows no publication or last-updated date, so its own age is unknown. The newest Claude Code versions it cites include v2.1.314, and it says behaviour changes across releases. Readers should expect the live page to move on and should check it against the Claude Code release they actually deploy.

Suggested next steps

If you run a gateway, check that it forwards anthropic-version and anthropic-beta verbatim. When the upstream is Anthropic-format, it should also pass anthropic-* request headers and request body fields through unchanged rather than allowlisting them. Check as well that it relays streams unbuffered with ping events intact, returns retry-after as integer seconds, passes x-should-retry and anthropic-ratelimit-unified-* through, and returns upstream error bodies unmodified. Keep the system array and cache_control markers intact so prompt caching still works. If the upstream is a non-Anthropic provider such as Amazon Bedrock or Google Cloud's Agent Platform, the page treats bridging the schema difference as the gateway's job, so blanket pass-through is not the rule there.

If your upstream is Bedrock or Agent Platform and you cannot bridge the schema difference, consider exposing that provider's own format. Use CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 only to address unsupported pre-release header and field pairs. It does not remove the adaptive thinking field, the top-level output_config.effort field, mid-conversation system messages or every beta value, so it cannot generally replace schema bridging. Then test against the Claude Code release you actually deploy, because the behaviour this page describes is version-dependent. For individual credential setup and rollout checklists, follow the linked guides Connect Claude Code to an LLM gateway and Roll out an LLM gateway, which are separate pages.

Evidence for this report

selected-page.txtselected · checked 2026-11-14