BlogTooling
Routing Claude Code, GitHub Copilot and Cursor through an LLM gateway
You can route coding agents through an LLM gateway today, but as of 7 November 2026 the three common tools support it to very different degrees. Claude Code is designed for it: point ANTHROPIC_BASE_URL at the gateway, give each developer a gateway credential, and a managed setting can refuse any other destination. GitHub Copilot's enterprise bring your own key, still in public preview, adds models from your provider or an OpenAI-compatible endpoint to Chat, CLI and IDEs. Cursor accepts your own provider keys, but every request still goes through Cursor's servers and Tab stays on Cursor's own models.
Why route coding agents through a gateway at all
A gateway gives you one control point for traffic that otherwise goes straight from every developer laptop to a model provider. Anthropic's Claude Code documentation lists the same benefits most platform teams are after:
- Spend per team: each developer holds a gateway credential, so usage is attributed to a person and team whichever provider serves the request
- A model allow-list: the gateway exposes only the models you have approved and priced
- Revocation in one place: the provider key stays on the server, and offboarding means revoking one gateway credential
- Provider and region choice: the gateway can forward to Claude on Amazon Bedrock, Google Cloud or Microsoft Foundry in your own cloud account, and you can switch without reconfiguring developer machines
- An audit log of model requests, where your policies require one
Switching providers without touching laptops only works if the gateway exposes one Anthropic-format endpoint whatever sits behind it. The price is that the gateway becomes infrastructure you operate. Anthropic warns that Claude Code adds capabilities with each release and that a gateway which does not forward them breaks those features, so someone has to keep it current. Our view is that one team on one provider with no audit requirement can often manage with separate provider workspaces or keys. A gateway starts to pay off once several teams, several tools or a residency requirement come into play.
Which coding agents support a gateway, as of 7 November 2026
Only Claude Code lets you send all of its model traffic through your own gateway and enforce that centrally. GitHub Copilot and Cursor let you bring provider keys or endpoints for part of the product, and their own models stay in use for the rest.
| Tool | How it connects | Can you enforce it | What stays outside your gateway |
|---|---|---|---|
| Claude Code | ANTHROPIC_BASE_URL plus a gateway credential, or provider-format variables for Bedrock, Google Cloud and Foundry | Yes, with allowedProviders set to customEndpoint in managed settings, Claude Code v2.1.285 or later | Telemetry and a few checks that go to Anthropic directly; Claude Code in Slack and cloud sessions |
| GitHub Copilot, enterprise BYOK (public preview) | Owners add keys for Anthropic, AWS Bedrock, Google AI Studio, Microsoft Foundry, OpenAI, OpenAI-compatible providers or xAI | Partly: custom models are added to the model picker next to GitHub's own | GitHub's built-in models; the docs name only Chat, Copilot CLI and IDEs as surfaces |
| GitHub Copilot, local BYOK | Each user adds a provider key in VS Code, JetBrains IDEs, Xcode, Copilot CLI and other clients | No, but Business and Enterprise owners can switch it off by policy | Code completions in VS Code, according to GitHub's April 2026 announcement |
| Cursor | Own keys for OpenAI, Anthropic, Google, Azure OpenAI and AWS Bedrock | No central enforcement is documented | Tab completion; every request passes through Cursor's servers for prompt building |
GitHub Copilot bring your own key
GitHub runs two mechanisms. Enterprise BYOK, for Copilot Business and Copilot Enterprise and still in public preview, lets enterprise or organisation owners add keys that every user then sees at the bottom of the model picker. In January 2026 GitHub added AWS Bedrock, Google AI Studio and any OpenAI-compatible provider, plus Responses API models, a maximum context window and streaming. That OpenAI-compatible option is the route to a LiteLLM endpoint. Local BYOK keys stay on the user's machine. GitHub's April 2026 announcement for VS Code says usage is billed by your provider, does not count against Copilot request quotas, and does not apply to code completions.
GitHub describes enterprise BYOK as handled server-side, through the Copilot API, and does not document the data path. Our reading is that the requests to your endpoint then come from GitHub's side rather than from the developer's laptop, so confirm the network requirements with GitHub before you plan a gateway that is only reachable internally.
Cursor with your own API keys
Cursor's help page on API keys lists OpenAI, Anthropic, Google, Azure OpenAI and AWS Bedrock, with Bedrock access through keys in the IDE or IAM roles set up in the Cursor dashboard. Own keys only work with chat models, and Tab completion keeps using Cursor's built-in models. Requests are routed through Cursor's servers for final prompt building. The key is sent with each request and not stored. Cursor's Zero Data Retention policy does not apply when you use your own keys, and own-key requests on Teams and Enterprise plans carry a Cursor fee on top of the provider's charges. The page does not document a custom base URL. In practice, own keys let you bill usage to your Azure or Bedrock account, but the traffic still leaves your network.
Setting up Claude Code with LiteLLM or another gateway
Claude Code needs a base URL and a credential. ANTHROPIC_BASE_URL points it at a gateway that serves the Anthropic Messages format at /v1/messages, which LiteLLM does. The credential goes in ANTHROPIC_AUTH_TOKEN if the gateway reads an Authorization bearer token, which is how LiteLLM virtual keys are sent, or in ANTHROPIC_API_KEY if it reads x-api-key. For keys that rotate or come from a vault, an apiKeyHelper command prints the credential and Claude Code sends it in both headers. The output is cached for five minutes by default, and CLAUDE_CODE_API_KEY_HELPER_TTL_MS changes that.
Distribute both through managed settings and your secrets tooling, never through the repository. Anthropic warns against putting a credential in a project's .claude/settings.json because that file is committed. To make the gateway the only destination a managed machine may use, the managed settings file sets allowedProviders and the base URL together:
{
"allowedProviders": ["customEndpoint"],
"env": {
"ANTHROPIC_BASE_URL": "https://llm-gateway.example.com"
}
}Claude Code then refuses a session pointed anywhere else, including Anthropic directly or a developer's own proxy. If the gateway speaks the native formats of Amazon Bedrock or Google Cloud's Agent Platform, formerly Vertex AI, use ANTHROPIC_BEDROCK_BASE_URL with CLAUDE_CODE_USE_BEDROCK=1 and CLAUDE_CODE_SKIP_BEDROCK_AUTH=1, or the VERTEX equivalents. Claude Code then sends only the features those providers accept. Microsoft Foundry uses ANTHROPIC_FOUNDRY_BASE_URL with CLAUDE_CODE_USE_FOUNDRY=1.
Three details catch teams out. A gateway credential replaces the developer's claude.ai subscription for those requests, so the traffic is billed per token to whoever owns the upstream key. Setting only the base URL leaves the subscription login in use. The VS Code extension reads gateway variables from claudeCode.environmentVariables, and the desktop app reads them from its own third-party inference configuration rather than from ANTHROPIC_BASE_URL. And Anthropic does not support routing Claude Code to non-Claude models through any gateway, even where a gateway makes it technically possible.
What the gateway sees, what to log and what not to keep
The gateway sees everything the agent sends to the model: the system prompt, the conversation, source code and file contents the agent has read, command output and tool results. A secret in a file the agent opens can therefore pass through it. Claude Code also sends headers that help with attribution: x-claude-code-session-id groups the requests of one session, and x-claude-code-agent-id marks requests from subagents. Anthropic points out that the agent ID identifies an agent and says nothing about a person or a device.
For cost and operations, metadata is enough. A useful record per request holds:
- The gateway key and the team and developer it belongs to
- The model requested and the model that served it, including any fallback
- Input, output, cache read and cache write tokens, and the computed cost
- Status code, latency and time to first token
- Session and agent IDs from the request headers
Keep request and response bodies out of storage unless a written purpose requires them. LiteLLM's documentation says it does not track request and response content by default. store_prompts_in_spend_logs turns that on, and an admin can also change it in the UI, where it overrides the config file. maximum_spend_logs_retention_period deletes old spend logs, and turn_off_message_logging keeps messages away from external logging callbacks while spend is still tracked. Per-developer usage records are personal data, so agree their purpose and retention with your data protection owner and, if you have one, your works council before go-live.
Not every request goes through the gateway. While ANTHROPIC_BASE_URL points at it, Claude Code still sends telemetry to Anthropic, without your gateway credential, and the WebFetch domain safety check calls api.anthropic.com directly. CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 turns off the nonessential traffic, but it also disables auto-updates, so plan another update path.
Budgets and rate limits per team without slowing engineers
Put the hard limit on the team and keep per-developer limits generous. Agent sessions are bursty: one task can start several subagents in parallel, each sending a large prompt. A tight requests-per-minute limit on a key therefore stops real work long before it protects the budget. This is our own judgement from the shape of the traffic. In LiteLLM the controls are:
- Per team: max_budget with budget_duration for a regular reset, and team_member_budget as a default for each member
- Per key: max_budget, budget_duration, rpm_limit, tpm_limit and max_parallel_requests, with budget_limits for several windows on one key, such as a daily and a monthly cap
- Per model: model_max_budget, which the documentation marks as an Enterprise feature
Two operating details decide whether the limits hold. Budgets need a Postgres database to be enforced at all. With more than one worker or replica, LiteLLM highly recommends Redis: without it, rate limits are counted per worker, budgets can overshoot, and a revoked key stays usable on workers that did not process the revocation until their cache entry expires. Then decide what an engineer experiences at the limit. An unexplained error in the middle of a task costs more working time than the tokens it saves, so alert the team below the hard cap and publish who can raise a budget.
Common failure modes and how to recognise them
Most problems come from a gateway that changes the request or the response on the way through. Anthropic's gateway protocol reference and troubleshooting table describe these, among others:
| Symptom | Cause | Fix |
|---|---|---|
| Invalid model name error after picking a model in /model | The model ID Claude Code sends is not a model_name in the LiteLLM config | Add the exact IDs to model_list, pin ANTHROPIC_MODEL, or enable CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 |
| Sessions stall, or abort during long thinking pauses | The gateway buffers the stream or strips SSE ping events; by default Claude Code aborts a stream that is silent for 300 seconds | Relay the stream as it arrives and forward ping events |
| 400 errors naming tool schema fields or context_management, often with Extra inputs are not permitted | A beta header was stripped while its body field passed, or an Anthropic-format body was sent to a Bedrock upstream | Forward anthropic-beta and body fields unchanged, or set CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 |
| No error, but high input token counts and little cache activity | cache_control markers were dropped, or system content was flattened to a plain string | Forward cache_control wherever it appears and keep block-form content |
| 403 with an HTML body, and no request in the gateway's logs | A web application firewall's cross-site scripting body rules match the source code in prompts | Exempt the /v1/messages path from request-body inspection |
| Claude Code stops recovering from rejected features | The gateway wraps upstream errors in its own envelope, and the retry logic no longer recognises them | Forward upstream error bodies unmodified |
Check prompt caching separately, because a broken cache costs money without raising an error. Compare cache read tokens per session before and after the gateway goes in. On Claude Code versions before v2.1.181, an attribution block that changed on every request also defeated caches keyed on the request body. Anthropic's protocol reference describes CLAUDE_CODE_ATTRIBUTION_HEADER=0 for that case.
A short rollout checklist
Roll out in this order, and test each step with a real agent session rather than a single curl request:
- 1
Decide the scope
List which tools and surfaces must use the gateway. The Claude Code CLI, the VS Code extension and the desktop app can. Claude Code in Slack and cloud sessions cannot, and Copilot and Cursor only partly. Do not enable anything that must not bypass the gateway.
- 2
Deploy and harden the gateway
Pin the gateway version, run Postgres for budgets and Redis for more than one worker, and set log retention before the first request.
- 3
Define models and names
Publish the allow-list with the exact model IDs each tool sends, and map those IDs in the gateway.
- 4
Issue one credential per developer
Tie each key to a team, set team budgets and generous per-key limits, and test revocation against every replica.
- 5
Distribute configuration centrally
Ship the base URL, the credential mechanism and allowedProviders through Claude Code managed settings, and set the Copilot BYOK policies in GitHub's enterprise or organisation settings.
- 6
Run an acceptance session
Check streaming, tool calls, subagents, cache reads and a budget breach from a test team before inviting everyone, and have each developer confirm the gateway URL in /status.
- 7
Re-test on every upgrade
Claude Code changes what it sends with each release, so repeat the acceptance session before upgrading the gateway or allowing a new client version.
Cloudsail sets up and runs LiteLLM gateways for engineering teams and rolls out Claude Code against them, including managed settings, team budgets and the acceptance session described above.
LiteLLM gateway setup and operationLLM cost optimisationClaude Code permissions and rollout
Questions
Can Claude Code use GPT or open-weight models through LiteLLM?
A gateway can translate the requests, and LiteLLM documents how to do it. Anthropic states that it does not support routing Claude Code to non-Claude models through any gateway, so features can break between releases and you carry that risk yourself.
Does a gateway key still use our Claude subscription?
No. While a gateway credential or apiKeyHelper is active, requests carry that credential instead of the claude.ai login, the subscription's usage limits do not apply, and the traffic is billed per token to the owner of the upstream key. Setting only ANTHROPIC_BASE_URL leaves the subscription login in use.
Can the gateway stay on our internal network?
For Claude Code, yes: requests go from the developer's machine to the gateway, so a VPN or internal DNS name works. Cursor routes requests through its own servers, and GitHub handles enterprise BYOK server-side, so an endpoint for either would have to be reachable from the vendor's side. Confirm the network requirements with the vendor before you plan a private endpoint.
Does LiteLLM store our prompts and source code?
Not in its spend logs by default: the documentation says request and response content is not tracked unless store_prompts_in_spend_logs is enabled. External logging callbacks are a separate path, covered by turn_off_message_logging. Check both in every environment, because an admin can change the spend-log setting from the UI.
Related services
LiteLLM gateway
Budgets and access rules for every team's AI use, through a LiteLLM gateway that is hardened, connected to your identity provider and kept up to date.
LLM cost optimisation
Agent spend broken down by team and task, then lowered through defaults, budgets and routing your platform team can run.
Claude Code consulting and rollout
Claude Code fitted to your codebase, permissions and review process, starting with one pilot team.
More from the blog
LLM cost allocation
How to explain an LLM bill by team, task and accepted outcome: tag requests at the gateway, price them as you are invoiced, allocate shared costs by a stated rule and reconcile with finance every month.
Coding agent security
Practical security and governance for coding agents: prompt injection, secrets, permissions, sandboxing, unattended runs and ownership.
Agent secrets and credentials
Where credentials used by agents and model integrations should live, how to give each agent its own identity, how to rotate without breaking running workflows and what to do after a leak.
Coding agents compared for teams
Claude Code, Cursor, GitHub Copilot and OpenAI Codex side by side: plans, usage billing, models, instruction files, data handling and when each one fits.
Sources
- Claude Code documentation: Other LLM gateways
- Claude Code documentation: Connect Claude Code to an LLM gateway
- Claude Code documentation: Gateway protocol reference
- GitHub Docs: Bring your own key for GitHub Copilot
- GitHub Docs: Enable custom models for an enterprise
- GitHub Changelog, 15 January 2026: GitHub Copilot bring your own key (BYOK) enhancements
- GitHub Changelog, 22 April 2026: Bring your own language model key in VS Code now available
- Cursor Help: API keys
- LiteLLM documentation: Connecting Claude Code to LiteLLM
- LiteLLM documentation: Budgets and rate limits
- LiteLLM documentation: Redis requirements
- LiteLLM documentation: Getting started with UI logs
- LiteLLM documentation: Logging
Talk to an engineer
Bring one piece of work you would like to improve. The call takes 30 minutes and needs no access to your systems or your data.
Booking runs on Google Calendar.
Prefer to write first? Leave your email and a few lines, and we reply with times.
Look for the draft in your email program
Send it from there, and an engineer replies in person with times for a 30-minute call. If no draft has opened, write to us at miki@cloudsail.com.