# ANTHROPIC_API_KEY

Canonical page: /glossary/anthropic-api-key

API keys & secrets glossary, Claude Code & MCP. ANTHROPIC_API_KEY: What It Is and Where to Put It

**Short answer:** ANTHROPIC_API_KEY is the environment variable Claude Code and the Claude API look for to authenticate your requests. You get the value from the Anthropic Console, and Claude Code reads it from your shell environment, a .env file, or a secrets manager, not from a config file you edit by hand.

## Why it matters

Claude Code checks a few places for this variable in order: your current shell session, a project .env file, and any value a secrets tool injects into the process before it starts. If none of them are set, Claude Code will ask you to log in or paste a key.

## In Claude Keychain

Claude Keychain stores your ANTHROPIC_API_KEY in the macOS Keychain instead of a shell profile or .env file. When Claude Code needs it, Claude Keychain injects it into the subprocess environment for that one command, so the key never has to sit in a file you could forget to gitignore.

## Common questions

**Do I need a different key for each project?**

No. One ANTHROPIC_API_KEY works across every project on your Mac. The only reason to use more than one is to track usage separately.

**What happens if I paste it into the chat by accident?**

Treat it as leaked. Revoke it in the Anthropic Console and generate a new one, the same as any other exposed secret.

## Related

[API key](/glossary/api-key), [.env file](/glossary/env-file), [MCP server](/glossary/mcp-server)
