ANTHROPIC_API_KEY
Updated by Alex Sorokoletov
ANTHROPIC_API_KEY is a Claude Code environment variable: Primary API key for Claude API. Its release history is not tracked here. It is listed in the official reference.
| Status | Present in v2.1.332 |
|---|---|
| Category | Authentication |
| Official docs | Listed |
How to set it
For one session, export it in the shell that starts Claude Code:
export ANTHROPIC_API_KEY=<value>
claudeTo apply it to every session, add it to the env object of a settings file:
// ~/.claude/settings.json
{
"env": {
"ANTHROPIC_API_KEY": "<value>"
}
}Release notes that mention it
- Claude Code "This sign-in cannot read meetings": Why the claude.ai Meetings Connector Fails and /login Does Not Fix It
- How to Install OpenCode: npm, curl, Homebrew, Windows, Desktop App and API Key
- How Much Does Claude Code Cost? Plans, API, OpenRouter and Bedrock Prices
- Claude Code Code Mode: How to Turn It On, What It Changes, and Why It Won't Start
- Why Claude Code Put Your Email in a User-Agent Header, and How to Stop It
- Claude Code "What's contributing to your limits usage?": How to Read the /usage Breakdown
- Claude Code's Org Memory: the Memory Stores REST API
- Claude Code v2.1.81 — 1 New Environment Variable: The --bare Flag and a Bug Fix Marathon
Related variables
CLAUDE_CODE_API_KEY_FILE_DESCRIPTOR: File descriptor to read API key from.CLAUDE_CODE_API_KEY_HELPER_TTL_MS: Cache TTL for API key helper.CLAUDE_API_KEYCLAUDE_CODE_LAUNCHER_RUNS_API_KEY_HELPERANTHROPIC_AUTH_TOKEN: Alternative bearer token; takes priority over API key.CLAUDE_CODE_ARTIFACTS_API_TOKEN: Auth token for the artifacts service.CLAUDE_CODE_CLIENT_KEY: Path to client private key.CLAUDE_CODE_CLIENT_KEY_PASSPHRASE: Passphrase for encrypted client key.
Frequently asked questions
What does ANTHROPIC_API_KEY do?
Primary API key for Claude API
Which Claude Code version has ANTHROPIC_API_KEY?
Its release history is not tracked here.
How do I set ANTHROPIC_API_KEY?
Export it before starting Claude Code (export ANTHROPIC_API_KEY=value), or add it to the "env" object in ~/.claude/settings.json to apply it to every session.
All variables, searchable: Claude Code environment variables.