CLAUDE_API_KEY
Updated by Alex Sorokoletov
CLAUDE_API_KEY is a Claude Code environment variable. Added between v2.1.143 and v2.1.212 and still present in v2.1.332. It is not in the official reference.
| Status | Present in v2.1.332 |
|---|---|
| Added | Added between v2.1.143 and v2.1.212 |
| Category | Authentication |
| Official docs | Not listed |
How to set it
For one session, export it in the shell that starts Claude Code:
export CLAUDE_API_KEY=<value>
claudeTo apply it to every session, add it to the env object of a settings file:
// ~/.claude/settings.json
{
"env": {
"CLAUDE_API_KEY": "<value>"
}
}Related variables
ANTHROPIC_API_KEY: Primary API key for Claude API.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_CODE_LAUNCHER_RUNS_API_KEY_HELPERCLAUDE_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.CLAUDE_CODE_MEMORY_API_TOKEN: Bearer token for that server.
Frequently asked questions
Which Claude Code version has CLAUDE_API_KEY?
Added between v2.1.143 and v2.1.212 and still present in v2.1.332.
How do I set CLAUDE_API_KEY?
Export it before starting Claude Code (export CLAUDE_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.