SpyBara
Go Premium

llm-gateway.md 2026-06-25 23:58 UTC to 2026-06-26 23:00 UTC

3 added, 11 removed.

2026
Tue 30 23:02 Mon 29 23:02 Sat 27 01:01 Fri 26 23:00 Thu 25 23:58 Wed 24 22:02 Tue 23 22:00 Mon 22 23:59 Fri 19 22:58 Thu 18 22:00 Wed 17 17:02 Tue 16 21:57 Mon 15 23:02 Sat 13 21:59 Fri 12 22:00 Thu 11 23:01 Wed 10 23:57 Tue 9 06:34 Mon 8 06:52 Sat 6 06:24 Fri 5 06:45 Thu 4 06:52 Wed 3 06:53 Tue 2 06:51

LLM gateways

Route Claude Code through an LLM gateway for centralized authentication, usage tracking, and cost controls. Covers connecting Claude Code to a gateway, rolling one out for your organization, what Claude Code sends to a gateway, and how gateways interact with claude.ai subscriptions.

An LLM gateway is a proxy your organization runs between Claude Code and a model provider. Claude Code sends API traffic to the gateway, and the gateway forwards it to the provider using a credential your organization controls.

What a gateway provides

A gateway gives your organization one place to manage:

  • Credentials: the provider key stays server-side; developers hold gateway credentials instead
  • Usage tracking: attribute usage by developer or team, regardless of which provider serves the request
  • Cost controls: enforce budgets and rate limits in one place
  • Audit logging: log every model request for compliance
  • Provider switching: change the provider in gateway configuration, without touching developer machines

All of these except provider switching apply whether the upstream is Anthropic's API or a cloud provider.

The tradeoff is that the gateway becomes infrastructure your organization operates. Claude Code adds capabilities with each release, and a gateway that doesn't forward them breaks the corresponding features, so the gateway product needs to be kept updated as Claude Code evolves. The gateway protocol reference covers what to forward.

How a gateway works

By default, Claude Code sends requests directly to Anthropic's API at api.anthropic.com. To route through a gateway, set ANTHROPIC_BASE_URL to the gateway's address; Claude Code sends the same requests there instead. The gateway authenticates the developer, attaches your organization's provider credential, and forwards each request to whichever provider it's configured for.

ANTHROPIC_BASE_URL is the address variable for most gateways. A gateway that fronts a specific cloud provider, such as Bedrock, Vertex, Foundry, or the Claude Platform on AWS, uses that provider's base URL variable instead; API formats lists which variable goes with each configuration.

Diagram showing Claude Code routing through an LLM gateway. In a developer machines zone, the Claude Code CLI, VS Code extension, and CI or Agent SDK clients send requests to the gateway, with the base URL variable for the gateway's API format pointing at it and each developer holding a per-developer credential, and the desktop app reaches the same gateway through organization-distributed configuration. In a zone labeled your infrastructure, the LLM gateway handles authentication, usage tracking, budgets, and routing, and forwards requests with your organization's credential. In a model providers zone, a solid arrow leads to the provider you configure, shown as the Anthropic API, and dashed arrows lead to other provider options, illustrated with Amazon Bedrock, Google Vertex AI, and Microsoft Foundry as examples.

Two kinds of credential are involved:

  • Developer credentials: each developer holds their own, issued by the gateway. It authenticates them to the gateway and identifies them in usage tracking
  • Provider credential: the gateway holds one credential for your provider account, shared by all forwarded traffic. You don't provision provider keys per developer

The gateway forwards each request to the provider you configure, such as the Anthropic API, Amazon Bedrock, Google Vertex AI, Microsoft Foundry, or the Claude Platform on AWS. Because Claude Code talks only to the gateway, the provider choice is the gateway's configuration, not the client's.

Roll out a gateway

When you're ready to roll out an LLM gateway to your organization, the sequence is the same whichever gateway product you choose:

  1. Deploy the gateway and give it your provider credential, so it can authenticate the requests it forwards.
  2. Issue each developer a gateway credential, so usage is attributed to the developer and offboarding revokes one credential.
  3. Distribute the configuration through a managed settings file and your secrets tooling, so every machine receives the base URL and a credential. When both are distributed, developers don't configure anything. If you don't have settings distribution in place, developers follow the connect page to set the variables themselves.
  4. Have each developer check for the configuration in Claude Code, so distribution problems surface before they depend on the gateway.

Roll out an LLM gateway for your organization walks each step and shows the configuration files to distribute at each one. The gateway is one part of organization setup; for policy enforcement, usage visibility, and data handling decisions, see Set up Claude Code for your organization.

Third-party gateways

Any gateway that exposes a supported API format works. Anthropic doesn't endorse, maintain, or audit third-party gateway products. Deploy them following their own documentation, then complete the Claude Code side of the rollout with the rollout steps.

Subscriptions and gateways

While a gateway credential variable or apiKeyHelper is active, a developer's claude.ai subscription isn't used: the credential replaces the subscription login for that session, and the subscription's usage limits don't apply. That traffic is billed per token to whoever owns the credential the gateway forwards, such as your organization's Anthropic Console account, or your Bedrock, Vertex, or Foundry account when the gateway routes there.

Setting only ANTHROPIC_BASE_URL, without a gateway credential, doesn't replace the subscription. Requests still route through the gateway, but a saved claude.ai login remains the active credential, so its usage limits and billing apply. Gateways that pass this traffic on to Anthropic must forward the OAuth capability in anthropic-beta; see the request headers reference.

Configure separately from the gateway

A gateway determines where model API requests are sent. Model selection, the rest of Claude Code's network traffic, and corporate proxies are configured separately:

  • Model selection: the base URL decides where requests go, not which model answers them. Pick the model with the /model command or the model environment variables; see how to set your model
  • Client-side traffic: version checks and optional client telemetry, both disabled with CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC, and login traffic when a claude.ai or Console login is in use, go to Anthropic's update and authentication endpoints rather than the gateway. See network access requirements for the domains
  • Corporate proxies: a proxy set with HTTPS_PROXY sits between Claude Code and every server it talks to, including the gateway. If your network requires a proxy, configure both; see proxy configuration