modified Set up Claude Code for your organization View current →
--- a/admin-setup.md +++ b/admin-setup.md @@ -46,7 +46,7 @@ Windows: `C:\Program Files\ClaudeCode\managed-settings.json`| Medium| All Windows user registry| `HKCU\SOFTWARE\Policies\ClaudeCode`| Lowest| Windows only -Server-managed settings reach devices at authentication time and refresh hourly during active sessions, with no endpoint infrastructure. They require a Claude for Teams or Enterprise plan, so deployments on other providers need one of the file-based or OS-level mechanisms instead. If your organization mixes providers, configure [server-managed settings](</docs/en/server-managed-settings>) for Claude.ai users plus a [file-based or plist/registry fallback](</docs/en/settings#settings-files>) so other users still receive managed policy. The plist and HKLM registry locations work with any provider and resist tampering because they require admin privileges to write. The Windows user registry at HKCU is writable without elevation, so treat it as a convenience default rather than an enforcement channel. By default WSL reads only the Linux file path at `/etc/claude-code`. To extend your Windows registry and `C:\Program Files\ClaudeCode` policy to WSL on the same machine, set [`wslInheritsWindowsSettings: true`](</docs/en/settings#available-settings>) in either of those admin-only Windows sources. Whichever mechanism you choose, managed values take precedence over user and project settings. Array settings such as `permissions.allow` and `permissions.deny` merge entries from all sources, so developers can extend managed lists but not remove from them. See [Server-managed settings](</docs/en/server-managed-settings>) and [Settings files and precedence](</docs/en/settings#settings-files>). +Server-managed settings reach devices at authentication time and refresh hourly during active sessions, with no endpoint infrastructure. They require a Claude for Teams or Enterprise plan, so deployments on other providers need one of the file-based or OS-level mechanisms instead. If your organization mixes providers, configure [server-managed settings](</docs/en/server-managed-settings>) for Claude.ai users plus a [file-based or plist/registry fallback](</docs/en/settings#settings-files>) so other users still receive managed policy. The plist and HKLM registry locations work with any provider and resist tampering because they require admin privileges to write. The Windows user registry at HKCU is writable without elevation, so treat it as a convenience default rather than an enforcement channel. By default WSL reads only the Linux file path at `/etc/claude-code`. To extend your Windows registry and `C:\Program Files\ClaudeCode` policy to WSL on the same machine, set [`wslInheritsWindowsSettings: true`](</docs/en/settings#available-settings>) in either of those admin-only Windows sources. Whichever mechanism you choose, managed values take precedence over user and project settings. Array settings such as `permissions.allow` and `permissions.deny` merge entries from all sources, so developers can extend managed lists but not remove from them, with [two exceptions](</docs/en/settings#settings-precedence>) where the managed value replaces lower layers rather than merging: `fallbackModel` and `availableModels`. See [Server-managed settings](</docs/en/server-managed-settings>) and [Settings files and precedence](</docs/en/settings#settings-files>). ## @@ -67,6 +67,7 @@ [Customization lockdown](</docs/en/settings#strictpluginonlycustomization>)| Block skills, agents, hooks, and MCP servers from user and project sources, so they can only come from plugins or managed settings| `strictPluginOnlyCustomization` [Hook restrictions](</docs/en/settings#hook-configuration>)| Only managed hooks load; restrict HTTP hook URLs| `allowManagedHooksOnly`, `allowedHttpHookUrls` [Disable agent view](</docs/en/agent-view#how-background-sessions-are-hosted>)| Turn off `claude agents`, `--bg`, `/background`, and the on-demand supervisor| `disableAgentView` +[Model restrictions](</docs/en/model-config#restrict-model-selection>)| `availableModels` filters which models appear in the picker. Adding `enforceAvailableModels` also constrains the auto-selected default model. See [surface coverage](</docs/en/model-config#surface-coverage>) for how this setting reaches the CLI, web, and IDE| `availableModels`, `enforceAvailableModels` [Version floor](</docs/en/settings>)| Prevent auto-update from installing below an org-wide minimum| `minimumVersion` [Required version range](</docs/en/settings>)| Refuse to start at all when the running version is outside an org-approved range. Stronger than `minimumVersion`, which only blocks downgrades| `requiredMinimumVersion`, `requiredMaximumVersion`
modified Escalate hard decisions with the advisor tool View current →
--- a/advisor.md +++ b/advisor.md @@ -36,7 +36,7 @@ /advisor opus -Your selection is saved to `advisorModel` in your user settings and persists across sessions. If your current main model does not support the advisor, the selection is still saved and activates when you switch to a compatible main model with [`/model`](</docs/en/model-config#setting-your-model>). +Your selection is saved to `advisorModel` in your user settings and persists across sessions. If your organization’s [`availableModels`](</docs/en/model-config#restrict-model-selection>) allowlist excludes the saved advisor model, the advisor is not invoked until you pick an allowed model with `/advisor`. If your current main model does not support the advisor, the selection is still saved and activates when you switch to a compatible main model with [`/model`](</docs/en/model-config#setting-your-model>). ### @@ -60,7 +60,7 @@ claude --advisor opus -The flag takes precedence over the `advisorModel` setting for that session. Unlike `/advisor`, which saves an inactive selection, the flag exits with an error if the session’s main model does not support the advisor. +The flag takes precedence over the `advisorModel` setting for that session. It exits with an error if the session’s main model does not support the advisor, or if the requested advisor model is excluded by your organization’s [`availableModels`](</docs/en/model-config#restrict-model-selection>) allowlist. ## @@ -166,7 +166,7 @@ Approach| When the stronger model runs| How it starts ---|---|--- Advisor tool| At decision points mid-task| Claude calls it when it needs guidance -[`opusplan`](</docs/en/model-config#opusplan-model-setting>)| During plan mode, then switches to Sonnet for execution| You enter plan mode +[`opusplan`](</docs/en/model-config#opusplan-model-setting>)| During plan mode when [allowed by `availableModels`](</docs/en/model-config#restrict-model-selection>), then switches to Sonnet for execution| You enter plan mode [Subagents](</docs/en/sub-agents#choose-a-model>) with `model` set| For the entire delegated subtask| Claude delegates, or you invoke the subagent [`/model`](</docs/en/model-config#setting-your-model>)| For all subsequent turns| You switch models
modified Claude Code on Amazon Bedrock View current →
--- a/amazon-bedrock.md +++ b/amazon-bedrock.md @@ -355,10 +355,10 @@ export CLAUDE_CODE_USE_BEDROCK=1 export CLAUDE_CODE_USE_MANTLE=1 -To surface a Mantle model in the `/model` picker, list its ID in `availableModels` in your [settings file](</docs/en/settings>). This setting also restricts the picker to the listed entries, so include every alias you want to keep available: - - { - "availableModels": ["opus", "sonnet", "haiku", "anthropic.claude-haiku-4-5"] +To surface a Mantle model in the `/model` picker, list its ID in `availableModels` in your [settings file](</docs/en/settings>). This setting also restricts the picker to the listed entries. Listing `anthropic.claude-haiku-4-5` removes the bare `haiku` alias from the picker, so also list version prefixes or full IDs for the versions you want to keep selectable. The Mantle ID and the `haiku` alias resolve to the same model family, so the merge keeps only the more specific entry. See [Merge behavior](</docs/en/model-config#merge-behavior>): + + { + "availableModels": ["opus", "sonnet", "claude-haiku-4-5", "anthropic.claude-haiku-4-5"] } Entries with the `anthropic.` prefix are added as custom picker options and routed to Mantle. Replace `anthropic.claude-haiku-4-5` with the model ID your account has been granted. See [Restrict model selection](</docs/en/model-config#restrict-model-selection>) for how `availableModels` interacts with other model settings. When both providers are active, `/status` shows `Amazon Bedrock + Amazon Bedrock (Mantle)`.
modified Authentication View current →
--- a/authentication.md +++ b/authentication.md @@ -146,7 +146,7 @@ * **Refresh intervals** : by default, `apiKeyHelper` is called after 5 minutes or on HTTP 401 response. Set `CLAUDE_CODE_API_KEY_HELPER_TTL_MS` environment variable for custom refresh intervals. * **Slow helper notice** : if `apiKeyHelper` takes longer than 10 seconds to return a key, Claude Code displays a warning notice in the prompt bar showing the elapsed time. If you see this notice regularly, check whether your credential script can be optimized. -`apiKeyHelper`, `ANTHROPIC_API_KEY`, and `ANTHROPIC_AUTH_TOKEN` apply to terminal CLI sessions only. Claude Desktop and cloud sessions use OAuth exclusively and do not call `apiKeyHelper` or read API key environment variables. +`apiKeyHelper`, `ANTHROPIC_API_KEY`, and `ANTHROPIC_AUTH_TOKEN` apply to the CLI and the surfaces that wrap it, including the VS Code extension, the Agent SDK, and GitHub Actions. Claude Desktop and cloud sessions do not call `apiKeyHelper` or read these environment variables: they use OAuth, except desktop sessions running an [organization-distributed third-party inference configuration](</docs/en/llm-gateway-connect#desktop-app>), which authenticate with that configuration’s credential. ###
modified Claude Code changelog View current →
--- a/changelog.md +++ b/changelog.md @@ -1,4 +1,39 @@ This page is generated from the [CHANGELOG.md on GitHub](<https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md>). Run `claude --version` to check your installed version. + +​ + +2.1.191 + +June 24, 2026 + + * Added `/rewind` support for resuming a conversation from before `/clear` was run + * Fixed scroll position jumping to the bottom while reading earlier output during a streaming response + * Fixed background agents resurrecting after being stopped — stopping an agent from the tasks panel is now permanent + * Fixed `/voice` showing a generic “not available” message when disabled by an organization’s policy — it now explains the restriction + * Fixed `/login` URL opening truncated in Windows Terminal when it wraps across lines + * Fixed Cmd+click on links in fullscreen mode for Ghostty over ssh/tmux + * Fixed `claude agents` sending builtin slash commands like `/usage` to background sessions as prompt text instead of showing a hint + * Fixed `claude agents` job rows showing full filesystem paths for pasted images instead of the `[Image #N]` placeholder + * Fixed hooks with comma-separated matchers (e.g. `"Bash,PowerShell"`) silently never firing + * Fixed `/permissions` Recently-denied tab: approving a denial now persists on close instead of being silently discarded + * Fixed the agent panel jumping by one row when scrolling the roster past the overflow cap + * Fixed the welcome splash art overflowing the default 80×24 macOS Terminal window + * Fixed managed settings: `forceRemoteSettingsRefresh` now takes effect when set via MDM or file policy, and the fetch sends `Cache-Control: no-cache` to prevent proxies from serving stale responses + * Improved sandbox network permission dialog: hosts you allow with “Yes” are now remembered for the rest of the session instead of re-prompting on every connection + * Improved MCP server reliability: capability discovery (`tools/list`, `prompts/list`, `resources/list`) now retries transient network errors with short backoff + * Improved MCP OAuth: discovery and token requests now retry once after transient network errors, and headless environments skip the browser popup and go straight to the paste-the-URL prompt + * Improved MCP error messages: HTTP 404 errors now show the URL and point to your MCP config + * Improved vim mode prompt-history search (NORMAL `/`) to hint how to reach slash commands + * Reduced CPU usage during streaming responses by ~37% by coalescing text updates to 100ms + * Reduced long-session memory growth from terminal output cache + +​ + +2.1.190 + +June 24, 2026 + + * Bug fixes and reliability improvements ​
modified Checkpointing View current →
--- a/checkpointing.md +++ b/checkpointing.md @@ -40,6 +40,14 @@ * **Never mind** : return to the message list without making changes After restoring the conversation or choosing Summarize from here, the original prompt from the selected message is restored into the input field so you can re-send or edit it. Choosing Summarize up to here leaves you at the end of the conversation with the input empty. + +#### + +​ + +Rewind past a cleared conversation + +If you ran `/clear` earlier in the same Claude Code process, the rewind menu shows an additional entry at the top of the list labeled `/resume <session-id> (previous session)`. Select it to resume the conversation that was active before `/clear` ran. The entry is available until you exit Claude Code or resume a different session, and requires Claude Code v2.1.191 or later. On earlier versions, run `/resume` and pick the previous session from the list instead. ####
modified Use Claude Code features in the SDK View current →
--- a/claude-code-features.md +++ b/claude-code-features.md @@ -51,12 +51,12 @@ Input| Behavior| To disable ---|---|--- -Managed policy settings| Always loaded when present on the host| Remove the managed settings file +Managed policy settings| Endpoint-managed policy, such as an MDM plist, registry policy, or managed settings file, loads from the host. [Server-managed settings](</docs/en/server-managed-settings>) are fetched on an [eligible configuration](</docs/en/server-managed-settings#platform-availability>) when the session authenticates with an organization OAuth login or a directly configured API key| Endpoint policy: remove the managed settings file, plist, or registry policy from the host. Server-managed settings: controlled by your org admin; cannot be disabled from the SDK `~/.claude.json` global config| Always read| Relocate with `CLAUDE_CONFIG_DIR` in `env` Auto memory at `~/.claude/projects/<project>/memory/`| Loaded by default into the system prompt| Set `autoMemoryEnabled: false` in settings, or `CLAUDE_CODE_DISABLE_AUTO_MEMORY=1` in `env` [claude.ai MCP connectors](</docs/en/mcp#use-mcp-servers-from-claude-ai>)| Loaded when the active authentication method is a claude.ai subscription. Passing `mcpServers: {}` does not suppress them| Set `strictMcpConfig: true`, [`disableClaudeAiConnectors: true`](</docs/en/mcp#disable-claude-ai-connectors>) in settings, or `ENABLE_CLAUDEAI_MCP_SERVERS=false` in `env` -Do not rely on default `query()` options for multi-tenant isolation. Because the inputs above are read regardless of `settingSources`, an SDK process can pick up host-level configuration and per-directory memory. For multi-tenant deployments, run each tenant in its own filesystem and set `settingSources: []` plus `CLAUDE_CODE_DISABLE_AUTO_MEMORY=1` in `env`. See [Secure deployment](</docs/en/agent-sdk/secure-deployment>). +Do not rely on default `query()` options for multi-tenant isolation. Because the inputs above are read regardless of `settingSources`, an SDK process can pick up host-level configuration and per-directory memory. For multi-tenant deployments, run each tenant in its own filesystem and set `settingSources: []` plus `CLAUDE_CODE_DISABLE_AUTO_MEMORY=1` in `env`. [Server-managed settings](</docs/en/server-managed-settings>) are fetched when the process authenticates with an organization credential; filesystem isolation does not remove them. See [Secure deployment](</docs/en/agent-sdk/secure-deployment>). ##
modified Use Claude Code on the web View current →
--- a/claude-code-on-the-web.md +++ b/claude-code-on-the-web.md @@ -49,7 +49,7 @@ What’s available in cloud sessions -Cloud sessions start from a fresh clone of your repository. Anything committed to the repo is available. Anything you’ve installed or configured only on your own machine is not. +Cloud sessions start from a fresh clone of your repository. Anything committed to the repo is available. Anything you’ve installed or configured only on your own machine is not; your organization’s policy arrives separately through [server-managed settings](</docs/en/server-managed-settings>). | Available in cloud sessions| Why ---|---|--- @@ -59,6 +59,7 @@ Your repo’s `.claude/rules/`| Yes| Part of the clone Your repo’s `.claude/skills/`, `.claude/agents/`, `.claude/commands/`| Yes| Part of the clone Plugins declared in `.claude/settings.json`| Yes| Installed at session start from the [marketplace](</docs/en/plugin-marketplaces>) you declared. Requires network access to reach the marketplace source +Your organization’s [server-managed settings](</docs/en/server-managed-settings>)| Yes| Fetched from Anthropic’s servers when the session starts. See [Surface coverage](</docs/en/model-config#surface-coverage>) for how `availableModels` is enforced in cloud sessions. Settings deployed to your device through MDM or managed settings files do not apply, because the session runs on an Anthropic-managed VM Your user `~/.claude/CLAUDE.md`| No| Lives on your machine, not in the repo Your user `~/.claude/skills/`, `~/.claude/agents/`, `~/.claude/commands/`| No| Live on your machine, not in the repo. Commit them to the repo’s `.claude/` directory instead. Skills you enable on claude.ai are loaded into cloud sessions automatically Plugins enabled only in your user settings| No| User-scoped `enabledPlugins` lives in `~/.claude/settings.json`. Declare them in the repo’s `.claude/settings.json` instead @@ -66,7 +67,7 @@ Static API tokens and credentials| No| No dedicated secrets store exists yet. See below Interactive auth like AWS SSO| No| Not supported. SSO requires browser-based login that can’t run in a cloud session -To make configuration available in cloud sessions, commit it to the repo. A dedicated secrets store is not yet available. Both environment variables and setup scripts are stored in the environment configuration, visible to anyone who can edit that environment. If you need secrets in a cloud session, add them as environment variables with that visibility in mind. +To make your own configuration available in cloud sessions, commit it to the repo; organization policy arrives separately through [server-managed settings](</docs/en/server-managed-settings>). A dedicated secrets store is not yet available. Both environment variables and setup scripts are stored in the environment configuration, visible to anyone who can edit that environment. If you need secrets in a cloud session, add them as environment variables with that visibility in mind. ### @@ -209,7 +210,7 @@ Runs| Before Claude Code launches, when no cached environment is available| After Claude Code launches, on every session including resumed Scope| Cloud environments only| Both local and cloud -SessionStart hooks can also be defined in your user-level `~/.claude/settings.json` locally, but user-level settings don’t carry over to cloud sessions. In the cloud, only hooks committed to the repo run. +SessionStart hooks can also be defined in your user-level `~/.claude/settings.json` locally, but user-level settings don’t carry over to cloud sessions. In the cloud, hooks come from the repo and from your organization’s [server-managed settings](</docs/en/server-managed-settings>). ###
modified Commands View current →
--- a/commands.md +++ b/commands.md @@ -64,7 +64,7 @@ `/ide`| Manage IDE integrations and show status `/init`| Initialize project with a `CLAUDE.md` guide. Set `CLAUDE_CODE_NEW_INIT=1` for an interactive flow that also walks through skills, hooks, and personal memory files `/insights`| Generate a report analyzing your Claude Code sessions, including project areas, interaction patterns, and friction points -`/install-github-app`| Set up the [Claude GitHub Actions](</docs/en/github-actions>) app for a repository. Walks you through selecting a repo and configuring the integration +`/install-github-app`| Install the Claude GitHub App for a repository, with an optional step to set up [GitHub Actions](</docs/en/github-actions>) workflows and secrets. Walks you through selecting a repo and configuring the integration `/install-slack-app`| Install the Claude Slack app. Opens a browser to complete the OAuth flow `/keybindings`| Open your [keyboard shortcuts](</docs/en/keybindings>) file `/login`| Sign in to your Anthropic account
modified Manage costs effectively View current →
--- a/costs.md +++ b/costs.md @@ -33,7 +33,7 @@ When you first authenticate Claude Code with your Claude Console account, a workspace called “Claude Code” is automatically created for you. This workspace provides centralized cost tracking and management for all Claude Code usage in your organization. You cannot create API keys for this workspace; it is exclusively for Claude Code authentication and usage.For organizations with custom rate limits, Claude Code traffic in this workspace counts toward your organization’s overall API rate limits. You can set a [workspace rate limit](<https://platform.claude.com/docs/en/api/rate-limits#setting-lower-limits-for-workspaces>) on this workspace’s Limits page in the Claude Console to cap Claude Code’s share and protect other production workloads. -On Bedrock, Vertex, and Foundry, Claude Code does not send metrics from your cloud. To get cost metrics, several large enterprises reported using [LiteLLM](</docs/en/llm-gateway#litellm-configuration>), which is an open-source tool that helps companies [track spend by key](<https://docs.litellm.ai/docs/proxy/virtual_keys#tracking-spend>). This project is unaffiliated with Anthropic and has not been audited for security. +On Bedrock, Vertex, and Foundry, Claude Code does not send metrics from your cloud. Organizations that already route Claude Code through an [LLM gateway](</docs/en/llm-gateway>) can track spend there, since the gateway sees every request. ###
modified Desktop application View current →
--- a/desktop.md +++ b/desktop.md @@ -653,7 +653,7 @@ Managed settings -Managed settings override project and user settings and apply when Desktop spawns CLI sessions. You can set these keys in your organization’s [managed settings](</docs/en/settings#settings-precedence>) file or push them remotely through the admin console. +Managed settings override project and user settings and apply to Claude Code sessions in Desktop. You can set these keys in your organization’s [managed settings](</docs/en/settings#settings-precedence>) file or push them remotely through the admin console. Key| Description ---|--- @@ -662,9 +662,15 @@ `autoMode`| customize what the auto mode classifier trusts and blocks across your organization. See [Configure auto mode](</docs/en/auto-mode-config>). `sshConfigs`| pre-configure SSH connections that appear in the environment dropdown. Users cannot edit or delete managed connections. `sshHostAllowlist`| restrict SSH sessions to hosts whose resolved hostname matches one of these patterns. An empty array disables SSH sessions. Read from managed settings only. -`managedMcpServers`| push MCP server configurations to all users in a third-party deployment. Each entry specifies a transport of `"http"`, `"sse"`, or `"stdio"`, connection details, and optionally a `toolPolicy` map that restricts which tools in that server users can invoke. Available in third-party (3P) Desktop deployments only. - -A managed settings file deployed to disk on each machine applies to Desktop sessions. Managed settings pushed remotely through the admin console currently reach CLI and IDE sessions only, so for Desktop deployments either distribute the file via MDM or use the admin console controls above. `permissions.disableBypassPermissionsMode` and `disableAutoMode` also work in user and project settings, but placing them in managed settings prevents users from overriding them. `autoMode` is read from user settings, `.claude/settings.local.json`, and managed settings, but not from the checked-in `.claude/settings.json`: a cloned repo cannot inject its own classifier rules. For the complete list of managed-only settings including `allowManagedPermissionRulesOnly` and `allowManagedHooksOnly`, see [managed-only settings](</docs/en/permissions#managed-only-settings>). +`managedMcpServers`| push MCP server configurations to all users in a third-party deployment. Each entry specifies a transport of `"http"`, `"sse"`, or `"stdio"`, connection details, and optionally a `toolPolicy` map that restricts which tools in that server users can invoke. Available in third-party (3P) Desktop deployments only. Deliver this key through the managed settings file or MDM, since third-party deployments do not receive admin-console settings. + +Which managed settings reach a Desktop session depends on where that session runs. Model restrictions such as [`availableModels`](</docs/en/model-config#restrict-model-selection>) are enforced in Desktop’s Claude Code sessions the same way as in the terminal CLI; see [surface coverage](</docs/en/model-config#surface-coverage>). + + * **Local sessions on this machine** : a managed settings file deployed to disk applies. Managed settings pushed remotely through the admin console also reach these sessions on Anthropic’s API when the session authenticates with an organization login or a directly configured API key, following the same [settings precedence](</docs/en/settings#settings-precedence>) as the terminal CLI. + * **Cloud sessions** : run on Anthropic-managed VMs and receive [server-managed settings](</docs/en/server-managed-settings>) only. + * **SSH sessions** : the session reads the managed settings file from the remote host. Desktop itself reads `sshConfigs` and `sshHostAllowlist` from the local machine’s managed settings when creating the connection. + +`permissions.disableBypassPermissionsMode` and `disableAutoMode` also work in user and project settings, but placing them in managed settings prevents users from overriding them. `autoMode` is read from user settings, `.claude/settings.local.json`, and managed settings, but not from the checked-in `.claude/settings.json`: a cloned repo cannot inject its own classifier rules. For the complete list of managed-only settings including `allowManagedPermissionRulesOnly` and `allowManagedHooksOnly`, see [managed-only settings](</docs/en/permissions#managed-only-settings>). ###
modified Discover and install prebuilt plugins through marketplaces View current →
--- a/discover-plugins.md +++ b/discover-plugins.md @@ -306,7 +306,7 @@ * type to filter by plugin name or description * press Enter to open a plugin’s detail view and enable, disable, or uninstall it -The detail view shows the components the plugin contributes: commands, skills, agents, hooks, MCP servers, and LSP servers. The same inventory is available from the command line with `claude plugin details`. When you install a plugin that declares dependencies, the install output lists which dependencies were auto-installed alongside it. You can also manage plugins with direct commands. List installed plugins without opening the menu: +The detail view shows the components the plugin contributes: commands, skills, agents, hooks, MCP servers, and LSP servers. The same inventory is available from the command line with `claude plugin details`. In Claude Code v2.1.187 and later, the Installed tab adds a **Not used recently** group for marketplace plugins you installed yourself but haven’t invoked in at least two weeks, over a span of at least 10 sessions, and the detail view shows a **Last used** line for each plugin. Use these to find plugins that you no longer use but that are still adding startup and context cost, then disable or uninstall them. Plugins that your organization manages or that you load with `--plugin-dir` are never listed as unused, and plugins that contribute an LSP server, theme, output style, monitor, or workflow are also never listed, since those deliver value without an invocation to track. The group and the **Last used** line are both hidden when your organization restricts marketplaces with [`strictKnownMarketplaces`](</docs/en/settings#strictknownmarketplaces>). When you install a plugin that declares dependencies, the install output lists which dependencies were auto-installed alongside it. You can also manage plugins with direct commands. List installed plugins without opening the menu: /plugin list
modified Environment variables View current →
--- a/env-vars.md +++ b/env-vars.md @@ -191,7 +191,7 @@ `CLAUDE_CODE_ENABLE_BACKGROUND_PLUGIN_REFRESH`| Set to `1` to refresh plugin state at turn boundaries in [non-interactive mode](</docs/en/headless>) after a background install completes. Off by default because the refresh changes the system prompt mid-session, which invalidates [prompt caching](</docs/en/prompt-caching>) for that turn `CLAUDE_CODE_ENABLE_FEEDBACK_SURVEY_FOR_OTEL`| Set to `1` to route the “How is Claude doing?” session quality survey to your own [OpenTelemetry collector](</docs/en/monitoring-usage>) when Anthropic-bound nonessential traffic is blocked. Survey ratings are emitted only as OTEL events to your configured collector. No survey data is sent to Anthropic in this mode. Applies when `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`, `DISABLE_TELEMETRY`, or `DO_NOT_TRACK` is set, and has no effect otherwise. `CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY` and the organization product feedback policy take precedence `CLAUDE_CODE_ENABLE_FINE_GRAINED_TOOL_STREAMING`| Controls whether tool call inputs stream from the API as Claude generates them. With this off, a large tool input such as a long file write arrives only after Claude finishes generating it, which can look like it’s hanging. Enabled by default on the Anthropic API. On Bedrock and Vertex, enabled per model where the deployed container supports it. Set to `0` to opt out. Set to `1` to force on when routing through a proxy via `ANTHROPIC_BASE_URL`, `ANTHROPIC_VERTEX_BASE_URL`, or `ANTHROPIC_BEDROCK_BASE_URL`. Off by default on Foundry and [gateway](</docs/en/llm-gateway>) connections -`CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY`| Set to `1` to populate the `/model` picker from your gateway’s `/v1/models` endpoint when `ANTHROPIC_BASE_URL` points at an Anthropic-compatible gateway such as LiteLLM, Kong, or an internal proxy. Off by default because gateways backed by a shared API key would otherwise show every user every model the key can access. Discovered models are still filtered by the [`availableModels`](</docs/en/settings#available-settings>) allowlist +`CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY`| Set to `1` to populate the `/model` picker from your gateway’s `/v1/models` endpoint when `ANTHROPIC_BASE_URL` points at an Anthropic-compatible gateway such as LiteLLM, Kong, or an internal proxy. Off by default because gateways backed by a shared API key would otherwise show every user every model the key can access. Discovered models are still filtered by an [`availableModels`](</docs/en/settings#available-settings>) allowlist the session receives; deliver the list through [MDM or a managed settings file](</docs/en/settings#settings-files>), since [server-managed delivery is not available on gateway configurations](</docs/en/server-managed-settings#platform-availability>) `CLAUDE_CODE_ENABLE_OPUS_4_7_FAST_MODE`| Removed in v2.1.142, when the [fast mode](</docs/en/fast-mode>) default moved from Opus 4.6 to Opus 4.7 `CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION`| Set to `false` to disable prompt suggestions (the “Prompt suggestions” toggle in `/config`). These are the grayed-out predictions that appear in your prompt input after Claude responds. See [Prompt suggestions](</docs/en/interactive-mode#prompt-suggestions>) `CLAUDE_CODE_ENABLE_TASKS`| Controls whether sessions use the structured Task tools (`TaskCreate`, `TaskUpdate`, `TaskGet`, `TaskList`) or the legacy `TodoWrite` tool. As of Claude Code v2.1.142, Task tools are the default in all modes. Set to `0` to revert to `TodoWrite`. See [Task list](</docs/en/interactive-mode#task-list>) and [Migrate to Task tools](</docs/en/agent-sdk/todo-tracking#migrate-to-task-tools>) @@ -218,6 +218,7 @@ `CLAUDE_CODE_MAX_TOOL_USE_CONCURRENCY`| Maximum number of read-only tools and subagents that can execute in parallel (default: 10). Higher values increase parallelism but consume more resources `CLAUDE_CODE_MAX_TURNS`| Cap the number of agentic turns when no explicit limit is passed. Equivalent to passing [`--max-turns`](</docs/en/cli-reference#cli-flags>), which takes precedence when both are set. A value that is not a positive integer is rejected at startup with an error rather than treated as no cap `CLAUDE_CODE_MCP_ALLOWLIST_ENV`| Set to `1` to spawn stdio MCP servers with only a safe baseline environment plus the server’s configured `env`, instead of inheriting your shell environment +`CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT`| Idle timeout in milliseconds for remote MCP tool calls (default: 300000, or 5 minutes). When an HTTP, SSE, WebSocket, or [claude.ai connector](</docs/en/mcp#use-mcp-servers-from-claude-ai>) MCP server sends no response and no progress notification for this long, the tool call aborts with an error instead of waiting for the overall `MCP_TOOL_TIMEOUT`. Set to `0` to disable the idle check. Values below 1000 are raised to one second, and the value is capped at the effective `MCP_TOOL_TIMEOUT`. Does not apply to stdio or IDE servers. Requires Claude Code v2.1.187 or later `CLAUDE_CODE_NATIVE_CURSOR`| Set to `1` to show the terminal’s own cursor at the input caret instead of a drawn block. The cursor respects the terminal’s blink, shape, and focus settings `CLAUDE_CODE_NEW_INIT`| Set to `1` to make `/init` run an interactive setup flow. The flow asks which files to generate, including CLAUDE.md, skills, and hooks, before exploring the codebase and writing them. Without this variable, `/init` generates a CLAUDE.md automatically without prompting. `CLAUDE_CODE_NO_FLICKER`| Set to `1` to enable [fullscreen rendering](</docs/en/fullscreen>), a research preview that reduces flicker and keeps memory flat in long conversations. Equivalent to the [`tui`](</docs/en/settings#available-settings>) setting; you can also switch with `/tui fullscreen` @@ -257,7 +258,7 @@ `CLAUDE_CODE_SIMPLE_SYSTEM_PROMPT`| Set to `1` to use a shorter system prompt and abbreviated tool descriptions on any model. Set to `0`, `false`, `no`, or `off` to opt out even on models where the experiment or server configuration would otherwise enable it. The full tool set, hooks, MCP servers, and CLAUDE.md discovery remain enabled `CLAUDE_CODE_SKIP_ANTHROPIC_AWS_AUTH`| Skip client-side authentication for [Claude Platform on AWS](</docs/en/claude-platform-on-aws>), for gateways that sign requests themselves `CLAUDE_CODE_SKIP_BEDROCK_AUTH`| Skip AWS authentication for Bedrock (for example, when using an LLM gateway) -`CLAUDE_CODE_SKIP_FOUNDRY_AUTH`| Skip Azure authentication for Microsoft Foundry (for example, when using an LLM gateway) +`CLAUDE_CODE_SKIP_FOUNDRY_AUTH`| Skip Azure authentication for Microsoft Foundry. For a gateway, set the credential in `ANTHROPIC_FOUNDRY_API_KEY` instead; without an API key this variable leaves the Foundry client unable to send requests `CLAUDE_CODE_SKIP_MANTLE_AUTH`| Skip AWS authentication for Bedrock Mantle (for example, when using an LLM gateway) `CLAUDE_CODE_SKIP_PROMPT_HISTORY`| Set to `1` to skip writing prompt history and session transcripts to disk. Sessions started with this variable set do not appear in `--resume`, `--continue`, or up-arrow history. Useful for ephemeral scripted sessions `CLAUDE_CODE_SKIP_VERTEX_AUTH`| Skip Google authentication for Vertex (for example, when using an LLM gateway)
modified Error reference View current →
--- a/errors.md +++ b/errors.md @@ -45,6 +45,7 @@ `Extra inputs are not permitted`| Request errors `There's an issue with the selected model`| Request errors `Claude Opus is not available with the Claude Pro plan`| Request errors +`Model ... is restricted by your organization's settings`| Request errors `thinking.type.enabled is not supported for this model`| Request errors `max_tokens must be greater than thinking.budget_tokens`| Request errors `API Error: 400 due to tool use concurrency issues`| Request errors @@ -146,6 +147,16 @@ * Retry the action; this usually succeeds on the next attempt * Run `claude --debug` and repeat the action to see the underlying classifier response in the debug log + +When a separate API safety check blocked the classifier request because of earlier conversation content: + + Auto mode could not evaluate this action and is blocking it for safety — a safety check separate from auto mode blocked this request because of earlier conversation content — it isn't about the action itself — run with --debug for details + +**What to do:** + + * This is not a decision about your action. A safety filter on the API was triggered by existing content in your conversation when auto mode sent the conversation to the classifier + * Retrying will not help; the same conversation content will trigger the filter again + * Switch to a different [permission mode](</docs/en/permission-modes>) so you can approve the action when prompted, or start a fresh conversation without the triggering content When the conversation has grown larger than the classifier’s context window: @@ -441,7 +452,7 @@ * Confirm you can reach the API host from the same shell by running `curl -I https://api.anthropic.com`. On Windows PowerShell use `curl.exe -I https://api.anthropic.com` so the built-in `Invoke-WebRequest` alias is not used. * If you are behind a corporate proxy, set `HTTPS_PROXY` before launching Claude Code and see [Network configuration](</docs/en/network-config>) - * If you route through an LLM gateway or relay, set [`ANTHROPIC_BASE_URL`](</docs/en/env-vars>) to its address. See [LLM gateway configuration](</docs/en/llm-gateway>) for setup. + * If you route through an LLM gateway or relay, set [`ANTHROPIC_BASE_URL`](</docs/en/env-vars>) to its address. See [Connect Claude Code to an LLM gateway](</docs/en/llm-gateway-connect>) for setup. * Ensure your firewall allows the hosts listed in [Network access requirements](</docs/en/network-config#network-access-requirements>) * Intermittent failures are retried automatically; persistent failures point to a local network issue @@ -612,7 +623,7 @@ Claude Code sends beta-only fields such as `context_management`, `effort`, and tool `input_examples` alongside an `anthropic-beta` header that enables them. When a gateway forwards the body but drops the header, the API sees fields it does not recognize. **What to do:** - * Configure your gateway to forward the `anthropic-beta` header. See [LLM gateway configuration](</docs/en/llm-gateway>). + * Configure your gateway to forward the `anthropic-beta` header. See [feature pass-through](</docs/en/llm-gateway-protocol#feature-pass-through>) for what gateways must forward. * As a fallback, set [`CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1`](</docs/en/env-vars>) before launching. This disables features that require the beta header so requests succeed through a gateway that cannot forward it. ### @@ -654,6 +665,22 @@ ​ +Model is restricted by your organization’s settings + +Your organization admin has disabled this model in the Claude Console, or it is excluded by an [`availableModels`](</docs/en/model-config#restrict-model-selection>) allowlist in managed settings. When the restricted model was set with `--model`, `ANTHROPIC_MODEL`, or the `model` setting, Claude Code substitutes an allowed model and continues. Typing `/model <name>` for a restricted model is rejected with `Run /model to choose a different model.` and the session keeps its current model. + + Model "claude-opus-4-8" is restricted by your organization's settings. Using claude-sonnet-4-6 instead. + +**What to do:** + + * Run `/model` to pick from the models your organization allows. Restricted models are hidden from the picker. + * If the restricted model was set in `--model`, `ANTHROPIC_MODEL`, or the `model` field of a settings file, remove or update that value so the notice does not recur on each launch + * If you need access to the restricted model, ask your organization admin to enable it. See [Organization model restrictions](</docs/en/model-config#organization-model-restrictions>). + +### + +​ + thinking.type.enabled is not supported for this model Your Claude Code version is older than the minimum for Opus 4.7 or Opus 4.8. The CLI sent a thinking configuration the model no longer accepts.
modified Speed up responses with fast mode View current →
--- a/fast-mode.md +++ b/fast-mode.md @@ -98,7 +98,7 @@ * **Admin enablement for Team and Enterprise** : fast mode is disabled by default for Team and Enterprise organizations. An admin must explicitly enable fast mode before users can access it. -If your admin has not enabled fast mode for your organization, the `/fast` command will show “Fast mode has been disabled by your organization.” If your organization’s [`availableModels`](</docs/en/model-config#restrict-model-selection>) allowlist excludes the fast-mode Opus model, `/fast` is refused with “is not in your organization’s allowed models”. +If your admin has not enabled fast mode for your organization, the `/fast` command will show “Fast mode has been disabled by your organization.” If your organization’s [`availableModels`](</docs/en/model-config#restrict-model-selection>) allowlist excludes the fast-mode Opus model, `/fast` is refused with “is not in your organization’s allowed models”. The exception is a session already running on an allowed Opus model that supports fast mode: `/fast` enables fast mode on your current model instead of switching models. ###
modified Fullscreen rendering View current →
--- a/fullscreen.md +++ b/fullscreen.md @@ -42,6 +42,7 @@ * **Click in the prompt input** to position your cursor anywhere in the text you’re typing. * **Click a suggestion in the`/` command or `@` file list** to accept it. Hovering highlights the row under your cursor. + * **Click an option in a select menu** to choose it. This covers permission prompts, `/model`, `/config`, and other dialogs that show a list of options. Hovering shows a pointer on the row under your cursor. Requires Claude Code v2.1.187 or later. * **Click a collapsed tool result** to expand it and see the full output. Click again to collapse. The tool call and its result expand together. Only messages that have more to show are clickable. * **Hold`Cmd` on macOS, or `Ctrl` on Linux and Windows, and click a URL or file path** to open it. File paths in tool output, like the ones printed after an Edit or Write, open in your default application. Plain `http://` and `https://` URLs open in your browser. As of v2.1.181, a plain click without holding `Cmd` or `Ctrl` no longer opens links, matching native terminal behavior. In the VS Code integrated terminal and similar xterm.js-based terminals, Claude Code defers to the terminal’s own link handler, which uses the same gesture. * **Click and drag** to select text anywhere in the conversation. Double-click selects a word, matching iTerm2’s word boundaries so a file path selects as one unit. Triple-click selects the line.
modified Claude Code GitHub Actions View current →
--- a/github-actions.md +++ b/github-actions.md @@ -42,7 +42,7 @@ Quick setup -The easiest way to set up this action is through Claude Code in the terminal. Just open claude and run `/install-github-app`. This command will guide you through setting up the GitHub app and required secrets. +Run `/install-github-app` in the Claude Code terminal to set up the integration interactively. The command installs the Claude GitHub App on your repository and then walks you through adding the GitHub Actions workflows and the API key secret. After the GitHub App is installed, the command asks whether to continue with GitHub Actions setup. In Claude Code v2.1.187 and later you can choose **Skip for now** to stop with only the App installed and return to the workflow and secret steps by running `/install-github-app` again. Earlier versions proceed straight to workflow selection. * You must be a repository admin to install the GitHub app and add secrets * The GitHub app will request read & write permissions for Contents, Issues, and Pull requests
modified Glossary View current →
--- a/glossary.md +++ b/glossary.md @@ -214,7 +214,7 @@ Managed settings -A settings file enforced org-wide by IT or DevOps, placed at an OS-level path outside `~/.claude`. Users cannot override or exclude managed settings. Use this for security policies, compliance requirements, or standardized tooling across a fleet. Learn more: [Server-managed settings](</docs/en/server-managed-settings>) +Settings enforced org-wide by IT or DevOps, delivered from Anthropic’s servers through the admin console or deployed to devices at an OS-level path outside `~/.claude`. User and project settings cannot override managed settings. Server-managed delivery applies on [eligible configurations](</docs/en/server-managed-settings#platform-availability>); see [Security considerations](</docs/en/server-managed-settings#security-considerations>). Use this for security policies, compliance requirements, or standardized tooling across a fleet. Learn more: [Server-managed settings](</docs/en/server-managed-settings>) · [Settings files](</docs/en/settings#settings-files>) ###
modified Hooks reference View current →
--- a/hooks.md +++ b/hooks.md @@ -181,10 +181,10 @@ Matcher value| Evaluated as| Example ---|---|--- `"*"`, `""`, or omitted| Match all| fires on every occurrence of the event -Only letters, digits, `_`, and `|`| Exact string, or `|`-separated list of exact strings| `Bash` matches only the Bash tool; `Edit|Write` matches either tool exactly +Only letters, digits, `_`, spaces, `,`, and `|`| Exact string, or list of exact strings separated by `|` or `,` with optional surrounding whitespace| `Bash` matches only the Bash tool; `Edit|Write` and `Edit, Write` each match either tool exactly Contains any other character| JavaScript regular expression| `^Notebook` matches any tool starting with Notebook; `mcp__memory__.*` matches every tool from the `memory` server -The `FileChanged` event does not follow these rules when building its watch list. See FileChanged. Each event type matches on a different field: +Comma separators and the surrounding whitespace tolerance require Claude Code v2.1.191 or later. The `FileChanged` and `StopFailure` events accept only `|` as the list separator and treat `,` as a literal character; all other events listed in the table that follows accept `|` or `,`. The `FileChanged` event does not follow these rules when building its watch list. See FileChanged. Each event type matches on a different field: Event| What the matcher filters| Example matcher values ---|---|---
modified Interactive mode View current →
--- a/interactive-mode.md +++ b/interactive-mode.md @@ -180,7 +180,7 @@ `T{char}`| Jump to just after previous occurrence of character `;`| Repeat last f/F/t/T motion `,`| Repeat last f/F/t/T motion in reverse -`/`| Open reverse history search, same as `Ctrl+R` +`/`| Open reverse history search, same as `Ctrl+R`. As of v2.1.191, the empty search prompt shows a hint: press `Esc` then `i` then `/` to open the command menu instead In vim normal mode, if the cursor is at the beginning or end of input and cannot move further, `j`/`k` and the arrow keys navigate command history instead. @@ -284,7 +284,7 @@ * Press `Ctrl+C` to cancel and restore your original input * Press `Backspace` on empty search to cancel -The search displays matching commands with the search term highlighted, so you can find and reuse previous inputs. +The search loads the 100 most recent unique prompts in the selected scope, with duplicates collapsed to the newest occurrence. Matching prompts display with the search term highlighted, so you can find and reuse previous inputs. ## @@ -382,6 +382,7 @@ ---|--- `Space`, `Enter`, `Escape`| Dismiss the answer and return to the prompt `Up` / `Down`| Scroll the answer +`Left` / `Right`| Step between this answer and your earlier `/btw` answers from the session. `Left` moves to older answers and `Right` returns toward the current one. Requires Claude Code v2.1.187 or later `c`| Copy the answer to your clipboard as raw Markdown. Use this instead of mouse selection, which captures the hard-wrapped terminal rendering rather than the source text `f`| Fork into a new session. The fork inherits the parent conversation plus this question and answer as real transcript turns, so you can continue with full tool access. The original session is preserved under [`/resume`](</docs/en/commands>). Available in local sessions only `x`| Clear the list of earlier `/btw` exchanges shown above the current answer
modified LLM gateways View current →
Show diff (271 lines)
--- a/llm-gateway.md +++ b/llm-gateway.md @@ -1,205 +1,96 @@ -LLM gateways provide a centralized proxy layer between Claude Code and model providers, often providing: +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. This page covers: - * **Centralized authentication** \- Single point for API key management - * **Usage tracking** \- Monitor usage across teams and projects - * **Cost controls** \- Implement budgets and rate limits - * **Audit logging** \- Track all model interactions for compliance - * **Model routing** \- Switch between providers without code changes + * What a gateway provides + * How routing and credentials work + * The steps to roll one out + * How gateways interact with claude.ai subscriptions + * What’s configured separately from the gateway -This page covers gateway requirements and configuration for the Claude Code CLI. Enterprise Desktop deployments can configure gateway providers via [managed settings](<https://support.claude.com/en/articles/12622667-enterprise-configuration>). The Claude Desktop app can also run against a self-hosted gateway through the [Cowork on 3P research preview](<https://claude.com/docs/cowork/3p/gateway>), which uses its own configuration keys. + * If you’re a developer connecting to an existing gateway: [connect Claude Code to your gateway](</docs/en/llm-gateway-connect>) + * If you’re an admin rolling out a gateway for your organization: [deploy and distribute a gateway](</docs/en/llm-gateway-rollout>) + * If you’re configuring a gateway product: the [gateway protocol reference](</docs/en/llm-gateway-protocol>) ## ​ -Gateway requirements +What a gateway provides -For an LLM gateway to work with Claude Code, it must meet the following requirements: **API format** The gateway must expose to clients at least one of the following API formats: +A gateway gives your organization one place to manage: - 1. **Anthropic Messages** : `/v1/messages`, `/v1/messages/count_tokens` - * Must forward request headers: `anthropic-beta`, `anthropic-version` - 2. **Bedrock InvokeModel** : `/invoke`, `/invoke-with-response-stream` - * Must preserve request body fields: `anthropic_beta`, `anthropic_version` - 3. **Vertex rawPredict** : `:rawPredict`, `:streamRawPredict`, `/count-tokens:rawPredict` - * Must forward request headers: `anthropic-beta`, `anthropic-version` + * **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 -Failure to forward headers or preserve body fields may result in reduced functionality or inability to use Claude Code features. - -Claude Code determines which features to enable based on the API format. When using the Anthropic Messages format with Bedrock or Vertex, you may need to set environment variable `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1`. - -**Request headers** Claude Code includes the following headers on API requests: - -Header| Description ----|--- -`X-Claude-Code-Session-Id`| A unique identifier for the current Claude Code session. Proxies can use this to aggregate all API requests from a single session without parsing the request body. -`X-Claude-Code-Agent-Id`| Identifier of the subagent or teammate that issued the request. Your proxy can use this to attribute API cost to individual parallel subagents within a session, without parsing the request body. Present only for requests made by an in-process subagent or teammate. -`X-Claude-Code-Parent-Agent-Id`| Identifier of the agent that spawned the agent making the request. Use this with `X-Claude-Code-Agent-Id` to attribute API costs across nested agents in your proxy. Present only when the requesting agent was itself spawned by another agent. - -Both agent ID headers are ephemeral per-spawn identifiers, not persistent user or device IDs. Claude Code also prepends a short attribution block to the system prompt containing the client version and a fingerprint derived from the conversation. The Anthropic API strips this block before processing, so it does not affect first-party prompt caching. If your gateway implements its own prompt cache keyed on the full request body, set [`CLAUDE_CODE_ATTRIBUTION_HEADER=0`](</docs/en/env-vars>) to omit it. +All of these except provider switching apply whether the upstream is Anthropic’s API or a [cloud provider](</docs/en/third-party-integrations>). 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](</docs/en/llm-gateway-protocol>) covers what to forward. ## ​ -Configuration +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](</docs/en/llm-gateway-protocol#api-formats>) lists which variable goes with each configuration. -​ +Two kinds of credential are involved: -Model selection + * **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 -By default, Claude Code uses standard model names for the selected API format. When `ANTHROPIC_BASE_URL` points at a gateway that exposes the Anthropic Messages format, Claude Code can query the gateway’s `/v1/models` endpoint at startup and add the returned models to the `/model` picker. Set `CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1` to enable this. Discovery is off by default so that gateways backed by a shared API key do not surface every model the key can access to every user. Each discovered entry is labeled “From gateway” and uses the `display_name` field from the response when one is provided. This requires Claude Code v2.1.129 or later. Discovery applies only to the Anthropic Messages format. It does not run for Bedrock or Vertex pass-through endpoints, and it does not run when `ANTHROPIC_BASE_URL` is unset or points at `api.anthropic.com`. The discovery request authenticates the same way as inference requests: it sends `ANTHROPIC_AUTH_TOKEN` as a bearer token, or `ANTHROPIC_API_KEY` as the `x-api-key` header when no auth token is set, along with any headers from `ANTHROPIC_CUSTOM_HEADERS`. Only models whose ID begins with `claude` or `anthropic` are added to the picker. Results are cached to `~/.claude/cache/gateway-models.json` and refreshed on each startup. If the request fails or the gateway does not implement `/v1/models`, the picker falls back to the cached list from the previous startup or to the built-in model list. If your gateway uses model names that do not match the discovery filter, use the environment variables documented in [Model configuration](</docs/en/model-config>) to add them manually. +The gateway forwards each request to the provider you configure, such as the Anthropic API, [Amazon Bedrock](</docs/en/amazon-bedrock>), [Google Vertex AI](</docs/en/google-vertex-ai>), [Microsoft Foundry](</docs/en/microsoft-foundry>), or the [Claude Platform on AWS](</docs/en/claude-platform-on-aws>). Because Claude Code talks only to the gateway, the provider choice is the gateway’s configuration, not the client’s. ## ​ -LiteLLM configuration +Roll out a gateway -LiteLLM PyPI versions 1.82.7 and 1.82.8 were compromised with credential-stealing malware. Do not install these versions. If you have already installed them: +When you’re ready to roll out an LLM gateway to your organization, the sequence is the same whichever gateway product you choose: - * Remove the package - * Rotate all credentials on affected systems - * Follow the remediation steps in [BerriAI/litellm#24518](<https://github.com/BerriAI/litellm/issues/24518>) + 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](</docs/en/settings#settings-files>) 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](</docs/en/llm-gateway-connect>) to set the variables themselves. + 4. Have each developer [check for the configuration in Claude Code](</docs/en/llm-gateway-connect#check-for-an-existing-configuration>), so distribution problems surface before they depend on the gateway. -LiteLLM is a third-party proxy service. Anthropic doesn’t endorse, maintain, or audit LiteLLM’s security or functionality. This guide is provided for informational purposes and may become outdated. Use at your own discretion. - -### - -​ - -Prerequisites - - * Claude Code updated to the latest version - * LiteLLM Proxy Server deployed and accessible - * Access to Claude models through your chosen provider - -### - -​ - -Basic LiteLLM setup - -**Configure Claude Code** : - -#### - -​ - -Authentication methods - -##### Static API key - -Simplest method using a fixed API key: - - # Set in environment - export ANTHROPIC_AUTH_TOKEN=sk-litellm-static-key - - # Or in Claude Code settings - { - "env": { - "ANTHROPIC_AUTH_TOKEN": "sk-litellm-static-key" - } - } - -This value will be sent as the `Authorization` header. - -##### Dynamic API key with helper - -For rotating keys or per-user authentication: - - 1. Create an API key helper script: - - #!/bin/bash - # ~/bin/get-litellm-key.sh - - # Example: Fetch key from vault - vault kv get -field=api_key secret/litellm/claude-code - - # Example: Generate JWT token - jwt encode \ - --secret="${JWT_SECRET}" \ - --exp="+1h" \ - '{"user":"'${USER}'","team":"engineering"}' - - 2. Configure Claude Code settings to use the helper: - - { - "apiKeyHelper": "~/bin/get-litellm-key.sh" - } - - 3. Set token refresh interval: - - # Refresh every hour (3600000 ms) - export CLAUDE_CODE_API_KEY_HELPER_TTL_MS=3600000 - -This value will be sent as `Authorization` and `X-Api-Key` headers. The `apiKeyHelper` has lower precedence than `ANTHROPIC_AUTH_TOKEN` or `ANTHROPIC_API_KEY`. - -#### - -​ - -Unified endpoint (recommended) - -Using LiteLLM’s [Anthropic format endpoint](<https://docs.litellm.ai/docs/anthropic_unified>): - - export ANTHROPIC_BASE_URL=https://litellm-server:4000 - -**Benefits of the unified endpoint over pass-through endpoints:** - - * Load balancing - * Fallbacks - * Consistent support for cost tracking and end-user tracking - -#### - -​ - -Provider-specific pass-through endpoints (alternative) - -##### Claude API through LiteLLM - -Using [pass-through endpoint](<https://docs.litellm.ai/docs/pass_through/anthropic_completion>): - - export ANTHROPIC_BASE_URL=https://litellm-server:4000/anthropic - -##### Amazon Bedrock through LiteLLM - -Using [pass-through endpoint](<https://docs.litellm.ai/docs/pass_through/bedrock>): - - export ANTHROPIC_BEDROCK_BASE_URL=https://litellm-server:4000/bedrock - export CLAUDE_CODE_SKIP_BEDROCK_AUTH=1 - export CLAUDE_CODE_USE_BEDROCK=1 - -##### Google Vertex AI through LiteLLM - -Using [pass-through endpoint](<https://docs.litellm.ai/docs/pass_through/vertex_ai>): - - export ANTHROPIC_VERTEX_BASE_URL=https://litellm-server:4000/vertex_ai/v1 - export ANTHROPIC_VERTEX_PROJECT_ID=your-gcp-project-id - export CLAUDE_CODE_SKIP_VERTEX_AUTH=1 - export CLAUDE_CODE_USE_VERTEX=1 - export CLOUD_ML_REGION=us-east5 - -##### Claude Platform on AWS through a gateway - -Route to a gateway that forwards to the [Claude Platform on AWS](</docs/en/claude-platform-on-aws>) endpoint: - - export ANTHROPIC_AWS_BASE_URL=https://litellm-server:4000/anthropic-aws - export ANTHROPIC_AWS_WORKSPACE_ID=wrkspc_01ABCDEFGHIJKLMN - export CLAUDE_CODE_SKIP_ANTHROPIC_AWS_AUTH=1 - export CLAUDE_CODE_USE_ANTHROPIC_AWS=1 - -For more detailed information, refer to the [LiteLLM documentation](<https://docs.litellm.ai/>). +[Roll out an LLM gateway for your organization](</docs/en/llm-gateway-rollout>) 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](</docs/en/admin-setup>). ## ​ -Additional resources +Third-party gateways - * [LiteLLM documentation](<https://docs.litellm.ai/>) - * [Claude Code settings](</docs/en/settings>) - * [Enterprise network configuration](</docs/en/network-config>) - * [Third-party integrations overview](</docs/en/third-party-integrations>) +Any gateway that exposes a [supported API format](</docs/en/llm-gateway-protocol#api-formats>) 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](</docs/en/llm-gateway-rollout>). + +## + +​ + +Subscriptions and gateways + +While a [gateway credential variable](</docs/en/llm-gateway-connect#set-the-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](</docs/en/llm-gateway-protocol#request-headers>). + +## + +​ + +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](</docs/en/model-config#setting-your-model>) + * **Client-side traffic** : version checks and optional client telemetry, both disabled with [`CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`](</docs/en/env-vars>), 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](</docs/en/network-config#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](</docs/en/network-config#proxy-configuration>) + +## + +​ + +Related pages + + * [Connect Claude Code to an LLM gateway](</docs/en/llm-gateway-connect>): set the base URL and credential on your own machine, with per-surface configuration and a troubleshooting table + * [Roll out an LLM gateway for your organization](</docs/en/llm-gateway-rollout>): the admin checklist for deploying a gateway, issuing developer credentials, and distributing managed settings + * [Gateway protocol reference](</docs/en/llm-gateway-protocol>): what Claude Code sends to a gateway, for operators configuring one, covering endpoints, headers to forward, and feature pass-through + * [Set up Claude Code for your organization](</docs/en/admin-setup>): the wider rollout decisions a gateway is one part of, including policy enforcement and usage visibility
added Connect Claude Code to an LLM gateway View current →
Show diff (471 lines)
--- a/llm-gateway-connect.md +++ b/llm-gateway-connect.md @@ -0,0 +1,468 @@ +An [LLM gateway](</docs/en/llm-gateway>) is a proxy your organization runs between Claude Code and the model provider. When your organization uses one, Claude Code authenticates to the gateway with a credential your organization issues instead of your personal claude.ai login. This page is for developers running Claude Code through a gateway their organization operates. It covers two paths: checking whether your administrator already configured it for you, and configuring it yourself when they haven’t. + + * To deploy a gateway for your organization, see [Roll out an LLM gateway](</docs/en/llm-gateway-rollout>) + * For what Claude Code sends to a gateway, see the [gateway protocol reference](</docs/en/llm-gateway-protocol>) + +## + +​ + +Check for an existing configuration + +Administrators can distribute the gateway address and credential through [managed settings](</docs/en/settings#settings-files>), device management, or an `apiKeyHelper`, so Claude Code picks them up at startup with nothing for you to set. To check whether your organization already did this: + +1 + +Start Claude Code + +Run `claude`. If it opens to the login screen instead of a session, no gateway credential was distributed; configure it yourself below. + +2 + +Check the Status tab + +If Claude Code started a session without showing the login screen, run `/status`, open the **Status** tab, and check two lines: + + * `Anthropic base URL`: this line only appears when a gateway address is set. If it isn’t there, Claude Code isn’t pointed at the gateway; configure it yourself below. + * `Auth token` or `API key`: a line naming `ANTHROPIC_AUTH_TOKEN`, `ANTHROPIC_API_KEY`, or an `apiKeyHelper` confirms a gateway credential is active. A `Login method` line naming a claude.ai account instead means the credential wasn’t distributed; set it yourself. + +3 + +Send a test message + +Close the `/status` menu and send any prompt in Claude Code. A normal response from Claude, with no error, confirms the gateway connection works. + +If both lines in the `/status` menu look right but the message to Claude fails, see the troubleshooting table. + +## + +​ + +Configure Claude Code yourself + +To configure Claude Code for the gateway yourself, you need from your gateway team: + + * The gateway’s base URL + * A credential: a key or token string, or a command that fetches one + * If your gateway team didn’t say which kind of credential it is, the credential variable section below covers what to try + +The sections below cover the configuration in order: + + * Set the credential variable and set the base URL: the two variables every gateway connection needs + * Verify the connection: confirm it works before persisting anything + * Configure each surface: if you are using a surface besides the Claude Code CLI, such as VS Code, see how to configure it with your gateway credentials + * Additional configuration: variables some gateways need beyond the base URL and credential, such as a custom header, a credential helper, model discovery, or a provider-format base URL. Set these only if your administrator named them + +### + +​ + +Set the credential variable + +To authenticate Claude Code to the gateway, set your credential in an environment variable. Which variable depends on what your gateway team told you: + +Set the credential in| Use when +---|--- +`ANTHROPIC_AUTH_TOKEN`| Your gateway team said “bearer token” or “Authorization header” +`ANTHROPIC_API_KEY`| Your gateway team said “API key” or “x-api-key” +`apiKeyHelper`| The credential rotates or comes from a vault + +If you weren’t told which kind, use `ANTHROPIC_AUTH_TOKEN`; the verification request below shows how to tell if you need to switch. + +### + +​ + +Set the base URL and credential + +Set the gateway’s base URL and the credential variable you picked above as environment variables. The examples use `ANTHROPIC_AUTH_TOKEN`; swap it for `ANTHROPIC_API_KEY` if that’s the variable you picked. You can set them in your shell, which lasts for one terminal session, or in a Claude Code settings file, which persists everywhere Claude Code runs. For your first connection, start with shell exports and run the verification request before moving the values to a settings file. + +#### + +​ + +Set as shell environment variables + +Replace the values with the ones your gateway team gave you: + + * Bash or Zsh + + * PowerShell + + export ANTHROPIC_BASE_URL=https://llm-gateway.example.com + export ANTHROPIC_AUTH_TOKEN=sk-gateway-key + + $env:ANTHROPIC_BASE_URL = "https://llm-gateway.example.com" + $env:ANTHROPIC_AUTH_TOKEN = "sk-gateway-key" + +Shell 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 them persist across new terminals, add the same lines to your shell profile, such as `~/.zshrc`, `~/.bashrc`, or your PowerShell `$PROFILE`, or use a settings file instead. + +#### + +​ + +Set in a settings file + +To make the configuration apply everywhere Claude Code runs without depending on your shell, set the variables in the `env` block of a [settings file](</docs/en/settings>). Settings files have different scopes: + + * `~/.claude/settings.json` applies to all your projects. On Windows the path is `%USERPROFILE%\.claude\settings.json` + * `.claude/settings.local.json` applies to one project. Claude Code adds it to your gitignore when it creates the file; if you create it yourself, add it to your gitignore manually first so you don’t accidentally commit your credential + +Don’t put the credential in a project’s `.claude/settings.json`. That file is committed and shared with everyone who clones the repository. + +The `env` block looks the same in either file: + + { + "env": { + "ANTHROPIC_BASE_URL": "https://llm-gateway.example.com", + "ANTHROPIC_AUTH_TOKEN": "sk-gateway-key" + } + } + +When both a shell export and a settings-file `env` block set the same variable, the settings-file value applies. Run `/status` to see which base URL and credential source Claude Code is using. + +### + +​ + +Verify the connection + +With 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 even if you also put the values in a settings file. + + * Bash or Zsh + + * PowerShell + + curl -X POST "$ANTHROPIC_BASE_URL/v1/messages" \ + -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \ + -H "anthropic-version: 2023-06-01" \ + -H "content-type: application/json" \ + -d '{"model": "claude-sonnet-4-6", "max_tokens": 1, "messages": [{"role": "user", "content": "."}]}' + + Invoke-RestMethod -Method Post -Uri "$env:ANTHROPIC_BASE_URL/v1/messages" ` + -Headers @{ "Authorization" = "Bearer $env:ANTHROPIC_AUTH_TOKEN"; "anthropic-version" = "2023-06-01" } ` + -ContentType "application/json" ` + -Body '{"model": "claude-sonnet-4-6", "max_tokens": 1, "messages": [{"role": "user", "content": "."}]}' + +If 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. A 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. + +#### + +​ + +Confirm in Claude Code + +Start `claude` from the same shell so it inherits the exports, send a message, and run `/status`. On the **Status** tab, the `Anthropic base URL` line should show your gateway address, which confirms requests are routing there; if the line isn’t there, the variable didn’t reach the session. An `Auth token` or `API key` line naming the variable you set confirms the gateway credential is active rather than a saved claude.ai login. If the message fails, or `/status` doesn’t show the gateway URL, see the troubleshooting table below. + +### + +​ + +How the credential variable maps to a header + +Each variable sends the credential in a different HTTP header: `ANTHROPIC_AUTH_TOKEN` in `Authorization: Bearer`, `ANTHROPIC_API_KEY` in `x-api-key`, and `apiKeyHelper` in both. A credential in the wrong variable reaches the gateway in a header it doesn’t read, and the request fails with `401`. If the verification request returned `401`, switch to the other variable and try again. + +### + +​ + +Conflicts with an existing login + +A gateway credential variable takes precedence over a saved claude.ai login or Console key. Your claude.ai login stays saved and unused while the variable is set; unset the variable and Claude Code goes back to it. With `ANTHROPIC_AUTH_TOKEN`, the variable takes precedence immediately. With `ANTHROPIC_API_KEY`, you are prompted once in interactive mode to approve the key before it takes over. Run `/status` to confirm which credential source is active. If startup shows an auth-conflict warning naming two sources, see the first row of the troubleshooting table for which one to drop. To clear a saved login so only the gateway credential remains, run `/logout`. + +## + +​ + +Configure each surface + +The CLI reads the environment variables and settings files above. The other surfaces are the VS Code extension, the desktop app, GitHub Actions, the Agent SDK, and the cloud surfaces such as Slack and the web; the sections below cover whether those settings reach each one. + +### + +​ + +VS Code extension + +Set the gateway variables for the [VS Code extension](</docs/en/vs-code>) in `claudeCode.environmentVariables`, in VS Code’s own user settings opened with the **Preferences: Open User Settings (JSON)** command. The extension checks credentials from this setting before launching, so it’s the reliable place for the gateway credential; values in `~/.claude/settings.json` reach the spawned process but not the extension’s own login check. + + { + "claudeCode.environmentVariables": [ + { "name": "ANTHROPIC_BASE_URL", "value": "https://llm-gateway.example.com" }, + { "name": "ANTHROPIC_AUTH_TOKEN", "value": "sk-gateway-key" } + ] + } + +### + +​ + +Desktop app + +The desktop app reads gateway routing from an [administrator-distributed configuration](<https://claude.com/docs/cowork/3p/gateway>), not from `ANTHROPIC_BASE_URL` or `settings.json`. If your organization has distributed it, the desktop app routes through the gateway with no setup on your part; if not, use the terminal CLI or VS Code extension for gateway sessions. Administrators distribute the configuration as described in the [organization rollout](</docs/en/llm-gateway-rollout#distribute-through-managed-settings>). If the desktop app shows `Gateway was unreachable`, the app couldn’t reach the configured base URL at startup; check the URL and network path with the curl test above. + +### + +​ + +GitHub Actions + +[Claude Code GitHub Actions](</docs/en/github-actions>) reads `ANTHROPIC_BASE_URL` and `ANTHROPIC_CUSTOM_HEADERS` from the workflow’s `env` block. Pass the credential as the action’s `anthropic_api_key` input; the action sets it as `ANTHROPIC_API_KEY`, so it reaches the gateway in the `x-api-key` header. For an `x-api-key` gateway, set the base URL in `env` and pass the gateway key as the input: + + env: + ANTHROPIC_BASE_URL: https://llm-gateway.example.com + + steps: + - uses: anthropics/claude-code-action@v1 + with: + anthropic_api_key: ${{ secrets.GATEWAY_API_KEY }} + +For a bearer-token gateway, pass the same secret as both the `anthropic_api_key` input and `ANTHROPIC_AUTH_TOKEN` in the workflow `env` block. The action requires `anthropic_api_key`, `CLAUDE_CODE_OAUTH_TOKEN`, or workload identity federation before it launches Claude Code, and it doesn’t read `ANTHROPIC_AUTH_TOKEN`, so the input satisfies that launch check while the env variable puts the key in the `Authorization` header the gateway reads. The copy in `x-api-key` is ignored: + + env: + ANTHROPIC_BASE_URL: https://llm-gateway.example.com + ANTHROPIC_AUTH_TOKEN: ${{ secrets.GATEWAY_API_KEY }} + + steps: + - uses: anthropics/claude-code-action@v1 + with: + anthropic_api_key: ${{ secrets.GATEWAY_API_KEY }} + +For the action’s other authentication options, including `CLAUDE_CODE_OAUTH_TOKEN` and workload identity federation, see [Claude Code GitHub Actions](</docs/en/github-actions>) and the action’s [README](<https://github.com/anthropics/claude-code-action#readme>). + +### + +​ + +Agent SDK + +The [Agent SDK](</docs/en/agent-sdk/overview>) has no gateway-specific options; it passes environment variables to the Claude Code process it spawns. Each SDK accepts an `env` option that sets the spawned process’s environment, and the TypeScript and Python SDKs treat it differently: + + * TypeScript: the spawned process inherits the parent environment by default, but setting `options.env` replaces the environment entirely. Spread `process.env` into it to keep your gateway variables. + * Python: `ClaudeAgentOptions(env=...)` merges on top of the inherited environment, so gateway variables set in the parent process carry through without spreading. + +TypeScript + +Python + + const result = query({ + prompt: "...", + options: { + env: { + ...process.env, + ANTHROPIC_BASE_URL: "https://llm-gateway.example.com", + ANTHROPIC_AUTH_TOKEN: process.env.GATEWAY_KEY, + }, + }, + }) + +### + +​ + +Slack, web, and Remote Control + +[Claude Code in Slack](</docs/en/slack>) and [Claude Code on the web](</docs/en/claude-code-on-the-web>) are Anthropic-hosted products that always use Anthropic’s API; they aren’t part of a gateway deployment. Gateway variables set in a cloud session’s environment configuration are not applied. If your traffic must stay on the gateway, don’t enable these surfaces for those users. [Remote Control](</docs/en/remote-control>) and [voice dictation](</docs/en/voice-dictation>) both rely on a claude.ai identity: Remote Control to pair a live session with your account, and voice dictation to reach the claude.ai transcription endpoint. They are unavailable while `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, or an `apiKeyHelper` is active. To use either, unset the gateway credential and log in with claude.ai instead; `/doctor` names the variable to unset. + +## + +​ + +Additional configuration + +These settings cover cases beyond the base URL and credential. Set them only if your administrator’s instructions or the troubleshooting table call for one. + +### + +​ + +Send additional headers + +Some 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`](</docs/en/env-vars>) with one `Name: Value` pair per line. The example below adds a routing header named `X-Org-Route`: + + * Bash or Zsh + + * PowerShell + + export ANTHROPIC_CUSTOM_HEADERS="X-Org-Route: prod" + + $env:ANTHROPIC_CUSTOM_HEADERS = "X-Org-Route: prod" + +You 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: + + { + "env": { + "ANTHROPIC_CUSTOM_HEADERS": "X-Org-Route: prod\nX-Tenant: acme" + } + } + +### + +​ + +Add gateway models to the model picker + +Model discovery queries the gateway for its model list at startup and adds those names to the `/model` picker alongside the built-in entries. Enable it if your gateway serves model names that aren’t in Claude Code’s built-in list and you want to select them from the picker. If the built-in models are what you use, you don’t need discovery; your administrator may also have already enabled it through managed settings. To enable it, set `CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1` in your shell or in the `env` block of `~/.claude/settings.json`. Discovery requires Claude Code v2.1.129 or later. Discovered models appear as additional `/model` entries labeled `From gateway`. To confirm discovery ran, start `claude --debug` and look for the `[gatewayDiscovery]` lines: a success logs how many models were cached, and a `404`, timeout, or redirect is recorded there too. For when discovery runs, what it filters, and the response format gateways serve, see the [model discovery reference](</docs/en/llm-gateway-protocol#model-discovery>). + +### + +​ + +Rotate credentials with apiKeyHelper + +An `apiKeyHelper` is a command Claude Code runs to fetch your gateway credential, instead of reading it from a static environment variable. Use a helper when the credential expires on a schedule, comes from a vault or SSO command, or your administrator told you to configure one. If your credential is a fixed string you set once, the credential variable is all you need and you can skip this section. The 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. Write the script, make it executable, and reference it from `apiKeyHelper` in your [settings file](</docs/en/settings>): + + * Bash or Zsh + + * PowerShell + +For example, a script that reads from a vault: + + #!/bin/bash + vault kv get -field=api_key secret/llm-gateway/claude-code + +Reference its path in `~/.claude/settings.json`: + + { + "apiKeyHelper": "~/bin/get-gateway-key.sh" + } + +For example, a script that reads from a vault: + + vault kv get -field=api_key secret/llm-gateway/claude-code + +Reference the PowerShell invocation in `%USERPROFILE%\.claude\settings.json`, escaping the backslashes in the JSON string: + + { + "apiKeyHelper": "powershell -NoProfile -File C:\\scripts\\get-gateway-key.ps1" + } + +Claude Code caches the helper’s output for five minutes by default and re-runs it when a request returns HTTP 401. To change the cache lifetime, set `CLAUDE_CODE_API_KEY_HELPER_TTL_MS` in milliseconds, for example `CLAUDE_CODE_API_KEY_HELPER_TTL_MS=900000` for 15 minutes. The helper’s value is sent in both the `Authorization` and `x-api-key` headers, so it works whichever header your gateway reads. + +### + +​ + +Route to a cloud provider through a gateway + +These configurations point Claude Code at a gateway through a provider-specific base URL variable in place of `ANTHROPIC_BASE_URL`. Bedrock and Vertex gateways accept those providers’ native request formats; Foundry and Claude Platform on AWS gateways accept the Anthropic Messages format and differ only in which base URL variable reaches them. Use one only if your gateway team specifically named Bedrock, Vertex, Foundry, or the Claude Platform on AWS. If the verification request above returned JSON, you can skip this section. Set the block for the provider your gateway team named. The skip-auth variables tell Claude Code not to sign requests with provider credentials, since the gateway holds those. If the gateway needs its own token, add `ANTHROPIC_AUTH_TOKEN` after the block, except for Foundry, which uses `ANTHROPIC_FOUNDRY_API_KEY` as shown. + +#### + +​ + +Amazon Bedrock + + * Bash or Zsh + + * PowerShell + + export ANTHROPIC_BEDROCK_BASE_URL=https://llm-gateway.example.com/bedrock + export CLAUDE_CODE_SKIP_BEDROCK_AUTH=1 + export CLAUDE_CODE_USE_BEDROCK=1 + + $env:ANTHROPIC_BEDROCK_BASE_URL = "https://llm-gateway.example.com/bedrock" + $env:CLAUDE_CODE_SKIP_BEDROCK_AUTH = "1" + $env:CLAUDE_CODE_USE_BEDROCK = "1" + +#### + +​ + +Google Vertex AI + + * Bash or Zsh + + * PowerShell + + export ANTHROPIC_VERTEX_BASE_URL=https://llm-gateway.example.com/vertex + export ANTHROPIC_VERTEX_PROJECT_ID=your-gcp-project-id + export CLAUDE_CODE_SKIP_VERTEX_AUTH=1 + export CLAUDE_CODE_USE_VERTEX=1 + export CLOUD_ML_REGION=us-east5 + + $env:ANTHROPIC_VERTEX_BASE_URL = "https://llm-gateway.example.com/vertex" + $env:ANTHROPIC_VERTEX_PROJECT_ID = "your-gcp-project-id" + $env:CLAUDE_CODE_SKIP_VERTEX_AUTH = "1" + $env:CLAUDE_CODE_USE_VERTEX = "1" + $env:CLOUD_ML_REGION = "us-east5" + +#### + +​ + +Microsoft Foundry + +Put the gateway’s credential in `ANTHROPIC_FOUNDRY_API_KEY`; it is sent to the gateway as the `x-api-key` header. `CLAUDE_CODE_SKIP_FOUNDRY_AUTH` doesn’t apply here: without an API key, the Foundry client fails every request before it leaves the machine. + + * Bash or Zsh + + * PowerShell + + export ANTHROPIC_FOUNDRY_BASE_URL=https://llm-gateway.example.com/foundry + export ANTHROPIC_FOUNDRY_API_KEY=sk-gateway-key + export CLAUDE_CODE_USE_FOUNDRY=1 + + $env:ANTHROPIC_FOUNDRY_BASE_URL = "https://llm-gateway.example.com/foundry" + $env:ANTHROPIC_FOUNDRY_API_KEY = "sk-gateway-key" + $env:CLAUDE_CODE_USE_FOUNDRY = "1" + +#### + +​ + +Claude Platform on AWS + +See [Claude Platform on AWS](</docs/en/claude-platform-on-aws>) for the workspace ID. + + * Bash or Zsh + + * PowerShell + + export ANTHROPIC_AWS_BASE_URL=https://llm-gateway.example.com/anthropic-aws + export ANTHROPIC_AWS_WORKSPACE_ID=wrkspc_01ABCDEFGHIJKLMN + export CLAUDE_CODE_SKIP_ANTHROPIC_AWS_AUTH=1 + export CLAUDE_CODE_USE_ANTHROPIC_AWS=1 + + $env:ANTHROPIC_AWS_BASE_URL = "https://llm-gateway.example.com/anthropic-aws" + $env:ANTHROPIC_AWS_WORKSPACE_ID = "wrkspc_01ABCDEFGHIJKLMN" + $env:CLAUDE_CODE_SKIP_ANTHROPIC_AWS_AUTH = "1" + $env:CLAUDE_CODE_USE_ANTHROPIC_AWS = "1" + +## + +​ + +Troubleshoot gateway errors + +These are the most common errors when running Claude Code through a gateway, with the gateway-side cause and the fix: + +Error| Cause| Fix +---|---|--- +A startup warning naming two credential sources and ending in `auth may not work as expected`. Older versions show `Auth conflict: Both a token (SOURCE) and an API key (SOURCE) are set` instead.| A gateway credential and a saved login are both active; the variable is used for requests, but the stale login can cause unexpected auth behavior| Unset the variable to use the saved login, or run `/logout` to use the gateway credential +`401` errors naming an invalid or unrecognized token| The credential isn’t one the gateway issued, or it’s in a header the gateway doesn’t read| Confirm the variable matches your credential kind in the credential table, and regenerate the key at the gateway if it was revoked +`Unable to connect to API (ConnectionRefused)`, or `(ECONNREFUSED)` from npm installs, often after a silent pause while Claude Code [retries with backoff](</docs/en/errors#automatic-retries>)| Nothing answered at the base URL: the address is wrong, or a VPN or firewall blocks the path to the gateway| Run the curl test above, which fails immediately with the same cause, and confirm the URL and network path with your gateway team +`API returned an empty or malformed response (HTTP 200)`| The gateway or an intermediate proxy returned a non-API response, often an HTML error or login page| Test with the curl request above; fix the gateway route that returns non-JSON +`400` errors naming `context_management`, `Extra inputs are not permitted`, or other unrecognized fields| The gateway forwards requests to an upstream that rejects fields Claude Code sends to Anthropic-format endpoints| Set `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1`, which suppresses most pre-release fields; see [feature pass-through](</docs/en/llm-gateway-protocol#feature-pass-through>). Some betas aren’t gated by this flag; for those, set the matching `CLAUDE_CODE_USE_*` provider variable so Claude Code sends only what that provider accepts +`400` errors naming `thinking` or `adaptive`, such as `Input tag 'adaptive' found`| The upstream model build doesn’t accept adaptive reasoning, which Claude Code requests for Claude 4.6 and later models| Upgrade the gateway’s upstream. On Opus 4.6 and Sonnet 4.6, `CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING=1` works instead. The [model configuration](</docs/en/model-config>) capability variables apply only to the provider configurations, such as `CLAUDE_CODE_USE_BEDROCK` and `CLAUDE_CODE_USE_VERTEX`, not behind an `ANTHROPIC_BASE_URL` gateway +`400` errors stating a context or token limit in the gateway’s own words, such as `ContextWindowExceededError` or `prompt token count of N exceeds the limit of M`| The gateway enforces a smaller context than the model’s native window and rewrites the upstream error, so the automatic compact-and-retry, which matches Anthropic’s `prompt is too long` wording, doesn’t fire| Run `/compact` to recover the session. To prevent it, set `CLAUDE_CODE_AUTO_COMPACT_WINDOW` to the gateway’s limit; the value is clamped to at least 100,000 tokens and at most the model’s context window, so a gateway limit below 100,000 can’t be matched and `/compact` remains the recovery there. Also set `CLAUDE_CODE_MAX_OUTPUT_TOKENS` below the gateway model’s output limit +Models missing from the `/model` picker| Gateway model names aren’t in Claude Code’s built-in list| Enable gateway model discovery or add names with the [model configuration](</docs/en/model-config>) variables +Claude Code asks you to log in even though the curl test succeeds| The CLI has no credential of its own: a reachable base URL isn’t one, and an `env` block in a project’s `.claude/settings.json` or `.claude/settings.local.json` applies only after the first-run wizard and trust prompt| Set `ANTHROPIC_AUTH_TOKEN` somewhere Claude Code reads before first-run setup: a shell export, the `env` block in `~/.claude/settings.json`, or managed settings +`ANTHROPIC_API_KEY` is set but ignored, with no prompt| The key needs a one-time approval in interactive sessions, and a previously declined key is ignored without asking again| Enable it under `/config` with the `Use custom API key` option +`This machine's managed settings require a first-party login`| Managed settings include `forceLoginMethod` or `forceLoginOrgUUID`, which on Claude Code v2.1.146 and later cannot coexist with `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, or `apiKeyHelper`| Your administrator must remove `forceLoginMethod` and `forceLoginOrgUUID` from managed settings to use gateway credentials, or remove the gateway credential to use first-party login. The two cannot be combined +`403` with an HTML body such as `403 Forbidden`, when the gateway’s own logs show no request received| A web application firewall or reverse proxy in front of the gateway blocked the request body before it reached the gateway. Claude Code prompts include XML-style tags and source code that match cross-site-scripting body rules, so a short curl test passes while a real session doesn’t| Exempt the gateway’s `/v1/messages` path from request-body inspection. On AWS WAF this is the `CrossSiteScripting_Body` managed rule; on nginx with ModSecurity it is the equivalent OWASP CRS body rules +Certificate or TLS errors such as `SSL certificate verification failed` or `Self-signed certificate detected`, when the curl test succeeds| Claude Code’s runtime isn’t trusting the same certificate authority that `curl` uses. Common behind corporate TLS-inspection proxies| Set `NODE_EXTRA_CA_CERTS` to the CA bundle path; see [CA certificate store](</docs/en/network-config#ca-certificate-store>) + +If Claude Code prompts you to log in repeatedly after removing gateway configuration, the cause is usually credential storage rather than the gateway; see [authentication errors](</docs/en/errors#authentication-errors>). + +## + +​ + +Related resources + + * [LLM gateways overview](</docs/en/llm-gateway>): what a gateway is and how it interacts with claude.ai subscriptions + * [Roll out an LLM gateway for your organization](</docs/en/llm-gateway-rollout>): the admin-facing checklist for deploying and distributing gateway configuration + * [Gateway protocol reference](</docs/en/llm-gateway-protocol>): what Claude Code sends to a gateway, including the headers and fields the gateway must forward + * [Settings](</docs/en/settings>): where settings files live and how the `env` block is read + * [Authentication](</docs/en/authentication>): how credential variables, `apiKeyHelper`, and OAuth login interact
added Gateway protocol reference View current →
Show diff (205 lines)
--- a/llm-gateway-protocol.md +++ b/llm-gateway-protocol.md @@ -0,0 +1,202 @@ +This page documents the requests Claude Code sends to a gateway, including the endpoints it calls, the headers and body fields the gateway must forward, and which features stop working when it doesn’t. It is written for operators configuring a gateway product to work with Claude Code. + + * To roll out an existing or third-party gateway for your organization, see [Roll out an LLM gateway](</docs/en/llm-gateway-rollout>) + * If you’re an individual developer authenticating Claude Code to a gateway with a credential you were given, see [Connect Claude Code to an LLM gateway](</docs/en/llm-gateway-connect>) + +This page covers: + + * API formats and the endpoints to serve for each + * Request headers: which must reach the upstream and which your gateway can consume + * The system prompt attribution block and how it interacts with prompt caching + * Feature pass-through: what breaks when headers or body fields are stripped + * Model discovery + +This page uses two terms for what your gateway does with each header and body field: + + * **Forward unchanged** : pass it to the upstream byte-for-byte + * **Consume** : the gateway may read it for routing, attribution, or tracing and need not forward it + +Anything not marked forward unchanged is yours to consume or ignore. + +## + +​ + +API formats + +A gateway must expose at least one of the following API formats to Claude Code clients. Which format Claude Code speaks is determined by the client’s configuration: the variable in the Selected by column of the table below points Claude Code at your gateway in that format. + +Format| Selected by| Endpoints| Forward unchanged +---|---|---|--- +Anthropic Messages| `ANTHROPIC_BASE_URL`| `/v1/messages`, `/v1/messages/count_tokens` (optional)| `anthropic-beta` and `anthropic-version` request headers +Bedrock InvokeModel| `ANTHROPIC_BEDROCK_BASE_URL` with `CLAUDE_CODE_USE_BEDROCK=1`| `/model/{model}/invoke`, `/model/{model}/invoke-with-response-stream`| `anthropic_beta` and `anthropic_version` request body fields +Vertex rawPredict| `ANTHROPIC_VERTEX_BASE_URL` with `CLAUDE_CODE_USE_VERTEX=1`| `:rawPredict`, `:streamRawPredict`, `count-tokens:rawPredict` (optional)| `anthropic-beta` and `anthropic-version` request headers, and the `anthropic_version` request body field + +### + +​ + +Foundry and Claude Platform on AWS + +Microsoft Foundry and the [Claude Platform on AWS](</docs/en/claude-platform-on-aws>) implement the Anthropic Messages format. Claude Code routes to them through their own variables, `ANTHROPIC_FOUNDRY_BASE_URL` and `ANTHROPIC_AWS_BASE_URL`, but a gateway fronting either implements the Anthropic Messages row above. A gateway fronting the Claude Platform on AWS must also forward the `anthropic-workspace-id` header, which [that platform requires on every request](</docs/en/claude-platform-on-aws>). + +### + +​ + +Optional endpoints and startup traffic + +Token-counting endpoints are the only optional ones: when they’re absent, Claude Code estimates context usage locally. Inference requests post to `/v1/messages?beta=true`, so match on the path, not the full URL. The Vertex method suffixes attach to the publisher model path, as in `/projects/{project}/locations/{location}/publishers/anthropic/models/{model}:streamRawPredict`. A gateway also sees best-effort startup traffic it can reject without breaking anything: a `HEAD /` connectivity probe, and on Bedrock-format gateways a `GET /inference-profiles?type=SYSTEM_DEFINED` request. + +### + +​ + +Streaming + +Inference responses must stream. Claude Code consumes server-sent events as they arrive, so a gateway that buffers complete responses before relaying them stalls the client. + +### + +​ + +Format mismatch with the upstream + +Which format the client speaks determines what your gateway receives. The common failure mode is a mismatch between the format the client sends to your gateway and the format the upstream provider behind it accepts. + + * When the client speaks the Bedrock or Vertex format, Claude Code sends only the subset of its full capability set that those providers accept + * When the client speaks the Anthropic Messages format, Claude Code sends the full set, even if your gateway forwards to a Bedrock or Vertex upstream + +Bridging that difference is your gateway’s job. Feature pass-through describes what breaks when it doesn’t. + +## + +​ + +Request headers + +Claude Code includes these headers on API requests. Header names are case-insensitive on the wire. Forward `anthropic-version` and `anthropic-beta` unchanged, plus `anthropic-workspace-id` when the upstream is the [Claude Platform on AWS](</docs/en/claude-platform-on-aws>); the rest the gateway may consume for routing, attribution, and tracing, and need not forward. + +Header| Description +---|--- +`Authorization`, `x-api-key`| The developer’s gateway credential, in one or both headers depending on which [credential variable](</docs/en/llm-gateway-connect#set-the-credential-variable>) they set +`anthropic-version`| API version, currently `2023-06-01`. Bedrock- and Vertex-format requests also carry the `anthropic_version` body field, whose value is the provider dialect string, not this header’s value +`anthropic-beta`| Comma-separated capability values for the request. Forward the header verbatim; do not allowlist individual values, because the set changes with Claude Code releases. When the developer authenticates with a claude.ai login, which is possible when `ANTHROPIC_BASE_URL` is set without a gateway credential variable, this header also carries an OAuth capability that the upstream requires, and stripping it fails those requests with `401` +`x-claude-code-session-id`| A unique identifier for the current Claude Code session. Use it to aggregate all requests from one session without parsing request bodies +`x-claude-code-agent-id`| Identifier of the [subagent](</docs/en/sub-agents>) that issued the request, present only on requests from an agent Claude Code spawned inside the session. Use it with the session ID to attribute cost to parallel agents +`x-claude-code-parent-agent-id`| Identifier of the agent that spawned the requesting agent, present only for nested agents + +Subagent IDs are generated fresh for each spawn. Teammate agents, the named members of an [agent team](</docs/en/agent-teams>), reuse a stable name-based ID across reconnections. In both cases the ID identifies an agent, not a person or a device, so do not treat the agent ID header as a user identifier. If your developers set `ANTHROPIC_CUSTOM_HEADERS`, those headers appear on requests as well. + +### + +​ + +Forward as open lists + +Treat the headers and body fields as open lists, not closed ones. Claude Code gains capabilities over releases, and they arrive as new `anthropic-beta` values, new request body fields, and occasionally new `anthropic-*` or `x-claude-code-*` headers. When forwarding to an Anthropic-format upstream, pass `anthropic-*` request headers and request body fields through unchanged rather than allowlisting the ones you see today. A gateway pinned to an observed list strips the next capability’s header or field and breaks it on the release that introduces it. The exception is a non-Anthropic upstream such as Bedrock or Vertex, where bridging the schema difference is the gateway’s job; see feature pass-through. + +## + +​ + +System prompt attribution block + +Claude Code prepends a short attribution block to the system prompt containing the client version and a fingerprint derived from the conversation. The `api.anthropic.com` endpoint strips the block before processing, so it does not affect first-party prompt caching; any other upstream receives it as part of the prompt. Anthropic and the cloud providers’ Claude endpoints read it for attribution, so to omit it set [`CLAUDE_CODE_ATTRIBUTION_HEADER=0`](</docs/en/env-vars>) rather than stripping it in the gateway. From Claude Code v2.1.181, the block is stable for the lifetime of a conversation when requests route through a custom base URL, so a gateway-side prompt cache keyed on the full request body works without disabling it. Before v2.1.181 the block included a per-request token; on those versions, set `CLAUDE_CODE_ATTRIBUTION_HEADER=0` if your gateway implements such a cache. + +## + +​ + +Feature pass-through + +Claude Code treats an `ANTHROPIC_BASE_URL` gateway as an Anthropic-format endpoint and sends it the beta headers and request body fields it sends to `api.anthropic.com`, except a small set of diagnostics and defaults reserved for direct connections. Capabilities that add body fields pair them with a beta header, and the pair travels together. A gateway that strips the header while passing the body, or forwards an Anthropic-format body to an upstream with a different schema, produces hard `400` errors; only when both halves are absent together does the feature turn off quietly. A gateway that rewrites or redacts request bodies for content inspection breaks the pairing the same way stripping does, so inspect without modifying. The table notes where a feature deviates from the pairing. Fine-grained tool streaming is one of the direct-connection defaults: it is off by default whenever requests route through a custom base URL, and a gateway receives it when developers set [`CLAUDE_CODE_ENABLE_FINE_GRAINED_TOOL_STREAMING=1`](</docs/en/env-vars>). + +Feature| Header and body pair| Symptom when broken| Remediation +---|---|---|--- +[Adaptive reasoning](</docs/en/model-config#adjust-effort-level>)| No beta header. Claude Code sends `thinking: {"type": "adaptive"}` for Claude 4.6 and later, and treats model names it doesn’t recognize, such as gateway aliases, as current models that receive the field| `400` naming the `thinking` field or the `adaptive` tag when the upstream model build doesn’t accept it| Upgrade the upstream. On Opus 4.6 and Sonnet 4.6, developers can set `CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING=1` instead +[Context management](<https://platform.claude.com/docs/en/build-with-claude/context-management>)| Context management beta header pairs with the `context_management` body field| `400` with `Extra inputs are not permitted`. Common when a gateway accepts Anthropic-format requests but forwards them to Bedrock| Forward both, or [`CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1`](</docs/en/env-vars>) +[Extended context](<https://platform.claude.com/docs/en/build-with-claude/context-windows#1m-token-context-window>) and [interleaved thinking](<https://platform.claude.com/docs/en/build-with-claude/extended-thinking#interleaved-thinking>)| Beta headers only, no body field| Silently unavailable when the header is stripped; the upstream never sees the capability request| Forward `anthropic-beta` verbatim +Beta [tool fields](<https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview>)| Tool-related beta headers pair with tool schema fields such as `strict` and `defer_loading`| `400` naming the unrecognized tool schema field when the body passes through without its header| Forward both, or `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1` +[Effort](<https://platform.claude.com/docs/en/build-with-claude/effort>) and [structured outputs](<https://platform.claude.com/docs/en/build-with-claude/structured-outputs>)| The `output_config` body field carries effort, structured-output format, and task budget settings; each pairs with its own beta header| `400` naming `output_config`, often `Extra inputs are not permitted`, on Bedrock and Vertex upstreams| Forward the field and its headers together +[Token counting](<https://platform.claude.com/docs/en/build-with-claude/token-counting>)| No beta pairing; uses the `count_tokens` endpoint| Claude Code falls back to estimating context usage locally| Expose the endpoint if you want exact counts + +The `ANTHROPIC_DEFAULT_*_MODEL_SUPPORTED_CAPABILITIES` [variables](</docs/en/model-config>) declare model capabilities only in the provider configurations: `CLAUDE_CODE_USE_BEDROCK`, `CLAUDE_CODE_USE_VERTEX`, `CLAUDE_CODE_USE_FOUNDRY`, and [`CLAUDE_CODE_USE_MANTLE`](</docs/en/amazon-bedrock#use-the-mantle-endpoint>). They have no effect behind an `ANTHROPIC_BASE_URL` gateway. + +### + +​ + +Automatic retry and error forwarding + +Claude Code retries automatically after some upstream rejections and disables the rejected capability for the rest of the conversation. Rejections of the `thinking` field, of [thinking signatures](<https://platform.claude.com/docs/en/build-with-claude/extended-thinking>), and of mid-conversation system messages all recover this way. Context management and tool schema field rejections do not retry; those `400` errors reach the developer. The retry logic matches on the upstream’s error wording, so forward error response bodies unmodified. A gateway that wraps upstream errors in its own envelope breaks the recovery path even when it preserves the status code. + +### + +​ + +Disable pre-release capabilities + +`CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1` stops Claude Code from sending pre-release capabilities and their body fields on every provider, including context management and the beta tool fields. It does not affect adaptive reasoning, which is selected by model rather than by beta, and it never suppresses the OAuth capability that subscription authentication requires. The set of capabilities Claude Code sends grows over releases. For current beta header strings, see the [beta headers reference](<https://platform.claude.com/docs/en/api/beta-headers>); test your gateway against new Claude Code releases rather than pinning to an observed list. + +## + +​ + +Model discovery + +When `ANTHROPIC_BASE_URL` points at a gateway that exposes the Anthropic Messages format, Claude Code can query the gateway’s `/v1/models` endpoint at startup and add the returned models to the `/model` picker. Developers enable it by setting [`CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1`](</docs/en/env-vars>), in their own environment or through managed settings. Discovery is off by default so that gateways backed by a shared API key do not surface every model the key can access to every user. This requires Claude Code v2.1.129 or later. + +### + +​ + +When discovery runs + +Discovery applies only to the Anthropic Messages format. It does not run when: + + * Any `CLAUDE_CODE_USE_*` provider variable is set, even if `ANTHROPIC_BASE_URL` is also set + * `ANTHROPIC_BASE_URL` is unset or points at `api.anthropic.com` + * Nonessential traffic is disabled, through [`CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`](</docs/en/env-vars>) or organization policy + +### + +​ + +Request and response + +The request is `GET /v1/models?limit=1000` with a 3-second timeout, and any redirect is treated as failure so the credential cannot leak to a redirect target. A gateway that responds slowly or redirects `/v1/models`, even `http` to `https`, fails discovery silently; serve the endpoint directly at the configured base URL. The discovery request sends exactly one credential header: + + * `ANTHROPIC_AUTH_TOKEN` as a bearer token, when set + * Otherwise the resolved API key, including an [`apiKeyHelper`](</docs/en/llm-gateway-connect#rotate-credentials-with-apikeyhelper>) value, in the `x-api-key` header + +This differs from inference requests, which send a helper value in both headers. A gateway that authenticates `/v1/models` must accept `x-api-key` for helper deployments. Any headers from `ANTHROPIC_CUSTOM_HEADERS` are included as well. Claude Code reads `id` and the optional `display_name` from each entry in the response’s `data` array, and ignores entries whose `id` doesn’t begin with `claude` or `anthropic`: + + { + "data": [ + { "id": "claude-sonnet-4-6", "display_name": "Claude Sonnet 4.6" }, + { "id": "claude-opus-4-7" } + ] + } + +### + +​ + +Picker entries and caching + +The picker is the interactive model list that opens when a developer runs `/model` in Claude Code. Each discovered entry is labeled “From gateway” and uses `display_name` when provided. A discovered ID is skipped only when it exactly matches a row already in the picker, or when both the discovered and existing IDs resolve to [Fable](</docs/en/model-config#work-with-fable-5>). Built-in rows are keyed on aliases such as `sonnet`, so a discovered ID such as `claude-sonnet-4-6` adds its own “From gateway” row alongside the built-in entry. The [`availableModels` managed setting](</docs/en/settings#available-settings>) bounds what discovery can add. Results are cached to `~/.claude/cache/gateway-models.json`, or `%USERPROFILE%\.claude\cache\gateway-models.json` on Windows, and refreshed on each startup. If the request fails or the gateway does not implement `/v1/models`, the picker falls back to the cached list from the previous startup or to the built-in model list. If your gateway serves Claude models under aliases that don’t match the discovery filter, developers can add those aliases manually with the [model configuration](</docs/en/model-config>) variables. + +## + +​ + +Related resources + +For the rest of the gateway documentation set and the underlying API references: + + * [LLM gateways overview](</docs/en/llm-gateway>): what a gateway is and how it interacts with claude.ai subscriptions + * [Roll out an LLM gateway for your organization](</docs/en/llm-gateway-rollout>): the admin checklist that uses this contract + * [Connect Claude Code to an LLM gateway](</docs/en/llm-gateway-connect>): per-developer configuration and the troubleshooting table + * [Beta headers reference](<https://platform.claude.com/docs/en/api/beta-headers>): the current set of `anthropic-beta` values + * [Messages API](<https://platform.claude.com/docs/en/api/messages>): the API format an Anthropic-format gateway implements
added Roll out an LLM gateway for your organization View current →
Show diff (267 lines)
--- a/llm-gateway-rollout.md +++ b/llm-gateway-rollout.md @@ -0,0 +1,264 @@ +This page walks an administrator through rolling out an LLM gateway for Claude Code. It assumes you have a gateway product deployed that meets the gateway requirements. Deploying or operating any specific product isn’t covered here; deploy yours following its vendor’s documentation. + + * To connect Claude Code on your own machine to an existing gateway, see [Connect Claude Code to an LLM gateway](</docs/en/llm-gateway-connect>) + * For what Claude Code sends to a gateway and what to forward, see the [gateway protocol reference](</docs/en/llm-gateway-protocol>) + +## + +​ + +Prerequisites + +To complete the rollout, you’ll need: + + * A gateway deployed on your infrastructure, serving HTTPS at the exact address you’ll distribute to developers, not an address that redirects to it, and configured to route Claude model names to your provider + * A provider credential for the gateway to forward with: + * For the Anthropic API: an API key from the [Claude Console](<https://platform.claude.com/settings/keys>) + * For a cloud provider: cloud credentials with model access. See the prerequisites on the [Amazon Bedrock](</docs/en/amazon-bedrock#prerequisites>), [Google Vertex AI](</docs/en/google-vertex-ai#prerequisites>), or [Microsoft Foundry](</docs/en/microsoft-foundry#prerequisites>) page + * A way to deliver settings files to developer machines, such as MDM or configuration management + * If you don’t have one yet, [how settings reach devices](</docs/en/admin-setup#decide-how-settings-reach-devices>) compares the options + +### + +​ + +Gateway requirements + +Whichever product provides the gateway, it must: + + * **Accept a supported API format** : one of the formats in the [API formats table](</docs/en/llm-gateway-protocol#api-formats>). The rollout steps below assume the Anthropic Messages API at `POST /v1/messages`, which most gateways serve + * **Stream responses** : pass server-sent events through as they arrive instead of buffering the whole response + * **Route Claude model names** : map each name developers use to an upstream model. Claude Code sends a model name such as `claude-sonnet-4-6` in each request; in most gateway products the mapping is a model list or routing table in the gateway’s own configuration + * **Forward headers and body unchanged** : pass `anthropic-beta`, `anthropic-version`, and the request body through in both directions; the [feature pass-through table](</docs/en/llm-gateway-protocol#feature-pass-through>) maps each to the feature that breaks without it + * **Return upstream errors unmodified** : Claude Code’s automatic recovery matches on error wording, so wrapping errors in the gateway’s own envelope breaks it + * **Exempt the path from request-body WAF inspection** : Claude Code prompts carry source code and XML-style tags that match cross-site-scripting body rules; a WAF in front of the gateway returns `403` on real sessions while short test requests pass + +Optionally, serve `GET /v1/models` so Claude Code can populate the model picker from your gateway with [model discovery](</docs/en/llm-gateway-protocol#model-discovery>). + +## + +​ + +Rollout steps + +The rollout takes five steps, each with a checkpoint: + + 1. Confirm the gateway routes your models + 2. Issue each developer a credential + 3. Test Claude Code against the gateway + 4. Distribute the base URL and credentials + 5. Verify from a developer machine + +The steps involve three different credentials, and the checkpoints name them by placeholder so you can tell which one is at fault when something fails: + +Credential| Who holds it| Placeholder in checkpoints +---|---|--- +Provider credential| The gateway, which forwards it to the upstream provider| Configured on the gateway; never appears in client commands +Gateway administrative credential| You, if your gateway product issues one for its admin or test interface| `<gateway-key>` +Developer key| Each developer, issued by the gateway in Issue developer credentials| `<developer-key>` + +### + +​ + +Confirm the gateway routes your models + +Your gateway should already be configured with your provider credential, listening at its base URL, and forwarding requests to your provider’s API. Test that the path works end to end with a minimal request, substituting two values from your deployment: + + * `<gateway-key>` is whatever credential lets you call the gateway right now: an administrative key, a test key, or your own developer key if you’ve already issued one. Not every gateway product has a separate admin credential; if yours doesn’t, issue yourself a developer key in Issue developer credentials first + * `model` is a Claude model name your gateway is configured to route. The example uses `claude-sonnet-4-6`; substitute a name you’ve configured + + * Bash or Zsh + + * PowerShell + + curl -X POST "https://llm-gateway.example.com/v1/messages" \ + -H "Authorization: Bearer <gateway-key>" \ + -H "anthropic-version: 2023-06-01" \ + -H "content-type: application/json" \ + -d '{"model": "claude-sonnet-4-6", "max_tokens": 1, "messages": [{"role": "user", "content": "."}]}' + + Invoke-RestMethod -Method Post -Uri "https://llm-gateway.example.com/v1/messages" ` + -Headers @{ "Authorization" = "Bearer <gateway-key>"; "anthropic-version" = "2023-06-01" } ` + -ContentType "application/json" ` + -Body '{"model": "claude-sonnet-4-6", "max_tokens": 1, "messages": [{"role": "user", "content": "."}]}' + +**Checkpoint** : a `200` with a `content` field means the gateway reached the provider with that model name. A `404` means that name isn’t routed at the gateway; a `401` from the provider means the gateway’s provider credential is wrong. Repeat the request once per Claude model name in your gateway’s routing configuration. A name the gateway doesn’t route returns `404` to any developer who selects it, so test every name before rollout. + +Avoid serving the gateway behind a redirect. A redirect can drop the request body or strip the credential header on inference requests, and [model discovery](</docs/en/llm-gateway-protocol#model-discovery>) treats any redirect as a failure so the credential cannot leak to a redirect target. + +### + +​ + +Issue developer credentials + +Each developer needs their own gateway key to authenticate. Create a credential per developer at the gateway, following your product’s credential management documentation. Confirm a freshly issued key works against the gateway with the same request as Confirm the gateway routes your models, replacing `<gateway-key>` with the new `<developer-key>`: + + * Bash or Zsh + + * PowerShell + + curl -X POST "https://llm-gateway.example.com/v1/messages" \ + -H "Authorization: Bearer <developer-key>" \ + -H "anthropic-version: 2023-06-01" \ + -H "content-type: application/json" \ + -d '{"model": "claude-sonnet-4-6", "max_tokens": 1, "messages": [{"role": "user", "content": "."}]}' + + Invoke-RestMethod -Method Post -Uri "https://llm-gateway.example.com/v1/messages" ` + -Headers @{ "Authorization" = "Bearer <developer-key>"; "anthropic-version" = "2023-06-01" } ` + -ContentType "application/json" ` + -Body '{"model": "claude-sonnet-4-6", "max_tokens": 1, "messages": [{"role": "user", "content": "."}]}' + +**Checkpoint** : a `200` with a `content` field means the developer key reaches the gateway and the gateway forwards it. A `401` here, when the previous step succeeded, means the developer key is wrong or hasn’t taken effect at the gateway yet. Issuing one key per developer rather than a shared key is what makes per-developer usage attribution and individual offboarding work. The environment variable that holds the key depends on which header the gateway reads. For a gateway that checks credentials in the `Authorization: Bearer` header, developers set their key in `ANTHROPIC_AUTH_TOKEN`. For a gateway that reads keys from the `x-api-key` header, developers set `ANTHROPIC_API_KEY` instead; the [credential table](</docs/en/llm-gateway-connect#set-the-credential-variable>) covers the mapping. + +### + +​ + +Test Claude Code against the gateway + +Run Claude Code through the gateway yourself before distributing anything, using the same configuration the rollout will deliver fleet-wide. Type these directly in a terminal, not in a `.env` or settings file; they last only for this terminal session, so closing it returns your machine to its normal configuration. Use `ANTHROPIC_API_KEY` instead of `ANTHROPIC_AUTH_TOKEN` if your gateway reads the `x-api-key` header: + + * Bash or Zsh + + * PowerShell + + export ANTHROPIC_BASE_URL=https://llm-gateway.example.com + export ANTHROPIC_AUTH_TOKEN="<developer-key>" + + $env:ANTHROPIC_BASE_URL = "https://llm-gateway.example.com" + $env:ANTHROPIC_AUTH_TOKEN = "<developer-key>" + +Then send a one-shot prompt through the gateway: + + claude -p "Reply with one word: connected" + +**Checkpoint** : the prompt returns a response, and the request appears in the gateway’s log as a `POST` to the `/v1/messages` path with status `200`. Claude Code appends a query string such as `?beta=true`, so match on the path, not the full URL. Two failure messages point in different directions: + + * `Not logged in`: check the gateway log to tell the two causes apart. If it’s empty, no credential reached the session and no request left the machine; re-run the exports in the shell you’re testing from. If it shows a rejected request with `x-api-key` in the `401` body, the gateway expects keys in that header instead; switch to `ANTHROPIC_API_KEY` + * `Failed to authenticate. API Error: 401` means a credential was sent and rejected, and the gateway log says where: a `401` naming `api.anthropic.com` or your provider’s endpoint means the gateway reached the upstream but its provider credential was rejected, so the developer key worked and the provider credential the gateway holds is wrong or a placeholder + +A wrong or unreachable base URL produces a different symptom: Claude Code [retries the connection with backoff](</docs/en/errors#automatic-retries>) and can sit with no output for several minutes before reporting an error. If the command appears to hang, check the gateway log instead of waiting; no arriving request means `ANTHROPIC_BASE_URL` doesn’t point at the gateway. + +### + +​ + +Distribute the configuration + +Every developer machine needs the gateway address and a credential. You can distribute them centrally through [managed settings](</docs/en/settings#settings-files>), so developers configure nothing, or hand developers the values to set themselves. + +#### + +​ + +What to distribute + +The same set of variables applies whichever path you choose. Most rollouts only need `ANTHROPIC_BASE_URL` and a credential; include the conditional rows when your gateway setup calls for them. + +Variable or setting| What it does| Include when +---|---|--- +`ANTHROPIC_BASE_URL`| Sends Claude Code’s API requests to the gateway instead of `api.anthropic.com`| Always +`apiKeyHelper`, or a credential in `ANTHROPIC_AUTH_TOKEN` or `ANTHROPIC_API_KEY`| Authenticates each request to the gateway. The helper runs a command to fetch the key; the variables hold a static key, sent as `Authorization: Bearer` and `x-api-key` respectively| Always; one of the three +`ANTHROPIC_CUSTOM_HEADERS`| Adds extra HTTP headers to every API request| Your gateway requires a tenant or routing header on every request +`CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY`| Queries the gateway’s `/v1/models` at startup and adds the returned names to the `/model` picker| Your gateway serves `/v1/models` and you want developers’ pickers populated from it +`CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS`| Stops Claude Code sending pre-release capability headers and body fields| Your gateway forwards to a Bedrock or Vertex upstream that rejects beta fields; see Gateway requirements +`ANTHROPIC_MODEL` or [`ANTHROPIC_DEFAULT_HAIKU_MODEL`](</docs/en/model-config>)| Set which model name Claude Code requests for the main session and for background traffic| Your gateway routes model names that don’t match Claude Code’s defaults, or you route [background functionality](</docs/en/costs#background-token-usage>) to a different model. Route both the override names and Claude Code’s default names at the gateway, since some sub-calls can request the default name regardless of the override +`ANTHROPIC_BEDROCK_BASE_URL`, `ANTHROPIC_VERTEX_BASE_URL`, `ANTHROPIC_FOUNDRY_BASE_URL`, or `ANTHROPIC_AWS_BASE_URL` with the [variables for that provider](</docs/en/llm-gateway-connect#route-to-a-cloud-provider-through-a-gateway>)| Point Claude Code at the gateway through a provider-specific base URL. Bedrock and Vertex also switch to those providers’ native request format| Your gateway fronts Bedrock, Vertex, Foundry, or the Claude Platform on AWS; see [API formats](</docs/en/llm-gateway-protocol#api-formats>) + +#### + +​ + +Distribute through managed settings + +Deliver the variables through the `env` block of a [managed settings file](</docs/en/settings#settings-files>), pushed by MDM, registry policy, or configuration management: + + { + "env": { + "ANTHROPIC_BASE_URL": "https://llm-gateway.example.com" + }, + "apiKeyHelper": "/usr/local/bin/get-gateway-key" + } + +Add the conditional variables from the table to the same `env` block. A managed `ANTHROPIC_BASE_URL` is enforced and cannot be overridden by a developer’s shell export, since Claude Code applies it over the process environment and lower-precedence settings. Do not include `forceLoginMethod` or `forceLoginOrgUUID` in managed settings alongside a gateway credential. On Claude Code v2.1.146 and later, either key blocks `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, and `apiKeyHelper` at startup, so developers see `This machine's managed settings require a first-party login` and cannot proceed. [Server-managed settings](</docs/en/server-managed-settings#platform-availability>) delivery requires a direct connection to `api.anthropic.com`, so it does not reach gateway-routed sessions. Gateway deployments use this file-based managed settings path, which enforces the same keys. For the credential, distribute one [`apiKeyHelper`](</docs/en/llm-gateway-connect#rotate-credentials-with-apikeyhelper>) command in the managed settings file as shown above; the command authenticates to your secrets store as the local developer, so each machine receives its own key. Alternatively, deliver each developer their key through your existing secrets process and have them set `ANTHROPIC_AUTH_TOKEN` themselves. Some environments need separate delivery: + + * The desktop app reads gateway routing only from its MDM-delivered third-party inference configuration; deploy that file alongside managed settings so desktop sessions route through the gateway too. See the [desktop third-party configuration docs](<https://claude.com/docs/cowork/3p/configuration>) and the [desktop gateway docs](<https://claude.com/docs/cowork/3p/gateway>) + * CI runners need `ANTHROPIC_BASE_URL` and the credential set in the [runner’s environment](</docs/en/llm-gateway-connect#configure-each-surface>) + * WSL on managed Windows machines reads the Windows managed settings only when [`wslInheritsWindowsSettings`](</docs/en/settings#available-settings>) is `true` + +#### + +​ + +Hand developers the values to set themselves + +If you don’t have managed-settings distribution in place, send each developer what they need to follow the [connect page](</docs/en/llm-gateway-connect#configure-claude-code-yourself>): + + * The gateway URL + * Their personal credential + * **Which variable to put the credential in** : `ANTHROPIC_AUTH_TOKEN` for a bearer-token gateway, or `ANTHROPIC_API_KEY` for an `x-api-key` gateway. Telling developers which one saves them the trial-and-error described on the [connect page](</docs/en/llm-gateway-connect#set-the-credential-variable>) + * Any conditional variables from the What to distribute table, with their values + +The [connect page](</docs/en/llm-gateway-connect#configure-claude-code-yourself>) walks developers through setting each one. **Checkpoint** : on a developer machine, `claude` starts a session without showing the login screen, since the distributed credential satisfies authentication. Then run `/status` and open the **Status** tab: the `Anthropic base URL` line shows the gateway address, and for managed distribution the `Setting sources` line includes managed settings. A login screen, or a missing `Anthropic base URL` line, means the configuration didn’t reach the machine. + +### + +​ + +Verify the rollout + +Confirm everything works from a developer machine, not the gateway host, so the test covers the network path developers use. Send a streaming request, which checks the endpoint, streaming pass-through, and model routing at once: + + * Bash or Zsh + + * PowerShell + + curl -N -X POST "https://llm-gateway.example.com/v1/messages" \ + -H "Authorization: Bearer <developer-key>" \ + -H "anthropic-version: 2023-06-01" \ + -H "content-type: application/json" \ + -d '{"model": "claude-sonnet-4-6", "max_tokens": 16, "stream": true, "messages": [{"role": "user", "content": "count to 3"}]}' + + $body = '{"model": "claude-sonnet-4-6", "max_tokens": 16, "stream": true, "messages": [{"role": "user", "content": "count to 3"}]}' + $body | curl.exe -N -X POST "https://llm-gateway.example.com/v1/messages" ` + -H "Authorization: Bearer <developer-key>" ` + -H "anthropic-version: 2023-06-01" ` + -H "content-type: application/json" ` + --data-binary '@-' + +You should see `data:` lines arrive incrementally. The whole response arriving at once after a pause means the gateway is buffering, which stalls Claude Code; a `404` means the model name isn’t routed. Repeat per model name. Then start `claude` and send a message. Each symptom at this step has one cause: + + * A login prompt means a credential gap. Run `/status` and open the **Status** tab: when the `Setting sources` line doesn’t include managed settings, the distribution didn’t reach the machine; when it does, the developer credential wasn’t delivered, so set `ANTHROPIC_AUTH_TOKEN` or the `apiKeyHelper` + * `Failed to authenticate` errors mean the gateway is rejecting requests; its log says which credential failed. A rejection the gateway logs itself names the developer key, while a `401` from `api.anthropic.com` or your provider’s endpoint means the provider credential the gateway holds was rejected + * A one-time approval prompt for the key is expected on first use when the gateway expects keys in the `x-api-key` header, set as `ANTHROPIC_API_KEY`. With `ANTHROPIC_AUTH_TOKEN`, no prompt appears and the variable takes over silently; a previously saved claude.ai login is inactive for that session + +Finally, check the gateway’s logs for the message you sent: the credential identifies the developer, and the [`x-claude-code-session-id` header](</docs/en/llm-gateway-protocol#request-headers>) groups requests by session. If features fail with the [troubleshooting symptoms](</docs/en/llm-gateway-connect#troubleshoot-gateway-errors>), the gateway is stripping headers or rewriting errors; see the gateway requirements above. + +## + +​ + +Maintain the gateway + +After rollout, three kinds of change reach the gateway over time. Each has a symptom to watch for and an action to take. + +Change| Symptom when the gateway hasn’t kept up| Action +---|---|--- +New Claude Code releases add `anthropic-beta` values and request body fields| Developers report `400` errors naming a new field after they update Claude Code; see [feature pass-through](</docs/en/llm-gateway-protocol#feature-pass-through>)| Forward `anthropic-*` headers and request bodies verbatim rather than allowlisting; test new Claude Code releases against the gateway before they reach developers +New Claude models become available| Developers selecting a new model name get `404`; the `/model` picker doesn’t list it| Add the model name to the gateway’s routing configuration, then re-run the routing check. If you distribute `ANTHROPIC_MODEL` or the default-model variables, update the managed settings +Credentials expire or need rotation| All developer requests start failing with `401` from the upstream| Rotate the gateway’s provider credential on its own schedule; developer keys rotate at the gateway, and an [`apiKeyHelper`](</docs/en/llm-gateway-connect#rotate-credentials-with-apikeyhelper>) handles per-developer rotation without redistributing settings + +When sizing per-key rate limits, account for the client [retrying transient failures](</docs/en/errors#automatic-retries>), including `429` responses, up to 10 times with backoff, honoring `Retry-After`. Keep the [protocol reference](</docs/en/llm-gateway-protocol>) as the contract for what each Claude Code release sends. + +## + +​ + +Related resources + + * [Connect Claude Code to an LLM gateway](</docs/en/llm-gateway-connect>): the developer-facing setup steps, with per-surface configuration and a troubleshooting table you can hand to developers + * [Gateway protocol reference](</docs/en/llm-gateway-protocol>): the wire contract for gateway operators, covering endpoints, headers to forward, and the feature pass-through table + * [Settings files and precedence](</docs/en/settings#settings-files>): how managed, project, and user settings combine, and where the managed file goes on each platform + * [Set up Claude Code for your organization](</docs/en/admin-setup>): the wider rollout this gateway is one part of, including policy enforcement, usage visibility, and data handling
modified Connect Claude Code to tools via MCP View current →
--- a/mcp.md +++ b/mcp.md @@ -162,7 +162,7 @@ Automatic reconnection -If an HTTP or SSE server disconnects mid-session, Claude Code automatically reconnects with exponential backoff: up to five attempts, starting at a one-second delay and doubling each time. The server appears as pending in `/mcp` while reconnection is in progress. After five failed attempts the server is marked as failed and you can retry manually from `/mcp`. Stdio servers are local processes and are not reconnected automatically. The same backoff applies when an HTTP or SSE server fails its initial connection at startup. As of v2.1.121, Claude Code retries the initial connection up to three times on transient errors such as a 5xx response, a connection refused, or a timeout, then marks the server as failed if it still cannot connect. Authentication and not-found errors are not retried because they require a configuration change to resolve. +If an HTTP or SSE server disconnects mid-session, Claude Code automatically reconnects with exponential backoff: up to five attempts, starting at a one-second delay and doubling each time. The server appears as pending in `/mcp` while reconnection is in progress. After five failed attempts the server is marked as failed and you can retry manually from `/mcp`. Stdio servers are local processes and are not reconnected automatically. The same backoff applies when an HTTP or SSE server fails its initial connection at startup. As of v2.1.121, Claude Code retries the initial connection up to three times on transient errors such as a 5xx response, a connection refused, or a timeout, then marks the server as failed if it still cannot connect. Authentication and not-found errors are not retried because they require a configuration change to resolve. As of v2.1.191, the capability discovery requests that run after a successful connection, such as `tools/list`, `prompts/list`, and `resources/list`, also retry transient network and server errors up to three times with short backoff. Authentication errors, 4xx responses, and request timeouts are not retried. ### @@ -184,7 +184,7 @@ * Claude Code will display a warning when MCP tool output exceeds 10,000 tokens. To increase this limit, set the `MAX_MCP_OUTPUT_TOKENS` environment variable (for example, `MAX_MCP_OUTPUT_TOKENS=50000`) * Use `/mcp` to authenticate with remote servers that require OAuth 2.0 authentication -The per-server `timeout` is a hard wall-clock limit per tool call, and progress notifications from the server do not extend it. Values below 1000 are ignored and fall through to `MCP_TOOL_TIMEOUT`, or to its default of about 28 hours when that variable is unset. Before v2.1.162, values below 1000 were floored to one second instead. For HTTP and SSE servers, the per-request fetch first-byte budget has a 60-second minimum. +The per-server `timeout` is a hard wall-clock limit per tool call, and progress notifications from the server do not extend it. Values below 1000 are ignored and fall through to `MCP_TOOL_TIMEOUT`, or to its default of about 28 hours when that variable is unset. Before v2.1.162, values below 1000 were floored to one second instead. For HTTP and SSE servers, the per-request fetch first-byte budget has a 60-second minimum. As of v2.1.187, a tool call to a remote HTTP, SSE, WebSocket, or claude.ai connector server that sends no response and no progress notification for 5 minutes aborts with an error instead of waiting for the wall-clock limit. Set the [`CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT`](</docs/en/env-vars>) environment variable in milliseconds to change the idle window, or set it to `0` to disable the check. Stdio servers are local processes and are not subject to the idle timeout. ### @@ -487,7 +487,7 @@ claude mcp login sentry -To clear stored credentials later, run `claude mcp logout <name>`. When you’re connected over SSH, add `--no-browser` so the command prints the authorization URL instead of opening a browser. Open the URL on your local machine, then paste the full redirect URL from your browser’s address bar back at the prompt. The command needs an interactive terminal for the paste step, so connect with `ssh -t`. +To clear stored credentials later, run `claude mcp logout <name>`. As of v2.1.191, the command detects when no local browser is available, such as during an SSH session or on Linux without a display server, and prints the authorization URL instead of trying to open a browser. Open the URL on your local machine, then paste the full redirect URL from your browser’s address bar back at the prompt. The command needs an interactive terminal for the paste step, so connect with `ssh -t`. Pass `--no-browser` to force the URL prompt even when a local browser is detected. claude mcp login sentry --no-browser
modified Model configuration View current →
Show diff (186 lines)
--- a/model-config.md +++ b/model-config.md @@ -13,7 +13,7 @@ * Foundry: a deployment name * Vertex: a version name -`ANTHROPIC_BASE_URL` changes where requests are sent, not which model answers them. To route Claude through an LLM gateway, see [LLM gateway configuration](</docs/en/llm-gateway>). +`ANTHROPIC_BASE_URL` changes where requests are sent, not which model answers them. To route Claude through an LLM gateway, see [LLM gateways](</docs/en/llm-gateway>). ### @@ -72,7 +72,7 @@ * `Enter`: switch model and save as your default * `s`: switch model for this session only -Typing `/model <name>` directly behaves like `Enter`. Project and managed settings still take precedence and reapply on the next launch. In v2.1.144 through v2.1.152, `/model` applied to the current session only and `d` in the picker saved a default. The `--model` flag and `ANTHROPIC_MODEL` environment variable apply only to the session you launch with them. To run different models in different terminals at the same time, launch each one with its own `--model` flag rather than switching with `/model`. Resumed sessions started with `claude --resume`, `--continue`, or the `/resume` picker keep the model they were using when the transcript was saved, regardless of the current `model` setting. If that model has been retired, the session falls through to the normal precedence order. This prevents another session’s `/model` choice from changing the model on resume. When the active model at startup comes from project or managed settings rather than your own selection, the startup header shows which settings file set it. Run `/model` to override; the project or managed setting reapplies on the next launch. When the requested model has a scheduled retirement date or is automatically remapped to a newer version, Claude Code shows a warning that names the requested model. Interactive sessions show it as a startup notice. From v2.1.182, the same warning is written to stderr in [non-interactive mode](</docs/en/headless>) when using the default text output format. The check also covers a `model` set in [subagent frontmatter](</docs/en/sub-agents>). The stderr warning is suppressed for `--output-format json` and `stream-json`; read the actual model from the `modelUsage` field of the [result message](</docs/en/headless#get-structured-output>) instead. Example usage: +Typing `/model <name>` directly behaves like `Enter`. Project and managed settings still take precedence and reapply on the next launch. In v2.1.144 through v2.1.152, `/model` applied to the current session only and `d` in the picker saved a default. The `--model` flag and `ANTHROPIC_MODEL` environment variable apply only to the session you launch with them. To run different models in different terminals at the same time, launch each one with its own `--model` flag rather than switching with `/model`. Resumed sessions started with `claude --resume`, `--continue`, or the `/resume` picker keep the model they were using when the transcript was saved, regardless of the current `model` setting. If that model has been retired or is excluded by `availableModels`, the session falls through to the normal precedence order. This prevents another session’s `/model` choice from changing the model on resume. When the active model at startup comes from project or managed settings rather than your own selection, the startup header shows which settings file set it. Run `/model` to override; the project or managed setting reapplies on the next launch. When the requested model has a scheduled retirement date or is automatically remapped to a newer version, Claude Code shows a warning that names the requested model. Interactive sessions show it as a startup notice. From v2.1.182, the same warning is written to stderr in [non-interactive mode](</docs/en/headless>) when using the default text output format. The check also covers a `model` set in [subagent frontmatter](</docs/en/sub-agents>). The stderr warning is suppressed for `--output-format json` and `stream-json`; read the actual model from the `modelUsage` field of the [result message](</docs/en/headless#get-structured-output>) instead. Example usage: # Start with Opus claude --model opus @@ -95,16 +95,17 @@ Restrict model selection -Enterprise administrators can use `availableModels` in [managed or policy settings](</docs/en/settings#settings-files>) to restrict which models users can select. When `availableModels` is set, the allowlist applies everywhere a user can specify a model: - - * **Main session model** : `/model`, the `--model` flag, and the `ANTHROPIC_MODEL` environment variable +Enterprise administrators can use `availableModels` in [managed or policy settings](</docs/en/settings#settings-files>) to restrict which models users can select. Entries match a model family such as `sonnet`, a version prefix such as `claude-sonnet-4-5`, or a full model ID such as `claude-sonnet-4-5-20250929`. When `availableModels` is set, the allowlist applies everywhere a user can specify a model: + + * **Main session model** : `/model`, the `--model` flag, the `ANTHROPIC_MODEL` environment variable, the `model` setting, and the model restored when resuming a session * **Alias resolution** : the `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, `ANTHROPIC_DEFAULT_HAIKU_MODEL`, and `ANTHROPIC_DEFAULT_FABLE_MODEL` environment variables cannot redirect an allowed alias to a model outside the list * **Fast mode** : `/fast` refuses to toggle when it would implicitly switch to an Opus model outside the list, with the message “is not in your organization’s allowed models” * **Subagent models** : the `model` field in [subagent](</docs/en/sub-agents#choose-a-model>) frontmatter, the Agent tool’s `model` parameter, the model picker in `/agents`, and `CLAUDE_CODE_SUBAGENT_MODEL` - * **Advisor model** : the configured [`advisorModel`](</docs/en/advisor>) setting - * **Fallback chains** : elements of a fallback model chain outside the list are dropped - -Switching to a blocked model with `/model` is rejected with an error, while a blocked `--model` flag or `ANTHROPIC_MODEL` value is replaced at startup with a warning naming both the requested and substituted models, and the session starts on the default model. A blocked subagent or advisor override falls back to the inherited or default model rather than failing the request. + * **Skill and command models** : the `model` frontmatter in [skills and commands](</docs/en/skills>) + * **Advisor model** : the configured [`advisorModel`](</docs/en/advisor>) setting and the `--advisor` flag + * **Background agent model** : the model selected in the [dispatch picker](</docs/en/agent-view>) + +Switching to a blocked model with `/model` is rejected with an error, while a blocked `--model` flag, `ANTHROPIC_MODEL`, or `model` setting value is replaced at startup with a warning naming both the requested and substituted models, and the session starts on the default model. A blocked subagent, skill, or command override falls back to the inherited or default model rather than failing the request; a blocked `advisorModel` setting disables the advisor for the session, while a blocked `--advisor` flag value exits with an error at launch. Excluded models are hidden from the `/model` picker. Automatic model changes are checked the same way: elements of a fallback model chain outside the allowlist are dropped, a plan-mode upgrade such as `opusplan` to an excluded model is skipped so planning continues on the session’s model, and an automatic model fallback whose target is excluded does not run, so the flagged request ends with a refusal instead. Enabling [fast mode](</docs/en/fast-mode>) is refused when the model the session would run on afterward is outside the allowlist. { "availableModels": ["sonnet", "haiku"] @@ -114,9 +115,44 @@ ​ +Surface coverage + +Every surface enforces the allowlist it receives. Which delivery mechanism reaches each surface differs: + +Delivery mechanism| CLI and IDE| Desktop local sessions| Web, mobile, and cloud sessions| Agent SDK and non-interactive| Cowork +---|---|---|---|---|--- +[Server-managed settings](</docs/en/server-managed-settings>) from the admin console| Enforced| Enforced| Enforced| Enforced| Not delivered +[MDM or managed settings files](</docs/en/settings#settings-files>)| Enforced| Enforced| Not delivered| Enforced| Enforced where deployed + + * Cloud sessions, on [Claude Code on the web](</docs/en/claude-code-on-the-web>) or in the Desktop app, run on Anthropic-managed VMs: settings deployed to your device do not reach them, so deliver the allowlist through server-managed settings. A mid-session model switch in a cloud session is rejected when the requested model is excluded by the allowlist. Server-side rejection at session creation applies to organization model restrictions, not the `availableModels` settings key. + * Cowork, the agentic-work tab in the Claude Desktop app, is not a Claude Code surface and does not receive server-managed settings by design. A managed settings file applies to Cowork sessions when it is present where the session runs; remote Cowork sessions run on Anthropic-managed VMs, where a device-deployed file is not present. + * Sessions on [third-party providers](</docs/en/server-managed-settings#platform-availability>) such as Bedrock, Vertex AI, Foundry, and [Claude Platform on AWS](</docs/en/claude-platform-on-aws>) do not receive server-managed settings, so deliver the allowlist through MDM or managed settings files there. + * Server-managed delivery also requires the session to authenticate with an organization login or a directly configured API key. Fleets that generate keys only through an [`apiKeyHelper`](</docs/en/settings#available-settings>) script should deliver the allowlist through MDM or managed settings files. + * The Desktop Code tab also hosts [SSH sessions](</docs/en/desktop#ssh-sessions>), which read the managed settings file from the remote host they run on. See [Desktop managed settings](</docs/en/desktop#managed-settings>). + * The model pickers on claude.ai and in the Desktop app hide or grey out models excluded by your organization’s allowlist. The picker state is a convenience for users; enforcement happens in the session. + +### + +​ + Default model behavior -By default, the Default option in the model picker is not affected by `availableModels`. It remains available and represents the system’s runtime default based on the user’s subscription tier. To extend the allowlist to the Default option, set `enforceAvailableModels` to `true` in managed or policy settings alongside a non-empty `availableModels` list. When the tier default is not in the allowlist, Default resolves to the first allowed entry instead of the tier default. This requires Claude Code v2.1.175 or later. An empty `availableModels` array never engages enforcement. Even with `availableModels: []`, users can still use Claude Code with the Default model for their tier regardless of `enforceAvailableModels`. +The Default option in the model picker is not affected by `availableModels` unless `enforceAvailableModels` is also set. On its own, `availableModels` leaves Default available, resolving to the system’s runtime default based on the user’s subscription tier. If the tier default is a model you intend to restrict, set `enforceAvailableModels` as well. An empty `availableModels` array never engages the Default-model enforcement: with `availableModels: []`, named model selections are blocked but the Default model for the account type remains usable regardless of `enforceAvailableModels`. + +### + +​ + +Enforce the allowlist for the Default model + +Set `enforceAvailableModels: true` alongside a non-empty `availableModels` in managed settings to extend the allowlist to the Default option. This requires Claude Code v2.1.175 or later. + + { + "availableModels": ["sonnet", "haiku"], + "enforceAvailableModels": true + } + +When the default model for the user’s account type is not in the allowlist, the Default option instead resolves to the first `availableModels` entry that names an allowed, available model, and the `/model` picker’s Default row shows that model. This applies everywhere the default is reached: session startup, selecting Default in `/model`, the `"default"` keyword in fallback model chains, and the fallback used when an excluded selection is dropped. `enforceAvailableModels` has no effect when `availableModels` is unset or empty: with `availableModels: []`, the Default model for the account type remains usable, so the setting cannot lock users out of every model. When `availableModels` is non-empty but no entry resolves to an allowed and available model, enforcement is skipped and Default resolves to the account-type default, with a warning visible only under `--debug`. Keep at least one guaranteed-available entry in the list to avoid this. Deploy both keys in the [highest-precedence managed source](</docs/en/settings#settings-precedence>): admin-deployed managed sources do not merge, so a pair placed in a managed settings file is ignored when the admin console delivers any settings. ### @@ -124,7 +160,7 @@ Control the model users run on -The `model` setting is an initial selection, not enforcement. It sets which model is active when a session starts, but users can still open `/model` and pick Default, which resolves to the system default for their tier regardless of what `model` is set to. To fully control the model experience, combine these settings: +The `model` setting is an initial selection, not enforcement. It sets which model is active when a session starts, but users can still open `/model` and pick Default, which resolves to the system default for their tier regardless of what `model` is set to, unless `enforceAvailableModels` redirects it. To fully control the model experience, combine these settings: * **`availableModels`** : restricts which named models users can switch to * **`enforceAvailableModels`** : extends the `availableModels` allowlist to the Default option, so Default cannot resolve to a model outside the list @@ -150,7 +186,7 @@ Merge behavior -When `availableModels` is set in user, project, and local settings only, arrays are merged and deduplicated across those levels. When `availableModels` is set in managed or policy settings, the managed or policy value replaces the merged result entirely: entries added in user or project settings cannot widen it. Managed and policy settings replace lower-precedence values for `enforceAvailableModels` the same way. As of Claude Code v2.1.175, this is the only way to enforce a strict allowlist; earlier versions merge the managed list with lower-precedence entries. +When the [highest-precedence managed settings source](</docs/en/server-managed-settings#settings-precedence>) defines `availableModels`, that list alone applies: entries in user, project, or local settings cannot extend it, and admin-deployed managed sources do not merge with each other, so a list deployed in a managed settings file is ignored when server-managed settings deliver any keys. Otherwise, lists from user, project, and local settings are [concatenated and deduplicated](</docs/en/settings#settings-precedence>) like other array settings. As of Claude Code v2.1.175, the managed list replaces lower-precedence entries; earlier versions merge them. Within the effective list, an entry naming a specific model in a family, whether a version prefix or a full model ID, disables that family’s wildcard entry: `["sonnet", "claude-sonnet-4-5"]` allows only Sonnet 4.5 versions, not every Sonnet model. ### @@ -158,7 +194,15 @@ Mantle model IDs -When the [Bedrock Mantle endpoint](</docs/en/amazon-bedrock#use-the-mantle-endpoint>) is enabled, entries in `availableModels` that start with `anthropic.` are added to the `/model` picker as custom options and routed to the Mantle endpoint. The setting still restricts the picker to listed entries, so include the standard aliases alongside any Mantle IDs. +When the [Bedrock Mantle endpoint](</docs/en/amazon-bedrock#use-the-mantle-endpoint>) is enabled, entries in `availableModels` that start with `anthropic.` are added to the `/model` picker as custom options and routed to the Mantle endpoint. This is an exception to the alias matching described in Pin models for third-party deployments. The setting still restricts the picker to listed entries, and a Mantle ID embeds a family name, so it counts as a specific entry and disables that family’s wildcard: alongside any Mantle IDs, list the version prefixes or full IDs you want to keep selectable. See Merge behavior. + +### + +​ + +Organization model restrictions + +Use the Console toggle instead of `availableModels` when your members authenticate through the Anthropic API and you want one org-wide switch without deploying settings files. Organization admins restrict which models members can run by disabling individual models in the Claude Console. This restriction is delivered with the account’s entitlements when Claude Code authenticates, separate from any `availableModels` list in settings, and the server enforces the same restriction independently when a session is created. Requires Claude Code v2.1.187 or later. A restricted model is hidden from the `/model` picker. Selecting it by name with `--model`, the `ANTHROPIC_MODEL` environment variable, or the `model` setting shows the notice `Model "<name>" is restricted by your organization's settings. Using <model> instead.` and the session starts on an allowed model. Typing `/model <name>` for a restricted model is rejected with `Model '<name>' is restricted by your organization's settings. Run /model to choose a different model.` and the session keeps its current model. Both restrictions apply together: a model is selectable only when it is permitted by `availableModels` and not restricted by the organization. Organization restrictions are delivered to sessions on the Anthropic API and [LLM gateway](</docs/en/llm-gateway>) deployments. Sessions on Bedrock, Vertex AI, Foundry, and Claude Platform on AWS do not receive them, so use `availableModels` on those providers instead. ## @@ -179,7 +223,7 @@ * **Pro, Team Standard, and Enterprise subscription seats** : defaults to Sonnet 4.6 * **Bedrock, Vertex, and Foundry** : defaults to Sonnet 4.5 -Enterprise pay-as-you-go means an Enterprise organization billed by usage rather than by subscription seat. Fable 5 is not the default model on any account type. Sessions use Fable 5 only after you choose it, with `/model fable`, a `model` setting, or the `best` alias where Fable 5 is available. Choosing it with `/model` saves it as the selected model in your user settings, so later sessions start on Fable 5 until you change models. +Enterprise pay-as-you-go means an Enterprise organization billed by usage rather than by subscription seat. When managed settings enforce the allowlist for the Default model and the account-type default is not in `availableModels`, `default` resolves to the enforced Default instead of the account-type default above. Fable 5 is not the default model on any account type. Sessions use Fable 5 only after you choose it, with `/model fable`, a `model` setting, or the `best` alias where Fable 5 is available. Choosing it with `/model` saves it as the selected model in your user settings, so later sessions start on Fable 5 until you change models. ### @@ -221,7 +265,7 @@ Automatic model fallback -This section covers content-based fallback from Fable 5. For availability-based fallback when a model is overloaded or unavailable, see Fallback model chains. Fable 5 runs with safety classifiers for cybersecurity and biology content. When a classifier flags a request, Claude Code re-runs that request on the default Opus model and shows a notice in the transcript: Opus 4.8 on the Anthropic API and [LLM gateway](</docs/en/llm-gateway>) deployments, or Opus 4.7 on [Claude Platform on AWS](</docs/en/claude-platform-on-aws>). The session then continues on that Opus model. To return to Fable 5, run `/model fable`. +This section covers content-based fallback from Fable 5. For availability-based fallback when a model is overloaded or unavailable, see Fallback model chains. Fable 5 runs with safety classifiers for cybersecurity and biology content. When a classifier flags a request, Claude Code re-runs that request on the default Opus model and shows a notice in the transcript: Opus 4.8 on the Anthropic API and [LLM gateway](</docs/en/llm-gateway>) deployments, or Opus 4.7 on [Claude Platform on AWS](</docs/en/claude-platform-on-aws>). The session then continues on that Opus model. To return to Fable 5, run `/model fable`. The fallback target is checked against `availableModels`. When it is blocked, no fallback occurs. The refusal is shown as a normal error and the session’s model is unchanged. #### @@ -242,6 +286,7 @@ * If both models flag the same request, you can edit the prompt and retry, or start a new session. * On mobile [Claude Code on the web](</docs/en/claude-code-on-the-web>) sessions, editing and retrying is not supported. Switch models, or continue the session from a desktop browser or the desktop app. * In [non-interactive mode](</docs/en/cli-reference#cli-flags>) and SDK integrations that can’t show the prompt, a flagged request ends the turn with a refusal instead. + * When the fallback target is blocked by `availableModels`, the prompt is not shown. The flagged request ends with the refusal, the same as automatic fallback when the target is blocked. #### @@ -388,13 +433,13 @@ Add a custom model option -Use `ANTHROPIC_CUSTOM_MODEL_OPTION` to add a single custom entry to the `/model` picker without replacing the built-in aliases. This is useful for testing model IDs that Claude Code does not list by default. For LLM gateway deployments, Claude Code can populate the picker from the gateway’s `/v1/models` endpoint when `CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1` is set, so this variable is needed only when discovery is disabled or does not return the model you want. See [LLM gateway model selection](</docs/en/llm-gateway#model-selection>). This example sets all three variables to make a gateway-routed Opus deployment selectable: +Use `ANTHROPIC_CUSTOM_MODEL_OPTION` to add a single custom entry to the `/model` picker without replacing the built-in aliases. This is useful for testing model IDs that Claude Code does not list by default. For LLM gateway deployments, Claude Code can populate the picker from the gateway’s `/v1/models` endpoint when `CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1` is set, so this variable is needed only when discovery is disabled or does not return the model you want. See [gateway model discovery](</docs/en/llm-gateway-protocol#model-discovery>). This example sets all three variables to make a gateway-routed Opus deployment selectable: export ANTHROPIC_CUSTOM_MODEL_OPTION="my-gateway/claude-opus-4-7" export ANTHROPIC_CUSTOM_MODEL_OPTION_NAME="Opus via Gateway" export ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION="Custom deployment routed through the internal LLM gateway" -The custom entry appears at the bottom of the `/model` picker. `ANTHROPIC_CUSTOM_MODEL_OPTION_NAME` and `ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION` are optional. If omitted, the model ID is used as the name and the description defaults to `Custom model (<model-id>)`. Claude Code skips validation for the model ID set in `ANTHROPIC_CUSTOM_MODEL_OPTION`, so you can use any string your API endpoint accepts. +The custom entry appears at the bottom of the `/model` picker. `ANTHROPIC_CUSTOM_MODEL_OPTION_NAME` and `ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION` are optional. If omitted, the model ID is used as the name and the description defaults to `Custom model (<model-id>)`. Claude Code skips validation for the model ID set in `ANTHROPIC_CUSTOM_MODEL_OPTION`, so you can use any string your API endpoint accepts. When `availableModels` is set, include the custom model ID in the allowlist as well: the custom entry is filtered from the picker and a `--model` selection of it is rejected like any other excluded model. A custom ID that embeds a family name, such as `my-gateway/claude-opus-4-7`, counts as a specific entry for that family and disables its wildcard, so also list the versions you intend to keep selectable. See Merge behavior. ## @@ -442,7 +487,7 @@ * Only append `[1m]` when the underlying model [supports 1M context](<https://platform.claude.com/docs/en/build-with-claude/context-windows#1m-token-context-window>). * The suffix is read per variable, not per model. On Bedrock, Vertex, and Foundry, a model ID without `[1m]` in one variable uses 200K context even if another variable sets the same model with the suffix. -The `settings.availableModels` allowlist still applies when using third-party providers. Filtering matches on the model alias such as `opus`, the version prefix such as `claude-opus-4-8`, or the full model ID. Any `[1m]` suffix is stripped from both the allowlist entry and the requested model before matching, so an entry of `claude-opus-4-8` permits both the standard and 1M-context Opus rows. Provider-specific prefixes such as `us.anthropic.` are not stripped: list the same form in `availableModels` that the picker shows, or map it through `modelOverrides`. +An `availableModels` allowlist delivered through [MDM or a managed settings file](</docs/en/settings#settings-files>) still applies when using third-party providers; [server-managed settings are not delivered there](</docs/en/server-managed-settings#platform-availability>). Filtering matches on a model alias such as `opus`, a version prefix such as `claude-opus-4-8`, or the full provider-form model ID. Provider-specific prefixes such as `us.anthropic.` are not stripped, so to allow a specific model, list the same provider-form ID the picker shows, or map it through `modelOverrides`. Any `[1m]` suffix is stripped from both the allowlist entry and the requested model before matching. ### @@ -492,7 +537,7 @@ } } -Keys must be Anthropic model IDs as listed in the [Models overview](<https://platform.claude.com/docs/en/about-claude/models/overview>). For dated model IDs, include the date suffix exactly as it appears there. Unknown keys are ignored. Overrides replace the built-in model IDs that back each entry in the `/model` picker. On Bedrock, overrides take precedence over any inference profiles that Claude Code discovers automatically at startup. Values you supply directly through `ANTHROPIC_MODEL`, `--model`, or the `ANTHROPIC_DEFAULT_*_MODEL` environment variables are passed to the provider as-is and are not transformed by `modelOverrides`. `modelOverrides` works alongside `availableModels`. The allowlist is evaluated against the Anthropic model ID, not the override value, so an entry like `"opus"` in `availableModels` continues to match even when Opus versions are mapped to ARNs. +Keys must be Anthropic model IDs as listed in the [Models overview](<https://platform.claude.com/docs/en/about-claude/models/overview>). For dated model IDs, include the date suffix exactly as it appears there. Unknown keys are ignored. Overrides replace the built-in model IDs that back each entry in the `/model` picker. On Bedrock, overrides take precedence over any inference profiles that Claude Code discovers automatically at startup. Values you supply directly through `ANTHROPIC_MODEL`, `--model`, or the `ANTHROPIC_DEFAULT_*_MODEL` environment variables are passed to the provider as-is and are not transformed by `modelOverrides`. `modelOverrides` works alongside `availableModels`. The allowlist is evaluated against the Anthropic model ID, not the override value, so an entry like `"opus"` in `availableModels` continues to match even when Opus versions are mapped to ARNs. When `enforceAvailableModels` is set in managed settings, the enforced Default resolves through `modelOverrides` from the [highest-precedence managed source](</docs/en/server-managed-settings#settings-precedence>) only. An admin’s mapping, such as a version pinned to an inference profile ARN, is honored in the enforced Default. Overrides from user or project settings do not affect it. ###
modified Monitoring View current →
--- a/monitoring-usage.md +++ b/monitoring-usage.md @@ -1108,7 +1108,7 @@ Detect retry exhaustion -Claude Code retries failed API requests internally and emits a single `claude_code.api_error` event only after it gives up, so the event itself is the terminal signal for that request. Intermediate retry attempts are not logged as separate events. The `attempt` attribute on the event records how many attempts were made in total. A value greater than `CLAUDE_CODE_MAX_RETRIES` (default `10`, capped at `15`) indicates the request exhausted all retries on a transient error. A lower value indicates a non-retryable error such as a `400` response. To distinguish a session that recovered from one that stalled, group events by `session.id` and check whether a later `api_request` event exists after the error. +Claude Code retries failed API requests internally and emits a single `claude_code.api_error` event only after it gives up, so the event itself is the terminal signal for that request. Intermediate retry attempts are not logged as separate events. The `attempt` attribute on the event records how many attempts were made in total. `CLAUDE_CODE_MAX_RETRIES` defaults to 10 and is capped at 15. When the request exhausts all retries on a transient error, `attempt` equals one more than that effective limit: 11 by default, and never more than 16. A lower value indicates a non-retryable error such as a `400` response. To distinguish a session that recovered from one that stalled, group events by `session.id` and check whether a later `api_request` event exists after the error. ###
modified Choose a permission mode View current →
--- a/permission-modes.md +++ b/permission-modes.md @@ -138,13 +138,13 @@ ​ -Eliminate prompts with auto mode +Eliminate permission prompts with auto mode Auto mode requires Claude Code v2.1.83 or later. Auto mode lets Claude execute without routine permission prompts. A separate classifier model reviews actions before they run, blocking anything that escalates beyond your request, targets unrecognized infrastructure, or appears driven by hostile content Claude read. Explicit [ask rules](</docs/en/permissions#manage-permissions>) still force a prompt. Auto mode also nudges Claude to keep working without stopping for clarifying questions, though Claude still asks when your prompt or a skill explicitly relies on it. For stronger autonomous behavior while keeping permission prompts, set the [Proactive output style](</docs/en/output-styles>) instead. -Auto mode is a research preview. It reduces prompts but does not guarantee safety. Use it for tasks where you trust the general direction, not as a replacement for review on sensitive operations. +Auto mode is a research preview. It reduces permission prompts but does not guarantee safety. Use it for tasks where you trust the general direction, not as a replacement for review on sensitive operations. Auto mode is available only when your account meets all of these requirements: @@ -275,7 +275,7 @@ The check is skipped automatically inside a recognized sandbox. To run autonomously in a container, use the [dev container](</docs/en/devcontainer>) configuration, which runs Claude Code as a non-root user. [Claude Code on the web](</docs/en/claude-code-on-the-web>) does not honor `defaultMode: "bypassPermissions"` or `"dontAsk"` from your settings files, so a repository’s checked-in settings cannot start a cloud session in bypass-permissions mode. The setting is ignored silently and the session starts in the mode shown in the mode dropdown instead. See Switch permission modes for which modes cloud sessions offer. -`bypassPermissions` offers no protection against prompt injection or unintended actions. For background safety checks with far fewer prompts, use auto mode instead. Administrators can block this mode by setting `permissions.disableBypassPermissionsMode` to `"disable"` in [managed settings](</docs/en/permissions#managed-settings>). +`bypassPermissions` offers no protection against prompt injection or unintended actions. For background safety checks with far fewer permission prompts, use auto mode instead. Administrators can block this mode by setting `permissions.disableBypassPermissionsMode` to `"disable"` in [managed settings](</docs/en/permissions#managed-settings>). ##
modified Agent SDK reference - Python View current →
--- a/python.md +++ b/python.md @@ -944,7 +944,7 @@ `agents`| `dict[str, AgentDefinition] | None`| `None`| Programmatically defined subagents `plugins`| `list[SdkPluginConfig]`| `[]`| Load custom plugins from local paths. See [Plugins](</docs/en/agent-sdk/plugins>) for details `sandbox`| `SandboxSettings` ` | None`| `None`| Configure sandbox behavior programmatically. See Sandbox settings for details -`setting_sources`| `list[SettingSource] | None`| `None` (CLI defaults: all sources)| Control which filesystem settings to load. Pass `[]` to disable user, project, and local settings. Managed policy settings load regardless. See [Use Claude Code features](</docs/en/agent-sdk/claude-code-features#what-settingsources-does-not-control>) +`setting_sources`| `list[SettingSource] | None`| `None` (CLI defaults: all sources)| Control which filesystem settings to load. Pass `[]` to disable user, project, and local settings. Endpoint-managed policy loads regardless; server-managed settings are fetched when the session authenticates with an organization credential on an [eligible configuration](</docs/en/server-managed-settings#platform-availability>). See [Use Claude Code features](</docs/en/agent-sdk/claude-code-features#what-settingsources-does-not-control>) `skills`| `list[str] | Literal["all"] | None`| `None`| Skills available to the session. Pass `"all"` to enable every discovered skill, or a list of skill names. When set, the SDK adds the Skill tool to `allowed_tools` automatically. If you also pass `tools`, include `"Skill"` in that list. See [Skills](</docs/en/agent-sdk/skills>) `max_thinking_tokens`| `int | None`| `None`| _Deprecated_ \- Maximum tokens for thinking blocks. Use `thinking` instead `thinking`| `ThinkingConfig` ` | None`| `None`| Controls extended thinking behavior. Takes precedence over `max_thinking_tokens` @@ -1035,7 +1035,7 @@ Default behavior -When `setting_sources` is omitted or `None`, `query()` loads the same filesystem settings as the Claude Code CLI: user, project, and local. Managed policy settings are loaded in all cases. See [What settingSources does not control](</docs/en/agent-sdk/claude-code-features#what-settingsources-does-not-control>) for inputs that are read regardless of this option, and how to disable them. +When `setting_sources` is omitted or `None`, `query()` loads the same filesystem settings as the Claude Code CLI: user, project, and local. Endpoint-managed policy is loaded in all cases; server-managed settings are fetched when the session authenticates with an organization credential on an [eligible configuration](</docs/en/server-managed-settings#platform-availability>). See [What settingSources does not control](</docs/en/agent-sdk/claude-code-features#what-settingsources-does-not-control>) for inputs that are read regardless of this option, and how to disable them. ####
modified Configure the sandboxed Bash tool View current →
--- a/sandboxing.md +++ b/sandboxing.md @@ -148,6 +148,32 @@ The `.` in `allowRead` resolves to the project root because this configuration lives in project settings. If you placed the same configuration in `~/.claude/settings.json`, `.` would resolve to `~/.claude` instead, and project files would remain blocked by the `denyRead` rule. +### + +​ + +Protect credentials + +The `sandbox.credentials` setting declares credential files and environment variables that sandboxed commands must not access. Listed file paths are denied for reads inside the sandbox, the same restriction that `filesystem.denyRead` applies, and listed environment variables are unset before each sandboxed command runs. The dedicated `credentials` block keeps credential rules grouped with the environment variables to unset and separate from general filesystem rules. Requires Claude Code v2.1.187 or later. The example below blocks reads of the AWS credentials file and the SSH directory and removes `GITHUB_TOKEN` and `NPM_TOKEN` from the environment of sandboxed commands: + + { + "sandbox": { + "enabled": true, + "credentials": { + "files": [ + { "path": "~/.aws/credentials", "mode": "deny" }, + { "path": "~/.ssh", "mode": "deny" } + ], + "envVars": [ + { "name": "GITHUB_TOKEN", "mode": "deny" }, + { "name": "NPM_TOKEN", "mode": "deny" } + ] + } + } + } + +Each entry carries `"mode": "deny"`, which is the only supported value. The explicit `mode` field keeps the schema forward-compatible with future modes. File paths follow the same [prefix rules](</docs/en/settings#sandbox-path-prefixes>) as `sandbox.filesystem.*` settings, and entries from every [settings scope](</docs/en/settings#settings-precedence>) are merged. Because the only mode is `deny`, any scope can add restrictions but none can remove them. There is no built-in credential deny list, so only the files and variables you list are restricted. The setting affects sandboxed Bash commands only. To strip Anthropic and cloud provider credentials from all subprocesses regardless of sandboxing, set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>). + ## ​ @@ -163,7 +189,7 @@ The sandboxed Bash tool restricts file system access to specific directories: * **Default write behavior** : read and write access to the current working directory and its subdirectories, plus the session temp directory that `$TMPDIR` points to - * **Default read behavior** : read access to the entire computer, except certain denied directories. Note that this default still allows reading credential files such as `~/.aws/credentials` and `~/.ssh/`. Add them to `denyRead` to block them. + * **Default read behavior** : read access to the entire computer, except certain denied directories. Note that this default still allows reading credential files such as `~/.aws/credentials` and `~/.ssh/`. Use `sandbox.credentials` to block reads of these files and unset secret environment variables, or add the paths to `denyRead`. * **Blocked access** : cannot modify files outside the current working directory and session temp directory without explicit permission, including shell configuration files such as `~/.bashrc` and system binaries in `/bin/` * **Git worktrees** : when the working directory is a [linked git worktree](</docs/en/worktrees>), the sandbox also allows writes to the main repository’s shared `.git` directory so commands such as `git commit` can update refs and the index. Writes to `hooks/` and `config` inside that directory remain denied. * **Configurable** : define custom allowed and denied paths through settings @@ -178,7 +204,7 @@ Network access is controlled through a proxy server running outside the sandbox: - * **Domain restrictions** : no domains are pre-allowed. The first time a command needs a new domain, Claude Code prompts for approval. Pre-allow domains with [`allowedDomains`](</docs/en/settings#sandbox-settings>) to avoid the prompt. + * **Domain restrictions** : no domains are pre-allowed. The first time a command needs a new domain, Claude Code prompts for approval. As of v2.1.191, choosing Yes allows the host for the rest of the current session, so later connections to the same host do not prompt again. Pre-allow domains with [`allowedDomains`](</docs/en/settings#sandbox-settings>) to avoid the prompt entirely. * **Managed lockdown** : if [`allowManagedDomainsOnly`](</docs/en/settings#sandbox-settings>) is set in managed settings, non-allowed domains are blocked automatically instead of prompting, and only `allowedDomains` from managed settings are honored. * **Custom proxy support** : advanced users can implement custom rules on outgoing traffic * **Comprehensive coverage** : restrictions apply to all scripts, programs, and subprocesses spawned by commands @@ -278,7 +304,7 @@ * **`failIfUnavailable`** : a missing dependency such as bubblewrap on Linux blocks Claude Code from starting rather than showing a warning and falling back to unsandboxed execution * **`allowUnsandboxedCommands: false`** : the `dangerouslyDisableSandbox` escape hatch is ignored, so commands that fail under the sandbox cannot be retried outside it -Two additions are worth considering alongside them. Add `excludedCommands` for any organization-approved tools that must run without isolation. Add `denyRead` entries for credential directories such as `~/.aws` and `~/.ssh`, which the default read policy still allows. The sandbox does not run on native Windows, so if your fleet includes Windows hosts, scope this configuration to macOS and Linux or have those users run Claude Code inside WSL2 or a container. +Two additions are worth considering alongside them. Add `excludedCommands` for any organization-approved tools that must run without isolation. Add `sandbox.credentials` entries for credential directories such as `~/.aws` and `~/.ssh` and for secret environment variables, since the default read policy still allows them. The sandbox does not run on native Windows, so if your fleet includes Windows hosts, scope this configuration to macOS and Linux or have those users run Claude Code inside WSL2 or a container. ### @@ -373,7 +399,7 @@ * **Built-in file tools** : Read, Edit, and Write use the permission system directly rather than running through the sandbox. See [permissions](</docs/en/permissions>). * **Computer use** : when Claude opens apps and controls your screen, it runs on your actual desktop rather than in an isolated environment. Per-app permission prompts gate each application. See [computer use in the CLI](</docs/en/computer-use>) or [computer use in Desktop](</docs/en/desktop#let-claude-use-your-computer>). - * **Environment variables** : sandboxed Bash commands inherit the parent process environment by default, including any credentials set there. To strip Anthropic and cloud provider credentials from subprocesses, set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>). + * **Environment variables** : sandboxed Bash commands inherit the parent process environment by default, including any credentials set there. Use `sandbox.credentials` to unset specific variables for sandboxed commands, or set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>) to strip Anthropic and cloud provider credentials from all subprocesses. * **Subagents** : [subagents](</docs/en/sub-agents>) run in the same process as the parent session and use the same sandbox configuration. Bash commands inside a subagent are sandboxed when sandboxing is enabled in the parent session. Effective sandboxing requires both filesystem and network isolation. Without network isolation, a compromised agent could exfiltrate sensitive files like SSH keys. Without filesystem isolation, a compromised agent could backdoor system resources to gain network access. When you widen the defaults, check that an `allowWrite` path, a broad `allowedDomains` entry, or an `excludedCommands` exception does not undo a restriction on the other side.
modified Configure server-managed settings View current →
--- a/server-managed-settings.md +++ b/server-managed-settings.md @@ -1,4 +1,4 @@ -Server-managed settings allow administrators to centrally configure Claude Code through a web-based interface on Claude.ai. Claude Code clients automatically receive these settings when users authenticate with their organization credentials. This approach is designed for organizations that do not have device management infrastructure in place, or need to manage settings for users on unmanaged devices. +Server-managed settings allow administrators to centrally configure Claude Code through a web-based interface on Claude.ai. Claude Code clients automatically receive these settings when users authenticate with an organization OAuth login or a directly configured API key, on platforms where server-managed delivery is supported. See Platform availability. This approach is designed for organizations that do not have device management infrastructure in place, or need to manage settings for users on unmanaged devices. Server-managed settings are available for [Claude for Teams](<https://claude.com/pricing?utm_source=claude_code&utm_medium=docs&utm_content=server_settings_teams#team-&-enterprise>) and [Claude for Enterprise](<https://anthropic.com/contact-sales?utm_source=claude_code&utm_medium=docs&utm_content=server_settings_enterprise>) customers. @@ -27,7 +27,7 @@ **Server-managed settings**| Organizations without MDM, or users on unmanaged devices| Settings delivered from Anthropic’s servers at authentication time **[Endpoint-managed settings](</docs/en/settings#settings-files>)**| Organizations with MDM or endpoint management| Settings deployed to devices via MDM configuration profiles, registry policies, or managed settings files -If your devices are enrolled in an MDM or endpoint management solution, endpoint-managed settings provide stronger security guarantees because the settings file can be protected from user modification at the OS level. +If your devices are enrolled in an MDM or endpoint management solution, endpoint-managed settings provide stronger security guarantees because the settings file can be protected from user modification at the OS level. Endpoint-managed settings do not reach [cloud sessions](</docs/en/model-config#surface-coverage>), so organizations using Claude Code on the web should configure server-managed settings as well. ## @@ -196,7 +196,7 @@ "forceRemoteSettingsRefresh": true } -Before enabling this setting, ensure your network policies allow connectivity to `api.anthropic.com`. If that endpoint is unreachable, the CLI exits at startup and users cannot start Claude Code. As of v2.1.139, the `claude auth` subcommands such as `claude auth login` are exempt from this check, so users can re-authenticate when expired credentials are the reason the settings fetch fails. +You can also set this key in an [endpoint-managed](</docs/en/settings#settings-files>) MDM profile or system `managed-settings.json` file to enforce fail-closed behavior on first launch, before any server payload has been delivered. As of v2.1.191, this flag is an exception to the precedence rule above: it is honored when set in any managed source even if a cached server-managed payload is also present, so an MDM-delivered value is not ignored when server-managed settings exist. The settings fetch also sends a `Cache-Control: no-cache` header so intermediate HTTP proxies do not serve a stale response. Before enabling this setting, ensure your network policies allow connectivity to `api.anthropic.com`. If that endpoint is unreachable, the CLI exits at startup and users cannot start Claude Code. As of v2.1.139, the `claude auth` subcommands such as `claude auth login` are exempt from this check, so users can re-authenticate when expired credentials are the reason the settings fetch fails. ### @@ -220,11 +220,12 @@ Platform availability -Server-managed settings require a direct connection to `api.anthropic.com` and are not available when using third-party model providers: +Server-managed settings require a direct connection to `api.anthropic.com`, and delivery requires the session to authenticate with an organization OAuth login or a directly configured API key: keys returned by an [`apiKeyHelper`](</docs/en/settings#available-settings>) script do not trigger the settings fetch. Server-managed settings are not available when using third-party model providers: * Amazon Bedrock * Google Vertex AI * Microsoft Foundry + * [Claude Platform on AWS](</docs/en/claude-platform-on-aws>) * Custom API endpoints via `ANTHROPIC_BASE_URL` or [LLM gateways](</docs/en/llm-gateway>) ## @@ -249,7 +250,7 @@ User deletes the cached settings file| First-launch behavior occurs: settings fetch asynchronously with a brief unenforced window API is unavailable| Cached settings apply if available, otherwise managed settings are not enforced until the next successful fetch. With `forceRemoteSettingsRefresh: true`, the CLI exits instead of continuing, except for `claude auth` subcommands User authenticates with a different organization| Settings are not delivered for accounts outside the managed organization -User configures a third-party model provider| Server-managed settings are bypassed. This includes setting `CLAUDE_CODE_USE_BEDROCK`, `CLAUDE_CODE_USE_MANTLE`, `CLAUDE_CODE_USE_VERTEX`, `CLAUDE_CODE_USE_FOUNDRY`, or a non-default `ANTHROPIC_BASE_URL` +User configures a third-party model provider| Server-managed settings are bypassed. This includes setting `CLAUDE_CODE_USE_BEDROCK`, `CLAUDE_CODE_USE_MANTLE`, `CLAUDE_CODE_USE_VERTEX`, `CLAUDE_CODE_USE_FOUNDRY`, `CLAUDE_CODE_USE_ANTHROPIC_AWS`, or a non-default `ANTHROPIC_BASE_URL` To detect runtime configuration changes, use [`ConfigChange` hooks](</docs/en/hooks#configchange>) to log modifications or block unauthorized changes before they take effect. For stronger enforcement guarantees, use [endpoint-managed settings](</docs/en/settings#settings-files>) on devices enrolled in an MDM solution.
modified Claude Code settings View current →
--- a/settings.md +++ b/settings.md @@ -16,7 +16,7 @@ Scope| Location| Who it affects| Shared with team? ---|---|---|--- -**Managed**| Server-managed settings, plist / registry, or system-level `managed-settings.json`| All users on the machine| Yes (deployed by IT) +**Managed**| Server-managed settings, plist / registry, or system-level `managed-settings.json`| All organization members for server-managed delivery; all users on the machine for plist, HKLM registry, and file delivery; the current user for HKCU registry delivery| Yes (deployed by IT) **User**| `~/.claude/` directory| You, across all projects| No **Project**| `.claude/` in repository| All collaborators on this repository| Yes (committed to git) **Local**| `.claude/settings.local.json`| You, in this repository only| No (gitignored when Claude Code creates it) @@ -178,6 +178,7 @@ `enforceAvailableModels`| Treated as `true`. Applies in v2.1.175 and later. `forceLoginOrgUUID`| No organization is permitted to log in until the value is fixed. `deniedMcpServers`| An individual invalid entry is stripped and the valid subset is enforced. A wholly invalid value is dropped with a warning, since denying every server would block servers the policy never named. +`sandbox.credentials`| An individual invalid entry in `files` or `envVars` is stripped with a warning and the valid subset is enforced. A wholly invalid `credentials` value is dropped with a warning while the rest of `sandbox` still applies. Applies in v2.1.191 and later. `requiredMinimumVersion` and `requiredMaximumVersion` fail open by design: an invalid value is stripped rather than enforced, so a bad policy push cannot prevent Claude Code from starting. Validation errors surface in three places: @@ -208,7 +209,7 @@ `allowManagedMcpServersOnly`| (Managed settings only) Only `allowedMcpServers` from managed settings are respected. `deniedMcpServers` still merges from all sources. Users can still add MCP servers, but only the admin-defined allowlist applies. See [Managed MCP configuration](</docs/en/managed-mcp>)| `true` `allowManagedPermissionRulesOnly`| (Managed settings only) Prevent user and project settings from defining `allow`, `ask`, or `deny` permission rules. Only rules in managed settings apply. See [Managed-only settings](</docs/en/permissions#managed-only-settings>)| `true` `alwaysThinkingEnabled`| Enable [extended thinking](</docs/en/model-config#extended-thinking>) by default for all sessions. Typically configured via the `/config` command rather than editing directly. To force thinking off regardless of this setting, set [`MAX_THINKING_TOKENS=0`](</docs/en/env-vars>) in `env`, which disables thinking on the Anthropic API except on Fable 5, which cannot have thinking turned off. On [third-party providers](</docs/en/third-party-integrations>) this omits the `thinking` parameter instead, and adaptive-reasoning models may still think| `true` -`apiKeyHelper`| Custom script, to be executed in `/bin/sh`, to generate an auth value. This value will be sent as `X-Api-Key` and `Authorization: Bearer` headers for model requests. Set the refresh interval with [`CLAUDE_CODE_API_KEY_HELPER_TTL_MS`](</docs/en/env-vars>)| `/bin/generate_temp_api_key.sh` +`apiKeyHelper`| Custom command, run through the system shell (`/bin/sh` on macOS and Linux, `cmd` on Windows), to generate an auth value. This value will be sent as `X-Api-Key` and `Authorization: Bearer` headers for model requests. Set the refresh interval with [`CLAUDE_CODE_API_KEY_HELPER_TTL_MS`](</docs/en/env-vars>)| `/bin/generate_temp_api_key.sh` `attribution`| Customize attribution for git commits and pull requests. See Attribution settings| `{"commit": "🤖 Generated with Claude Code", "pr": ""}` `autoCompactEnabled`| Automatically compact the conversation when context approaches the limit. Default: `true`. Appears in `/config` as **Auto-compact**. To disable via environment variable, set [`DISABLE_AUTO_COMPACT`](</docs/en/env-vars>) in `env`| `false` `autoMemoryDirectory`| Custom directory for [auto memory](</docs/en/memory#storage-location>) storage. Accepts an absolute path or a `~/`-prefixed path. From project or local settings, this is honored only after you accept the workspace trust dialog, since a cloned repository can supply this file| `"~/my-memory-dir"` @@ -216,7 +217,7 @@ `autoMode`| Customize what the [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) classifier blocks and allows. Contains `environment`, `allow`, `soft_deny`, and `hard_deny` arrays of prose rules. Include the literal string `"$defaults"` in an array to inherit the built-in rules at that position. See [Configure auto mode](</docs/en/auto-mode-config>). Not read from shared project settings| `{"soft_deny": ["$defaults", "Never run terraform apply"]}` `autoScrollEnabled`| In [fullscreen rendering](</docs/en/fullscreen>), follow new output to the bottom of the conversation. Default: `true`. Appears in `/config` as **Auto-scroll**. Permission prompts still scroll into view when this is off| `false` `autoUpdatesChannel`| Release channel to follow for updates. Use `"stable"` for a version that is typically about one week old and skips versions with major regressions, or `"latest"` (default) for the most recent release. To disable auto-updates entirely, set [`DISABLE_AUTOUPDATER`](</docs/en/setup#disable-auto-updates>) in `env`| `"stable"` -`availableModels`| Restrict which models users can select for the main session, [subagents](</docs/en/sub-agents>), and the [advisor](</docs/en/advisor>). See [Restrict model selection](</docs/en/model-config#restrict-model-selection>). See `enforceAvailableModels` to also constrain the default model| `["sonnet", "haiku"]` +`availableModels`| Restrict which models users can select for the main session, [subagents](</docs/en/sub-agents>), [skills](</docs/en/skills>), and the [advisor](</docs/en/advisor>). Does not affect the Default option unless `enforceAvailableModels` is also set. See [Restrict model selection](</docs/en/model-config#restrict-model-selection>)| `["sonnet", "haiku"]` `awaySummaryEnabled`| Show a one-line session recap when you return to the terminal after a few minutes away. Set to `false` or turn off Session recap in `/config` to disable. Same as [`CLAUDE_CODE_ENABLE_AWAY_SUMMARY`](</docs/en/env-vars>)| `true` `awsAuthRefresh`| Custom script that modifies the `.aws` directory (see [advanced credential configuration](</docs/en/amazon-bedrock#advanced-credential-configuration>))| `aws sso login --profile myprofile` `awsCredentialExport`| Custom script that outputs JSON with AWS credentials (see [advanced credential configuration](</docs/en/amazon-bedrock#advanced-credential-configuration>))| `/bin/generate_aws_grant.sh` @@ -244,7 +245,7 @@ `effortLevel`| Persist the [effort level](</docs/en/model-config#adjust-effort-level>) across sessions. Accepts `"low"`, `"medium"`, `"high"`, or `"xhigh"`. Written automatically when you run `/effort` with one of those values. `--effort` and [`CLAUDE_CODE_EFFORT_LEVEL`](</docs/en/env-vars>) override this for one session. See [Adjust effort level](</docs/en/model-config#adjust-effort-level>) for supported models| `"xhigh"` `enableAllProjectMcpServers`| Automatically approve all MCP servers defined in project `.mcp.json` files| `true` `enabledMcpjsonServers`| List of specific MCP servers from `.mcp.json` files to approve| `["memory", "github"]` -`enforceAvailableModels`| When `true` and `availableModels` is a non-empty list in managed or policy settings, the Default model is also constrained to the allowlist. See [Restrict model selection](</docs/en/model-config#restrict-model-selection>) for details and the [merge behavior](</docs/en/model-config#merge-behavior>) when `availableModels` is set at multiple levels. Requires Claude Code v2.1.175 or later| `true` +`enforceAvailableModels`| Extend the `availableModels` allowlist to the Default model. When `true` in managed settings and `availableModels` is a non-empty array, the Default option falls back to the first allowlisted entry that is available. Has no effect when `availableModels` is unset or empty. See [Enforce the allowlist for the Default model](</docs/en/model-config#enforce-the-allowlist-for-the-default-model>). Requires Claude Code v2.1.175 or later| `true` `env`| Environment variables applied to every session and to subprocesses Claude Code spawns from it. As of v2.1.143, `NO_COLOR` and `FORCE_COLOR` set here are passed to subprocesses but do not change Claude Code’s own interface colors. Set those in your shell before launching `claude` to change interface colors| `{"FOO": "bar"}` `fallbackModel`| Fallback model(s) to try in order when the primary model is overloaded or unavailable. Claude Code switches to the next available model in the chain for the rest of the turn and shows a notice. `"default"` expands to the default model. Chains are capped at three models; extra entries are ignored. Unlike most array settings, this key does not merge across settings files: the highest-precedence file that defines it supplies the entire chain. The [`--fallback-model`](</docs/en/cli-reference#cli-flags>) flag overrides this for one session. See [Fallback model chains](</docs/en/model-config#fallback-model-chains>)| `["claude-sonnet-4-6", "claude-haiku-4-5"]` `fastModePerSessionOptIn`| When `true`, fast mode does not persist across sessions. Each session starts with fast mode off, requiring users to enable it with `/fast`. The user’s fast mode preference is still saved. See [Require per-session opt-in](</docs/en/fast-mode#require-per-session-opt-in>)| `true` @@ -397,6 +398,8 @@ `filesystem.denyRead`| Paths where sandboxed commands cannot read. Arrays are merged across all settings scopes. Also merged with paths from `Read(...)` deny permission rules.| `["~/.aws/credentials"]` `filesystem.allowRead`| Paths to re-allow reading within `denyRead` regions. Takes precedence over `denyRead`. Arrays are merged across all settings scopes. Use this to create workspace-only read access patterns.| `["."]` `filesystem.allowManagedReadPathsOnly`| (Managed settings only) Only `filesystem.allowRead` paths from managed settings are respected. `denyRead` still merges from all sources. Default: false| `true` +`credentials.files`| Credential files or directories that sandboxed commands cannot read. Applies the same read block as `filesystem.denyRead`; the separate key keeps credential paths grouped with `credentials.envVars` and apart from general filesystem rules. Each entry is `{ "path": "...", "mode": "deny" }`. Paths use the same prefixes as `filesystem.*` settings. Arrays are merged across all settings scopes. Only `deny` is supported. Requires Claude Code v2.1.187 or later.| `[{ "path": "~/.aws/credentials", "mode": "deny" }]` +`credentials.envVars`| Environment variables to unset before running sandboxed commands. Each entry is `{ "name": "...", "mode": "deny" }`. Arrays are merged across all settings scopes. Only `deny` is supported. Requires Claude Code v2.1.187 or later.| `[{ "name": "GITHUB_TOKEN", "mode": "deny" }]` `network.allowUnixSockets`| (macOS only) Unix socket paths accessible in sandbox. Ignored on Linux and WSL2, where the seccomp filter cannot inspect socket paths; use `allowAllUnixSockets` instead.| `["~/.ssh/agent-socket"]` `network.allowAllUnixSockets`| Allow all Unix socket connections in sandbox. On Linux and WSL2 this is the only way to permit Unix sockets, since it skips the seccomp filter that otherwise blocks `socket(AF_UNIX, ...)` calls. Default: false| `true` `network.allowLocalBinding`| Allow binding to localhost ports (macOS only). Default: false| `true` @@ -418,7 +421,7 @@ Sandbox path prefixes -Paths in `filesystem.allowWrite`, `filesystem.denyWrite`, `filesystem.denyRead`, and `filesystem.allowRead` support these prefixes: +Paths in `filesystem.allowWrite`, `filesystem.denyWrite`, `filesystem.denyRead`, `filesystem.allowRead`, and `credentials.files` support these prefixes: Prefix| Meaning| Example ---|---|--- @@ -617,7 +620,7 @@ * Policies deployed by IT through server delivery, MDM configuration profiles, registry policies, or managed settings files * Cannot be overridden by any other level, including command line arguments * Within the managed tier, precedence is: server-managed > MDM/OS-level policies > file-based (`managed-settings.d/*.json` \+ `managed-settings.json`) > HKCU registry (Windows only). Only one managed source is used; sources do not merge across tiers. Within the file-based tier, drop-in files and the base file are merged together. - * Embedding hosts such as Claude Desktop can supply policy via the SDK `managedSettings` option. By default this is ignored when any managed-settings tier is present. Administrators can opt in by setting `parentSettingsBehavior` to `"merge"`. The embedder’s values are filtered so they can tighten managed policy but not loosen it. + * Embedding hosts such as Claude Desktop can supply policy via the SDK `managedSettings` option. By default this is ignored when an admin-deployed managed source is present: server-managed settings, an MDM or OS-level policy, or a managed settings file. The user-writable HKCU registry fallback does not count as an admin-deployed source. Administrators can opt in by setting `parentSettingsBehavior` to `"merge"`. The embedder’s values are filtered so they can tighten managed policy but not loosen it. 2. **Command line arguments** * Temporary overrides for a specific session. JSON passed via `--settings <file-or-json>` merges with file-based settings using the same rules as the other layers: a key set here overrides the same key in local, project, or user settings, and omitting a key leaves the lower-layer value in place 3. **Local project settings** (`.claude/settings.local.json`) @@ -629,7 +632,10 @@ This hierarchy ensures that organizational policies are always enforced while still allowing teams and individuals to customize their experience. The same precedence applies whether you run Claude Code from the CLI, the [VS Code extension](</docs/en/vs-code>), or a [JetBrains IDE](</docs/en/jetbrains>). For example, if your user settings set `permissions.defaultMode` to `acceptEdits` and a project’s shared settings set it to `default`, the project value applies. The example below covers how array-valued settings such as permission rules combine instead. -**Array settings merge across scopes.** When the same array-valued setting (such as `sandbox.filesystem.allowWrite` or `permissions.allow`) appears in multiple scopes, the arrays are **concatenated and deduplicated** , not replaced. This means lower-priority scopes can add entries without overriding those set by higher-priority scopes, and vice versa. For example, if managed settings set `allowWrite` to `["/opt/company-tools"]` and a user adds `["~/.kube"]`, both paths are included in the final configuration. Two exceptions: `fallbackModel` is an ordered chain where position carries meaning, so the highest-precedence file that defines it supplies the entire value. As of v2.1.175, a managed or policy `availableModels` value replaces lower-precedence entries entirely. See [Merge behavior](</docs/en/model-config#merge-behavior>). +**Array settings merge across scopes.** When the same array-valued setting (such as `sandbox.filesystem.allowWrite` or `permissions.allow`) appears in multiple scopes, the arrays are **concatenated and deduplicated** , not replaced. This means lower-priority scopes can add entries without overriding those set by higher-priority scopes, and vice versa. For example, if managed settings set `allowWrite` to `["/opt/company-tools"]` and a user adds `["~/.kube"]`, both paths are included in the final configuration.Two array settings do not merge this way: + + * `fallbackModel` is an ordered chain where position carries meaning: the highest-precedence file that defines it supplies the entire value. + * `availableModels`: when the [highest-precedence managed source](</docs/en/server-managed-settings#settings-precedence>) defines it, that list applies as-is and user, project, and local entries cannot extend it. Across non-managed scopes the arrays merge as usual. See [Merge behavior](</docs/en/model-config#merge-behavior>). ### @@ -650,7 +656,7 @@ * **Skills** : Custom prompts that can be invoked with `/skill-name` or loaded by Claude automatically * **MCP servers** : Extend Claude Code with additional tools and integrations * **Precedence** : Higher-level configurations (Managed) override lower-level ones (User/Project) - * **Inheritance** : Settings merge across scopes; scalar values from higher-priority scopes override, and arrays concatenate. Exceptions: `fallbackModel`, where the highest-precedence scope supplies the whole chain, and `availableModels`, where a managed or policy value replaces lower-precedence entries + * **Inheritance** : Settings merge across scopes; scalar values from higher-priority scopes override, and arrays concatenate, with two exceptions described in the array-merge Note ###
modified Extend Claude with skills View current →
--- a/skills.md +++ b/skills.md @@ -221,7 +221,7 @@ `user-invocable`| No| Set to `false` to hide from the `/` menu. Use for background knowledge users shouldn’t invoke directly. Default: `true`. `allowed-tools`| No| Tools Claude can use without asking permission when this skill is active. Accepts a space- or comma-separated string, or a YAML list. `disallowed-tools`| No| Tools removed from Claude’s available pool while this skill is active. Use for autonomous skills that should never call certain tools, such as `AskUserQuestion` for a background loop. Accepts a space- or comma-separated string, or a YAML list. The restriction clears when you send your next message. -`model`| No| Model to use when this skill is active. The override applies for the rest of the current turn and is not saved to settings; the session model resumes on your next prompt. Accepts the same values as [`/model`](</docs/en/model-config>), or `inherit` to keep the active model. +`model`| No| Model to use when this skill is active. The override applies for the rest of the current turn and is not saved to settings; the session model resumes on your next prompt. Accepts the same values as [`/model`](</docs/en/model-config>), or `inherit` to keep the active model. A value excluded by your organization’s [`availableModels`](</docs/en/model-config#restrict-model-selection>) allowlist is not used and the session keeps its current model. `effort`| No| [Effort level](</docs/en/model-config#adjust-effort-level>) when this skill is active. Overrides the session effort level. Default: inherits from session. Options: `low`, `medium`, `high`, `xhigh`, `max`; available levels depend on the model. `context`| No| Set to `fork` to run in a forked subagent context. `agent`| No| Which subagent type to use when `context: fork` is set.
modified Create custom subagents View current →
--- a/sub-agents.md +++ b/sub-agents.md @@ -284,6 +284,8 @@ 2. The per-invocation `model` parameter 3. The subagent definition’s `model` frontmatter 4. The main conversation’s model + +The environment variable, per-invocation parameter, and frontmatter values are checked against your organization’s [`availableModels`](</docs/en/model-config#restrict-model-selection>) allowlist. A value that resolves to an excluded model is not used and the subagent runs on the inherited model instead. ### @@ -765,7 +767,7 @@ Spawn nested subagents -As of Claude Code v2.1.172, a subagent can spawn its own subagents. Use this when a delegated task itself splits into parallel subtasks, such as a reviewer subagent that dispatches a verifier per finding, so the intermediate output never reaches your main conversation. Only the top-level subagent’s summary returns to you. A nested subagent is configured the same way as a top-level one and resolves from the same scopes. The subagent panel below the prompt input shows the full tree: each row displays a `(+N)` count of descendants, and opening a row shows that subagent’s direct children with a path back to `main`. The Running tab in `/agents` lists running subagents as a flat list. Depth is counted as the number of subagent levels below the main conversation, regardless of whether each level runs in the foreground or background. A subagent at depth five does not receive the Agent tool and cannot spawn further. The limit is fixed and not configurable. To prevent a specific subagent from spawning others, omit `Agent` from its `tools` list or add it to `disallowedTools`. A fork still cannot spawn another fork. It can spawn other subagent types, and those count toward the depth limit. +As of Claude Code v2.1.172, a subagent can spawn its own subagents. Use this when a delegated task itself splits into parallel subtasks, such as a reviewer subagent that dispatches a verifier per finding, so the intermediate output never reaches your main conversation. Only the top-level subagent’s summary returns to you. A nested subagent is configured the same way as a top-level one and resolves from the same scopes. The subagent panel below the prompt input shows the full tree: each row displays a `(+N)` count of descendants, and opening a row shows that subagent’s direct children with a path back to `main`. The Running tab in `/agents` lists running subagents as a flat list. Depth is counted as the number of subagent levels below the main conversation, regardless of whether each level runs in the foreground or background. A subagent at depth five does not receive the Agent tool and cannot spawn further. The limit is fixed and not configurable. As of Claude Code v2.1.187, a background subagent’s depth is fixed when it is first spawned, and resuming it later does not change that depth. For example, if your main conversation spawns subagent A, and A spawns a background subagent B at depth two, B is still at depth two when you resume it directly from the main conversation. Resuming a subagent from a shallower context does not let it spawn additional levels that the depth limit already prevented. To prevent a specific subagent from spawning others, omit `Agent` from its `tools` list or add it to `disallowedTools`. A fork still cannot spawn another fork. It can spawn other subagent types, and those count toward the depth limit. ###
modified Enterprise deployment overview View current →
--- a/third-party-integrations.md +++ b/third-party-integrations.md @@ -35,7 +35,7 @@ Most organizations can use a cloud provider directly without additional configuration. However, you may need to configure a corporate proxy or LLM gateway if your organization has specific network or management requirements. These are different configurations that can be used together: * **Corporate proxy** : Routes traffic through an HTTP/HTTPS proxy. Use this if your organization requires all outbound traffic to pass through a proxy server for security monitoring, compliance, or network policy enforcement. Configure with the `HTTPS_PROXY` or `HTTP_PROXY` environment variables. Learn more in [Enterprise network configuration](</docs/en/network-config>). - * **LLM Gateway** : A service that sits between Claude Code and the cloud provider to handle authentication and routing. Use this if you need centralized usage tracking across teams, custom rate limiting or budgets, or centralized authentication management. Configure with the `ANTHROPIC_BASE_URL`, `ANTHROPIC_BEDROCK_BASE_URL`, `ANTHROPIC_AWS_BASE_URL`, or `ANTHROPIC_VERTEX_BASE_URL` environment variables. Learn more in [LLM gateway configuration](</docs/en/llm-gateway>). + * **LLM Gateway** : A service that sits between Claude Code and the cloud provider to handle authentication and routing. Use this if you need centralized usage tracking across teams, custom rate limiting or budgets, or centralized authentication management. Configure with the `ANTHROPIC_BASE_URL`, `ANTHROPIC_BEDROCK_BASE_URL`, `ANTHROPIC_AWS_BASE_URL`, or `ANTHROPIC_VERTEX_BASE_URL` environment variables. Learn more in [LLM gateways](</docs/en/llm-gateway>). The following examples show the environment variables to set in your shell or shell profile (`.bashrc`, `.zshrc`). See [Settings](</docs/en/settings>) for other configuration methods. @@ -94,7 +94,7 @@ # Configure LLM gateway export ANTHROPIC_FOUNDRY_BASE_URL='https://your-llm-gateway.com' - export CLAUDE_CODE_SKIP_FOUNDRY_AUTH=1 # If gateway handles Azure auth + export ANTHROPIC_FOUNDRY_API_KEY=your-gateway-key # Sent as x-api-key ### @@ -124,6 +124,8 @@ # Configure LLM gateway export ANTHROPIC_VERTEX_BASE_URL='https://your-llm-gateway.com/vertex' export CLAUDE_CODE_SKIP_VERTEX_AUTH=1 # If gateway handles GCP auth + export ANTHROPIC_VERTEX_PROJECT_ID=your-gcp-project-id + export CLOUD_ML_REGION=us-east5 Use `/status` in Claude Code to verify your proxy and gateway configuration is applied correctly.
modified Agent SDK reference - TypeScript View current →
--- a/typescript.md +++ b/typescript.md @@ -431,7 +431,7 @@ Parameter| Type| Default| Description ---|---|---|--- `options.cwd`| `string`| `process.cwd()`| Directory to resolve project and local settings relative to -`options.settingSources`| `SettingSource``[]`| All sources| Which filesystem sources to load. Pass `[]` to skip user, project, and local settings. Managed policy settings load in all cases +`options.settingSources`| `SettingSource``[]`| All sources| Which filesystem sources to load. Pass `[]` to skip user, project, and local settings. [Endpoint-managed policy](</docs/en/settings#settings-files>) loads in all cases. Server-managed settings are taken from `serverManagedSettings` when the host passes it, or read from the CLI’s on-disk cache otherwise; the snapshot does not fetch them from the network `options.managedSettings`| `Settings`| `undefined`| Restrictive policy-tier settings supplied by the embedding host. Dropped by default when an admin-deployed managed tier is present; merged under that tier when [`parentSettingsBehavior`](</docs/en/settings#available-settings>) is `"merge"`. Non-restrictive keys such as `model` are silently dropped so this option can tighten managed policy but not loosen it `options.serverManagedSettings`| `Settings`| `undefined`| Server-managed settings payload from `/api/claude_code/settings`. Non-restrictive keys pass through unfiltered @@ -533,7 +533,7 @@ `sessionStore`| [`SessionStore`](</docs/en/agent-sdk/session-storage#the-sessionstore-interface>)| `undefined`| Mirror session transcripts to an external backend so any host can resume them. See [Persist sessions to external storage](</docs/en/agent-sdk/session-storage>) `sessionStoreFlush`| `'batched' | 'eager'`| `'batched'`| _Alpha._ Flush mode for `sessionStore`. Ignored when `sessionStore` is not set `settings`| `string | Settings`| `undefined`| Inline [settings](</docs/en/settings>) object or path to a settings file. Populates the flag-settings layer in the [precedence order](</docs/en/settings#settings-precedence>). Change at runtime with `applyFlagSettings()` -`settingSources`| `SettingSource``[]`| CLI defaults (all sources)| Control which filesystem settings to load. Pass `[]` to disable user, project, and local settings. Managed policy settings load regardless. See [Use Claude Code features](</docs/en/agent-sdk/claude-code-features#what-settingsources-does-not-control>) +`settingSources`| `SettingSource``[]`| CLI defaults (all sources)| Control which filesystem settings to load. Pass `[]` to disable user, project, and local settings. [Endpoint-managed policy](</docs/en/settings#settings-files>) loads regardless; server-managed settings are fetched when the session authenticates with an organization credential on an [eligible configuration](</docs/en/server-managed-settings#platform-availability>). See [Use Claude Code features](</docs/en/agent-sdk/claude-code-features#what-settingsources-does-not-control>) `skills`| `string[] | 'all'`| `undefined`| Skills available to the session. Pass `'all'` to enable every discovered skill, or a list of skill names. When set, the SDK adds the Skill tool to `allowedTools` automatically. If you also pass `tools`, include `'Skill'` in that list. See [Skills](</docs/en/agent-sdk/skills>) `spawnClaudeCodeProcess`| `(options: SpawnOptions) => SpawnedProcess`| `undefined`| Custom function to spawn the Claude Code process. Use to run Claude Code in VMs, containers, or remote environments `stderr`| `(data: string) => void`| `undefined`| Callback for stderr output @@ -775,7 +775,7 @@ Default behavior -When `settingSources` is omitted or `undefined`, `query()` loads the same filesystem settings as the Claude Code CLI: user, project, and local. Managed policy settings are loaded in all cases. See [What settingSources does not control](</docs/en/agent-sdk/claude-code-features#what-settingsources-does-not-control>) for inputs that are read regardless of this option, and how to disable them. +When `settingSources` is omitted or `undefined`, `query()` loads the same filesystem settings as the Claude Code CLI: user, project, and local. [Endpoint-managed policy](</docs/en/settings#settings-files>) is loaded in all cases; server-managed settings are fetched when the session authenticates with an organization credential on an [eligible configuration](</docs/en/server-managed-settings#platform-availability>). See [What settingSources does not control](</docs/en/agent-sdk/claude-code-features#what-settingsources-does-not-control>) for inputs that are read regardless of this option, and how to disable them. ####
modified Voice dictation View current →
--- a/voice-dictation.md +++ b/voice-dictation.md @@ -21,7 +21,7 @@ Run `/voice` to enable dictation. The first time you enable it, Claude Code runs a microphone check. On macOS, this triggers the system microphone permission prompt for your terminal if it has never been granted. /voice - Voice mode enabled (hold). Hold Space to record. Dictation language: en (/config to change). + Voice mode enabled (hold). Hold space to record. Dictation language: en (/config to change). `/voice` accepts an optional mode argument: @@ -41,7 +41,7 @@ } } -While voice dictation is enabled, the input footer shows a `hold Space to speak` hint when the prompt is empty. The hint reflects your current `voice:pushToTalk` binding and updates if you rebind the dictation key. The hint text is the same in both modes, and it does not appear if you have a [custom status line](</docs/en/statusline>) configured. Transcription is tuned for coding vocabulary in both modes. Common development terms like `regex`, `OAuth`, `JSON`, and `localhost` are recognized correctly, and your current project name and git branch name are added as recognition hints automatically. +While voice dictation is enabled, the input footer shows a `hold space to speak` hint when the prompt is empty. The hint reflects your current `voice:pushToTalk` binding and updates if you rebind the dictation key. The hint text is the same in both modes, and it does not appear if you have a [custom status line](</docs/en/statusline>) configured. Transcription is tuned for coding vocabulary in both modes. Common development terms like `regex`, `OAuth`, `JSON`, and `localhost` are recognized correctly, and your current project name and git branch name are added as recognition hints automatically. ## @@ -56,7 +56,7 @@ Your speech appears in the prompt as you speak, dimmed until the transcript is finalized. Release `Space` to stop recording and finalize the text. The transcript is inserted at your cursor position and the cursor stays at the end of the inserted text, so you can mix typing and dictation in any order. Hold `Space` again to append another recording, or move the cursor first to insert speech elsewhere in the prompt: > refactor the auth middleware to ▮ - # hold Space, speak "use the new token validation helper" + # hold space, speak "use the new token validation helper" > refactor the auth middleware to use the new token validation helper▮ By default, releasing the key inserts the transcript and waits for you to press `Enter`. Set `"autoSubmit": true` in the `voice` settings object to send the prompt automatically when you release the key, as long as the transcript is at least three words long.