{"name":"ANTHROPIC_API_KEY","slug":"anthropic-api-key","family":"env","title":"Environment variables","noun":"environment variable","description":"API key sent as `X-Api-Key` header. When set, this key is used instead of your Claude Pro, Max, Team, or Enterprise subscription even if you are logged in. In non-interactive mode (`-p`), the key is always used when present. In interactive mode, you are prompted to approve the key once before it overrides your subscription. To use your subscription instead, run `unset ANTHROPIC_API_KEY`","description_source":"docs","described_by":{"doc":"claude-code\/env-vars","title":"Environment variables"},"presence":{"first_seen":"2.1.138","removed_in":null,"in_current_build":true,"newest_mined":"2.1.308","builds":149,"mined_builds":149,"first_cited":{"version":"2.1.76","released_at":"2026-03-14 00:14:17","spans":6}},"aliases":[],"entries":[{"version":"2.1.307","anchor":"env-management-401-message-moved-to-a-shared-variable","heading":"Sign-in error for environment management no longer built in place","line":"The error shown when you are not signed in for environment management now comes from elsewhere in Claude Code, and its wording may differ","released_at":"2026-10-21 20:47:18","reason":"found in this entry's text"},{"version":"2.1.307","anchor":"environment-management-endpoints-need-claude-login","heading":"Environment management needs claude login , not an API key","line":"A reworded error says environment-management features need you signed in with `claude login` and do not work with `ANTHROPIC_API_KEY`","released_at":"2026-10-21 20:47:18","reason":"named in this entry, found in this entry's text"},{"version":"2.1.305","anchor":"plugin-eval-can-pass-the-session-api-key-to-its-test-runs-by","heading":"claude plugin eval passes your session's API key to its test runs","line":"With an API key session, `claude plugin eval` now hands the key to its test runs itself, except on Windows, where you must set `ANTHROPIC_API_KEY`","released_at":"2026-10-20 19:29:36","reason":"found in this entry's text"},{"version":"2.1.304","anchor":"policy-limits-re-fetch-after-an-api-refusal-anthropic-api-k","heading":"Organisation policy limits are re-fetched as soon as the API refuses a request","line":"When the API refuses a request over an organisation policy the session has not loaded, Claude Code re-fetches its policy limits straight away","released_at":"2026-10-19 19:47:15","reason":"found in this entry's text"},{"version":"2.1.300","anchor":"new-credential-road-telemetry-and-cloud-launch-credential-ev","heading":"Analytics now note where your sign-in credential came from","line":"Some analytics events now record how the credential was supplied, such as an environment variable, a file descriptor or none at all","released_at":"2026-10-14 14:27:26","reason":"found in this entry's text"},{"version":"2.1.296","anchor":"cloud-session-availability-message-names-the-credential-in-u","heading":"Cloud sessions message names the key or token whose organization was checked","line":"When cloud sessions are blocked by organization policy, the message now says which API key or token Claude Code checked the policy for","released_at":"2026-10-09 16:58:10","reason":"found in this entry's text"},{"version":"2.1.288","anchor":"bare-mode-login-now-refuses-with-explanation","heading":"\/login in bare mode explains why it won't sign you in","line":"In bare mode, `\/login` now prints an explanation instead of a sign-in that would have no effect","released_at":"2026-10-02 18:30:40","reason":"found in this entry's text"},{"version":"2.1.286","anchor":"auth-source-classification-changed-login-managed-key","heading":"Keys managed through \/login are now labelled as API keys, not claude.ai","line":"Claude Code now reports a key managed through `\/login` as an API key rather than a claude.ai login","released_at":"2026-09-30 17:14:38","reason":"found in this entry's text, named in this entry"},{"version":"2.1.285","anchor":"ssh-placeholder-credential-detection","heading":"Detection of sign-in forwarded over SSH now checks for a placeholder","line":"Claude Code recognises SSH-forwarded sign-in when a socket is set and exactly one credential variable holds the value ssh-placeholder","released_at":"2026-09-29 17:32:09","reason":"found in this entry's text"},{"version":"2.1.285","anchor":"provider-auth-probes-and-clients-unify-headers-x-api-key-fo","heading":"Bedrock, Mantle and Vertex connections share headers and can send your API key","line":"Bedrock, Mantle and Vertex clients now share one set of headers and add an `X-Api-Key` header from `ANTHROPIC_API_KEY` unless one is set","released_at":"2026-09-29 17:32:09","reason":"found in this entry's text"}],"entries_total":34,"docs":[{"source":"claude-code","path":"env-vars","title":"Environment variables","documented":true},{"source":"api","path":"about-claude\/models\/migration-guide","title":"Or, for the model with the same capabilities and no access approval requirement:","documented":false},{"source":"api","path":"about-claude\/models\/optimizing-for-cost-and-intelligence","title":"optimizing-for-cost-and-intelligence","documented":false},{"source":"api","path":"about-claude\/use-case-guides\/customer-support-chat","title":"customer-support-chat","documented":false},{"source":"api","path":"agents-and-tools\/agent-skills\/quickstart","title":"quickstart","documented":false},{"source":"api","path":"agents-and-tools\/mcp-connector","title":"mcp-connector","documented":false},{"source":"api","path":"agents-and-tools\/mcp-tunnels\/overview","title":"overview","documented":false},{"source":"api","path":"agents-and-tools\/tool-use\/advisor-tool","title":"advisor-tool","documented":false},{"source":"api","path":"agents-and-tools\/tool-use\/bash-tool","title":"bash-tool","documented":false},{"source":"api","path":"agents-and-tools\/tool-use\/browser-use-tool","title":"browser-use-tool","documented":false}],"docs_total":13,"gates":[],"related":[{"name":"ANTHROPIC_AUTH_TOKEN","slug":"anthropic-auth-token","description":"Custom value for the `Authorization` header (the value you set here will be prefixed with `Bearer `)"},{"name":"ANTHROPIC_AWS_API_KEY","slug":"anthropic-aws-api-key","description":"Workspace API key for [Claude Platform on AWS](\/docs\/en\/claude-platform-on-aws), generated in the AWS Console. Sent as `x-api-key` and takes precedence over AWS SigV4"},{"name":"ANTHROPIC_AWS_BASE_URL","slug":"anthropic-aws-base-url","description":"Override the [Claude Platform on AWS](\/docs\/en\/claude-platform-on-aws) endpoint URL. Use for custom regions or when routing through an [LLM gateway](\/docs\/en\/llm-gateway). Defaults to `https:\/\/aws-external-anthropic.{region}.api.aws`. Claude Code resolves the region with the [same precedence as on Amazon Bedrock](\/docs\/en\/amazon-bedrock#3-configure-claude-code)"},{"name":"ANTHROPIC_AWS_WORKSPACE_ID","slug":"anthropic-aws-workspace-id","description":"Required for [Claude Platform on AWS](\/docs\/en\/claude-platform-on-aws). Sent on every request as the `anthropic-workspace-id` header"},{"name":"ANTHROPIC_BASE_URL","slug":"anthropic-base-url","description":"Override the API endpoint to route requests through a proxy or gateway. When set to a non-first-party host, [MCP tool search](\/docs\/en\/mcp#scale-with-mcp-tool-search) is disabled by default. Set `ENABLE_TOOL_SEARCH=true` if your proxy forwards `tool_reference` blocks. As of v2.1.196, [Remote Control](\/docs\/en\/remote-control#requirements) is disabled when this points at a host other than `api.anthropic.com`, matching its behavior on Amazon Bedrock, Google Cloud's Agent Platform, and Microsoft Foundry"},{"name":"ANTHROPIC_BEDROCK_BASE_URL","slug":"anthropic-bedrock-base-url","description":"Override the Amazon Bedrock endpoint URL. Use for custom Amazon Bedrock endpoints or when routing through an [LLM gateway](\/docs\/en\/llm-gateway). See [Amazon Bedrock](\/docs\/en\/amazon-bedrock)"},{"name":"ANTHROPIC_BEDROCK_MANTLE_BASE_URL","slug":"anthropic-bedrock-mantle-base-url","description":"Override the Amazon Bedrock Mantle endpoint URL. See [Mantle endpoint](\/docs\/en\/amazon-bedrock#use-the-mantle-endpoint)"},{"name":"ANTHROPIC_BEDROCK_REGION_PREFIX","slug":"anthropic-bedrock-region-prefix","description":"Cross-region inference profile prefix (`us`, `eu`, `apac`, `jp`, `au`, or `global`) Claude Code tries first instead of the one derived from the AWS region. Ignored in AWS GovCloud regions. Requires Claude Code v2.1.224 or later. See [Amazon Bedrock](\/docs\/en\/amazon-bedrock#cross-region-inference-profile-prefixes)"},{"name":"ANTHROPIC_BEDROCK_SERVICE_TIER","slug":"anthropic-bedrock-service-tier","description":"Amazon Bedrock [service tier](https:\/\/docs.aws.amazon.com\/bedrock\/latest\/userguide\/service-tiers-inference.html) (`default`, `flex`, or `priority`). Sent as the `X-Amzn-Bedrock-Service-Tier` header. See [Amazon Bedrock](\/docs\/en\/amazon-bedrock#service-tiers)"},{"name":"ANTHROPIC_BETAS","slug":"anthropic-betas","description":"Comma-separated list of additional `anthropic-beta` header values to include in API requests. Claude Code already sends the beta headers it needs; use this to opt into an [Anthropic API beta](https:\/\/platform.claude.com\/docs\/en\/api\/beta-headers) before Claude Code adds native support. Unlike the [`--betas` flag](\/docs\/en\/cli-reference#cli-flags), which requires API key authentication, this variable works with all auth methods including Claude.ai subscription"}],"url":"https:\/\/changelogs.core-directive.com\/reference\/env\/anthropic-api-key","family_url":"https:\/\/changelogs.core-directive.com\/reference\/env.json"}