Follow Discord
Sweep 06 Nov 2026 · 01:32Z Build v2.1.319 537 read Stable v2.1.311 Latest v2.1.318 Next v2.1.319 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · claude-code

Connect Claude Code to an LLM gateway changedllm-gateway-connect

Nearest release: v2.1.312, published an hour before upstream edited the page. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.

Upstream edited this page at 27 Oct 2026 19:58 UTC, give or take a minute or two: the time comes from Anthropic’s own sitemap rather than from a commit. This site recorded the change at 30 Oct 2026 18:07 UTC.

Upstream edited
Recorded here
Lines+151added
Lines−151removed
From line 69 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits34to this page, all time

The whole hunk

from line 69, old and new numbered
/
lines
from line 69
6969 
7070Replace the values with the ones your gateway team gave you:
7171 
72**Bash or Zsh**
72> [tab] Bash or Zsh
73>
74> ```bash theme={null}
75> export ANTHROPIC_BASE_URL=https://llm-gateway.example.com
76> export ANTHROPIC_AUTH_TOKEN=sk-gateway-key
77> ```
7378 
74```bash theme={null}
75export ANTHROPIC_BASE_URL=https://llm-gateway.example.com
76export ANTHROPIC_AUTH_TOKEN=sk-gateway-key
77```
79> [tab] PowerShell
80>
81> ```powershell theme={null}
82> $env:ANTHROPIC_BASE_URL = "https://llm-gateway.example.com"
83> $env:ANTHROPIC_AUTH_TOKEN = "sk-gateway-key"
84> ```
7885 
79**PowerShell**
80 
81```powershell theme={null}
82$env:ANTHROPIC_BASE_URL = "https://llm-gateway.example.com"
83$env:ANTHROPIC_AUTH_TOKEN = "sk-gateway-key"
84```
85 
8686Shell exports apply only to that terminal session and programs started from it. An editor launched from the dock or Start menu won't see them. To make the values persist across new terminals, add the same lines to your shell profile, such as `~/.zshrc`, `~/.bashrc`, or your PowerShell `$PROFILE`.
8787 
8888If you export the gateway only in your shell, it doesn't reliably reach background agents hosted by the [supervisor](https://code.claude.com/docs/en/agent-view.md#how-background-sessions-are-hosted); see [how each background session sources its gateway](https://code.claude.com/docs/en/agent-view.md#llm-gateway). Use a settings file for any gateway that background agents must always route through.
from line 115
115115 
116116With the variables exported in your shell, send a one-token request to the gateway directly. This confirms the URL and credential work before you open Claude Code, so a failure points at the gateway rather than your configuration. The commands below read the shell variables, so they need the [shell exports](#set-as-shell-environment-variables) even if you also put the values in a settings file.
117117 
118**Bash or Zsh**
118> [tab] Bash or Zsh
119>
120> ```bash theme={null}
121> curl -sS -w '\n%{http_code}\n' -X POST "$ANTHROPIC_BASE_URL/v1/messages" \
122> -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
123> -H "anthropic-version: 2023-06-01" \
124> -H "content-type: application/json" \
125> -d '{"model": "claude-sonnet-4-6", "max_tokens": 1, "messages": [{"role": "user", "content": "."}]}'
126> ```
119127 
120```bash theme={null}
121curl -sS -w '\n%{http_code}\n' -X POST "$ANTHROPIC_BASE_URL/v1/messages" \
122 -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
123 -H "anthropic-version: 2023-06-01" \
124 -H "content-type: application/json" \
125 -d '{"model": "claude-sonnet-4-6", "max_tokens": 1, "messages": [{"role": "user", "content": "."}]}'
126```
128> [tab] PowerShell
129>
130> ```powershell theme={null}
131> Invoke-RestMethod -Method Post -Uri "$env:ANTHROPIC_BASE_URL/v1/messages" `
132> -Headers @{ "Authorization" = "Bearer $env:ANTHROPIC_AUTH_TOKEN"; "anthropic-version" = "2023-06-01" } `
133> -ContentType "application/json" `
134> -Body '{"model": "claude-sonnet-4-6", "max_tokens": 1, "messages": [{"role": "user", "content": "."}]}'
135> ```
127136 
128**PowerShell**
129 
130```powershell theme={null}
131Invoke-RestMethod -Method Post -Uri "$env:ANTHROPIC_BASE_URL/v1/messages" `
132 -Headers @{ "Authorization" = "Bearer $env:ANTHROPIC_AUTH_TOKEN"; "anthropic-version" = "2023-06-01" } `
133 -ContentType "application/json" `
134 -Body '{"model": "claude-sonnet-4-6", "max_tokens": 1, "messages": [{"role": "user", "content": "."}]}'
135```
136 
137137If your gateway expects keys in the `x-api-key` header, replace the `Authorization` header with `x-api-key: $ANTHROPIC_API_KEY` in the Bash command, or the `"Authorization"` hashtable entry with `"x-api-key" = "$env:ANTHROPIC_API_KEY"` in the PowerShell command.
138138 
139139A JSON response that starts with `{"id":"msg_` and includes a `"content":[...]` field means the gateway is reachable and the credential works. An error naming an unknown model still proves the URL and credential work, since the gateway authenticated the request before rejecting the model name; you don't need to find a model your gateway serves for this test. A `401` means the credential was rejected: if you guessed the variable, switch to the other one and re-export.
from line 270
270270 
271271Some gateways route or tag requests using a custom header in addition to the credential, for example a tenant identifier or a routing key. To send one, set [`ANTHROPIC_CUSTOM_HEADERS`](https://code.claude.com/docs/en/env-vars) with one `Name: Value` pair per line. The example below adds a routing header named `X-Org-Route`:
272272 
273**Bash or Zsh**
273> [tab] Bash or Zsh
274>
275> ```bash theme={null}
276> export ANTHROPIC_CUSTOM_HEADERS="X-Org-Route: prod"
277> ```
274278 
275```bash theme={null}
276export ANTHROPIC_CUSTOM_HEADERS="X-Org-Route: prod"
277```
279> [tab] PowerShell
280>
281> ```powershell theme={null}
282> $env:ANTHROPIC_CUSTOM_HEADERS = "X-Org-Route: prod"
283> ```
278284 
279**PowerShell**
280 
281```powershell theme={null}
282$env:ANTHROPIC_CUSTOM_HEADERS = "X-Org-Route: prod"
283```
284 
285285You can also set `ANTHROPIC_CUSTOM_HEADERS` in the `env` block of a settings file. Use `\n` between pairs there, since JSON strings can't span multiple lines:
286286 
287287```json theme={null}
from line 314
314314 
315315The helper is any shell command that prints the current credential to stdout. Claude Code runs it through your system shell, so on Windows it can be an executable or a PowerShell invocation. Make the command print nothing but the credential. On Claude Code v2.1.227 or later, a banner or a log line printed alongside the key makes the [helper fail](https://code.claude.com/docs/en/errors.md#your-apikeyhelper-script-is-failing). Write the script, make it executable, and reference it from `apiKeyHelper` in your [settings file](https://code.claude.com/docs/en/settings.md):
316316 
317**Bash or Zsh**
317> [tab] Bash or Zsh
318>
319> For example, a script that reads from a vault:
320>
321> ```bash theme={null}
322> #!/bin/bash
323> vault kv get -field=api_key secret/llm-gateway/claude-code
324> ```
325>
326> Reference its path in `~/.claude/settings.json`:
327>
328> ```json theme={null}
329> {
330> "apiKeyHelper": "~/bin/get-gateway-key.sh"
331> }
332> ```
318333 
319For example, a script that reads from a vault:
334> [tab] PowerShell
335>
336> For example, a script that reads from a vault:
337>
338> ```powershell theme={null}
339> vault kv get -field=api_key secret/llm-gateway/claude-code
340> ```
341>
342> Reference the PowerShell invocation in `%USERPROFILE%\.claude\settings.json`, escaping the backslashes in the JSON string:
343>
344> ```json theme={null}
345> {
346> "apiKeyHelper": "powershell -NoProfile -File C:\\scripts\\get-gateway-key.ps1"
347> }
348> ```
320349 
321```bash theme={null}
322#!/bin/bash
323vault kv get -field=api_key secret/llm-gateway/claude-code
324```
325 
326Reference its path in `~/.claude/settings.json`:
327 
328```json theme={null}
329{
330 "apiKeyHelper": "~/bin/get-gateway-key.sh"
331}
332```
333 
334**PowerShell**
335 
336For example, a script that reads from a vault:
337 
338```powershell theme={null}
339vault kv get -field=api_key secret/llm-gateway/claude-code
340```
341 
342Reference the PowerShell invocation in `%USERPROFILE%\.claude\settings.json`, escaping the backslashes in the JSON string:
343 
344```json theme={null}
345{
346 "apiKeyHelper": "powershell -NoProfile -File C:\\scripts\\get-gateway-key.ps1"
347}
348```
349 
350350Claude Code caches the helper's output for five minutes by default and re-runs the helper after the cache lifetime elapses. To change the lifetime, set `CLAUDE_CODE_API_KEY_HELPER_TTL_MS` in milliseconds, for example `CLAUDE_CODE_API_KEY_HELPER_TTL_MS=900000` for 15 minutes.
351351 
352352See [`apiKeyHelper`](https://code.claude.com/docs/en/settings-reference#apikeyhelper) for the other cases in which Claude Code re-runs the helper.
from line 359
359359 
360360To turn that traffic off, set `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1` alongside the gateway variables, in the same shell exports or settings-file `env` block:
361361 
362**Bash or Zsh**
362> [tab] Bash or Zsh
363>
364> ```bash theme={null}
365> export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
366> ```
363367 
364```bash theme={null}
365export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
366```
368> [tab] PowerShell
369>
370> ```powershell theme={null}
371> $env:CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = "1"
372> ```
367373 
368**PowerShell**
369 
370```powershell theme={null}
371$env:CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = "1"
372```
373 
374374Setting the variable has these effects and limits:
375375 
376376* It disables auto-updates, so plan for another update path, such as your package manager or managed distribution.
from line 394
394394 
395395Leave `AWS_BEARER_TOKEN_BEDROCK` unset when the gateway issues its own credential. If you set it, Claude Code sends that [Amazon Bedrock API key](https://code.claude.com/docs/en/amazon-bedrock.md#2-configure-aws-credentials) as the `Authorization` header instead of your gateway token, even with `CLAUDE_CODE_SKIP_BEDROCK_AUTH` set.
396396 
397**Bash or Zsh**
397> [tab] Bash or Zsh
398>
399> ```bash theme={null}
400> export ANTHROPIC_BEDROCK_BASE_URL=https://llm-gateway.example.com/bedrock
401> export CLAUDE_CODE_SKIP_BEDROCK_AUTH=1
402> export CLAUDE_CODE_USE_BEDROCK=1
403> ```
398404 
399```bash theme={null}
400export ANTHROPIC_BEDROCK_BASE_URL=https://llm-gateway.example.com/bedrock
401export CLAUDE_CODE_SKIP_BEDROCK_AUTH=1
402export CLAUDE_CODE_USE_BEDROCK=1
403```
405> [tab] PowerShell
406>
407> ```powershell theme={null}
408> $env:ANTHROPIC_BEDROCK_BASE_URL = "https://llm-gateway.example.com/bedrock"
409> $env:CLAUDE_CODE_SKIP_BEDROCK_AUTH = "1"
410> $env:CLAUDE_CODE_USE_BEDROCK = "1"
411> ```
404412 
405**PowerShell**
406 
407```powershell theme={null}
408$env:ANTHROPIC_BEDROCK_BASE_URL = "https://llm-gateway.example.com/bedrock"
409$env:CLAUDE_CODE_SKIP_BEDROCK_AUTH = "1"
410$env:CLAUDE_CODE_USE_BEDROCK = "1"
411```
412 
413413#### Google Cloud's Agent Platform
414414 
415415Replace the project ID and region with your own values. Claude Code includes both in the path of each request it sends to the gateway:
416416 
417**Bash or Zsh**
417> [tab] Bash or Zsh
418>
419> ```bash theme={null}
420> export ANTHROPIC_VERTEX_BASE_URL=https://llm-gateway.example.com/vertex
421> export ANTHROPIC_VERTEX_PROJECT_ID=your-gcp-project-id
422> export CLAUDE_CODE_SKIP_VERTEX_AUTH=1
423> export CLAUDE_CODE_USE_VERTEX=1
424> export CLOUD_ML_REGION=us-east5
425> ```
418426 
419```bash theme={null}
420export ANTHROPIC_VERTEX_BASE_URL=https://llm-gateway.example.com/vertex
421export ANTHROPIC_VERTEX_PROJECT_ID=your-gcp-project-id
422export CLAUDE_CODE_SKIP_VERTEX_AUTH=1
423export CLAUDE_CODE_USE_VERTEX=1
424export CLOUD_ML_REGION=us-east5
425```
427> [tab] PowerShell
428>
429> ```powershell theme={null}
430> $env:ANTHROPIC_VERTEX_BASE_URL = "https://llm-gateway.example.com/vertex"
431> $env:ANTHROPIC_VERTEX_PROJECT_ID = "your-gcp-project-id"
432> $env:CLAUDE_CODE_SKIP_VERTEX_AUTH = "1"
433> $env:CLAUDE_CODE_USE_VERTEX = "1"
434> $env:CLOUD_ML_REGION = "us-east5"
435> ```
426436 
427**PowerShell**
428 
429```powershell theme={null}
430$env:ANTHROPIC_VERTEX_BASE_URL = "https://llm-gateway.example.com/vertex"
431$env:ANTHROPIC_VERTEX_PROJECT_ID = "your-gcp-project-id"
432$env:CLAUDE_CODE_SKIP_VERTEX_AUTH = "1"
433$env:CLAUDE_CODE_USE_VERTEX = "1"
434$env:CLOUD_ML_REGION = "us-east5"
435```
436 
437437The block covers routing and authentication. The region overrides and model pins from the [Agent Platform setup](https://code.claude.com/docs/en/google-vertex-ai.md#4-configure-claude-code) apply through a gateway as well:
438438 
439439* **Per-model regions**: if your gateway serves some models from a region other than `CLOUD_ML_REGION`, set the matching `VERTEX_REGION_CLAUDE_*` variable for each, for example `VERTEX_REGION_CLAUDE_4_6_SONNET=europe-west1`. The [environment variables reference](https://code.claude.com/docs/en/env-vars.md) lists the exact names.
from line 446
446446 
447447For a gateway that injects its own `Authorization` header, set `CLAUDE_CODE_SKIP_FOUNDRY_AUTH=1` and leave both credential variables unset. Claude Code then sends requests without an Azure credential and preserves the `Authorization` header you supply, for example through `ANTHROPIC_CUSTOM_HEADERS`.
448448 
449**Bash or Zsh**
449> [tab] Bash or Zsh
450>
451> ```bash theme={null}
452> export ANTHROPIC_FOUNDRY_BASE_URL=https://llm-gateway.example.com/foundry
453> export ANTHROPIC_FOUNDRY_API_KEY=sk-gateway-key
454> export CLAUDE_CODE_USE_FOUNDRY=1
455> ```
450456 
451```bash theme={null}
452export ANTHROPIC_FOUNDRY_BASE_URL=https://llm-gateway.example.com/foundry
453export ANTHROPIC_FOUNDRY_API_KEY=sk-gateway-key
454export CLAUDE_CODE_USE_FOUNDRY=1
455```
457> [tab] PowerShell
458>
459> ```powershell theme={null}
460> $env:ANTHROPIC_FOUNDRY_BASE_URL = "https://llm-gateway.example.com/foundry"
461> $env:ANTHROPIC_FOUNDRY_API_KEY = "sk-gateway-key"
462> $env:CLAUDE_CODE_USE_FOUNDRY = "1"
463> ```
456464 
457**PowerShell**
458 
459```powershell theme={null}
460$env:ANTHROPIC_FOUNDRY_BASE_URL = "https://llm-gateway.example.com/foundry"
461$env:ANTHROPIC_FOUNDRY_API_KEY = "sk-gateway-key"
462$env:CLAUDE_CODE_USE_FOUNDRY = "1"
463```
464 
465465#### Claude Platform on AWS
466466 
467467See [Claude Platform on AWS](https://code.claude.com/docs/en/claude-platform-on-aws.md) for the workspace ID.
468468 
469**Bash or Zsh**
469> [tab] Bash or Zsh
470>
471> ```bash theme={null}
472> export ANTHROPIC_AWS_BASE_URL=https://llm-gateway.example.com/anthropic-aws
473> export ANTHROPIC_AWS_WORKSPACE_ID=wrkspc_01ABCDEFGHIJKLMN
474> export CLAUDE_CODE_SKIP_ANTHROPIC_AWS_AUTH=1
475> export CLAUDE_CODE_USE_ANTHROPIC_AWS=1
476> ```
470477 
471```bash theme={null}
472export ANTHROPIC_AWS_BASE_URL=https://llm-gateway.example.com/anthropic-aws
473export ANTHROPIC_AWS_WORKSPACE_ID=wrkspc_01ABCDEFGHIJKLMN
474export CLAUDE_CODE_SKIP_ANTHROPIC_AWS_AUTH=1
475export CLAUDE_CODE_USE_ANTHROPIC_AWS=1
476```
477 
478**PowerShell**
479 
480```powershell theme={null}
481$env:ANTHROPIC_AWS_BASE_URL = "https://llm-gateway.example.com/anthropic-aws"
482$env:ANTHROPIC_AWS_WORKSPACE_ID = "wrkspc_01ABCDEFGHIJKLMN"
483$env:CLAUDE_CODE_SKIP_ANTHROPIC_AWS_AUTH = "1"
484$env:CLAUDE_CODE_USE_ANTHROPIC_AWS = "1"
485```
478> [tab] PowerShell
479>
480> ```powershell theme={null}
481> $env:ANTHROPIC_AWS_BASE_URL = "https://llm-gateway.example.com/anthropic-aws"
482> $env:ANTHROPIC_AWS_WORKSPACE_ID = "wrkspc_01ABCDEFGHIJKLMN"
483> $env:CLAUDE_CODE_SKIP_ANTHROPIC_AWS_AUTH = "1"
484> $env:CLAUDE_CODE_USE_ANTHROPIC_AWS = "1"
485> ```
486486 
487487#### Confirm the provider route
488488 
Feedback