Answer: To fix the "Invalid API key" error, check for typos and confirm the key has not been revoked in the Console, and verify which credential source Claude Code is using by running `/status`. You can also unset `ANTHROPIC_API_KEY` and run `/login` to use subscription auth instead. Status: Confirmed Entry: tool/claude-code/troubleshooting/fix-invalid-api-key Revision: 8 Digest: sha256:656ad74844f8cbcf (changes whenever the content changes) Timeline: Created: 2026-11-13T03:04:06Z Last changed: 2026-11-20T12:20:35Z (alternative auth: — → Unset `ANTHROPIC_API_KEY` and run `/login` to use subscription auth instead) Last verified: 2026-11-20T12:20:35Z Next check: 2026-11-21T12:20:35Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of diagnostic command | env | grep ANTHROPIC | [1] | 2026-11-20 PowerShell command | Get-ChildItem Env:ANTHROPIC* | [1] | 2026-11-20 alternative auth | Unset `ANTHROPIC_API_KEY` and run `/login` to use subscription auth instead | [1] | 2026-11-20 status command | /status | [1] | 2026-11-20 Sources: [1] Anthropic. "Error reference". https://code.claude.com/docs/en/errors.md Role: primary. Accessed: 2026-11-20T12:20:35Z Quote: "In the same shell, run `env | grep ANTHROPIC`" (Supports: diagnostic command) Quote: "or in PowerShell `Get-ChildItem Env:ANTHROPIC*`" (Supports: PowerShell command) Quote: "Unset `ANTHROPIC_API_KEY` and run `/login` to use subscription auth instead" (Supports: alternative auth) Quote: "Run `/status` to confirm which credential source Claude Code is actually using" (Supports: status command) Published: 2026-11-20T10:25:18Z Snapshot SHA-256: c9ad601aff1e6a50d95382b7c498d9da861c091898ac54ec614418bd376887f4 (captured 2026-11-20T12:20:34Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. Cross-check: not-available at 2026-11-20T12:20:35Z. No independent second source is configured for this entry Last successful check: 2026-11-20T12:20:35Z Last attempt: 2026-11-20T12:20:35Z Notes and limitations: Extracted automatically from a single official source (section "Invalid API key"). Related: https://latestn.com/tool/claude-code/troubleshooting/fix-marketplace-not-found How do I fix the "Marketplace not found" error when adding a marketplace in Claude Code? https://latestn.com/tool/claude-code/troubleshooting/fix-plugin-installed-not-working How do I fix a Claude Code plugin that is installed but not working or not showing up? https://latestn.com/tool/claude-code/troubleshooting/fix-plugin-not-found-in-marketplace Why does Claude Code say a plugin is not found in the marketplace, and how do I fix it? https://latestn.com/tool/claude-code/troubleshooting/fix-commands-path-not-found How do I fix the "commands path not found" error when building a Claude Code plugin? https://latestn.com/tool/claude-code/troubleshooting/fix-garbled-text-integrated-terminal How do I fix garbled or corrupted text in an editor's integrated terminal when using Claude Code? https://latestn.com/tool/claude-code/troubleshooting/fix-high-cpu-memory-usage How do I fix high CPU or memory usage in Claude Code? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-20T12:20:35Z | changed | alternative auth: — → Unset `ANTHROPIC_API_KEY` and run `/login` to use subscription auth instead | [1] 2026-11-20T12:20:35Z | changed | PowerShell command: — → Get-ChildItem Env:ANTHROPIC* | [1] 2026-11-20T12:20:35Z | changed | diagnostic command: — → env | grep ANTHROPIC | [1] 2026-11-20T12:20:35Z | changed | login command: /login → — | [1] 2026-11-20T12:20:35Z | changed | environment variable: ANTHROPIC_API_KEY → — | [1] 2026-11-20T12:20:35Z | changed | error message: Invalid API key · Fix external API key → — | [1] 2026-11-19T12:16:09Z | changed | status command: — → /status | [1] 2026-11-19T12:16:09Z | changed | login command: — → /login | [1] 2026-11-19T12:16:09Z | changed | error message: — → Invalid API key · Fix external API key | [1] 2026-11-19T12:16:09Z | changed | apiKeyHelper check: run the script directly to confirm it prints a valid key on stdout → — | [1] 2026-11-19T12:16:09Z | changed | alternative auth: Unset `ANTHROPIC_API_KEY` and run `/login` to use subscription auth instead → — | [1] 2026-11-19T12:16:09Z | changed | check credential source: /status → — | [1] 2026-11-18T12:16:06Z | changed | apiKeyHelper check: — → run the script directly to confirm it prints a valid key on stdout | [1] 2026-11-18T12:16:06Z | changed | environment variable: — → ANTHROPIC_API_KEY | [1] 2026-11-18T12:16:06Z | changed | alternative auth: — → Unset `ANTHROPIC_API_KEY` and run `/login` to use subscription auth instead | [1] 2026-11-18T12:16:06Z | changed | check credential source: — → /status | [1] 2026-11-18T12:16:06Z | changed | Environment variable: ANTHROPIC_API_KEY → — | [1] 2026-11-18T12:16:06Z | changed | Verify credential source: Run `/status` to confirm which credential source Claude Code is actually using → — | [1] 2026-11-18T12:16:06Z | changed | Alternative fix: Unset `ANTHROPIC_API_KEY` and run `/login` to use subscription auth instead → — | [1] 2026-11-17T12:25:37Z | changed | Environment variable: — → ANTHROPIC_API_KEY | [1] 2026-11-17T12:25:37Z | changed | apiKeyHelper check: run the script directly to confirm it prints a valid key on stdout → — | [1] 2026-11-17T12:25:37Z | changed | Check environment: env | grep ANTHROPIC → — | [1] 2026-11-15T12:20:28Z | changed | apiKeyHelper check: — → run the script directly to confirm it prints a valid key on stdout | [1] 2026-11-15T12:20:28Z | changed | Verify credential source: — → Run `/status` to confirm which credential source Claude Code is actually using | [1] 2026-11-15T12:20:28Z | changed | Alternative fix: — → Unset `ANTHROPIC_API_KEY` and run `/login` to use subscription auth instead | [1] 2026-11-15T12:20:28Z | changed | Confirm credential source: Run `/status` to confirm which credential source Claude Code is actually using → — | [1] 2026-11-15T12:20:28Z | changed | Alternative auth: Unset `ANTHROPIC_API_KEY` and run `/login` to use subscription auth instead → — | [1] 2026-11-15T12:20:28Z | changed | PowerShell command: Get-ChildItem Env:ANTHROPIC* → — | [1] 2026-11-14T12:16:19Z | changed | Confirm credential source: — → Run `/status` to confirm which credential source Claude Code is actually using | [1] 2026-11-14T12:16:19Z | changed | Alternative auth: — → Unset `ANTHROPIC_API_KEY` and run `/login` to use subscription auth instead | [1] 2026-11-14T12:16:19Z | changed | PowerShell command: — → Get-ChildItem Env:ANTHROPIC* | [1] 2026-11-14T12:16:19Z | changed | Check environment: — → env | grep ANTHROPIC | [1] 2026-11-14T12:16:19Z | changed | status command: /status → — | [1] 2026-11-14T12:16:19Z | changed | login command: /login → — | [1] 2026-11-14T12:16:19Z | changed | PowerShell check command: Get-ChildItem Env:ANTHROPIC* → — | [1] 2026-11-14T12:16:19Z | changed | shell check command: env | grep ANTHROPIC → — | [1] 2026-11-14T12:16:19Z | changed | environment variable: ANTHROPIC_API_KEY → — | [1] 2026-11-14T12:16:19Z | changed | error message: Invalid API key · Fix external API key → — | [1] 2026-11-13T12:10:17Z | changed | status command: — → /status | [1] 2026-11-13T12:10:17Z | changed | login command: — → /login | [1] 2026-11-13T12:10:17Z | changed | PowerShell check command: — → Get-ChildItem Env:ANTHROPIC* | [1] 2026-11-13T12:10:17Z | changed | shell check command: — → env | grep ANTHROPIC | [1] 2026-11-13T12:10:17Z | changed | environment variable: — → ANTHROPIC_API_KEY | [1] 2026-11-13T12:10:17Z | changed | error message: — → Invalid API key · Fix external API key | [1] 2026-11-13T12:10:17Z | changed | Status command: /status → — | [1] 2026-11-13T12:10:17Z | changed | Alternative auth: Unset `ANTHROPIC_API_KEY` and run `/login` to use subscription auth instead → — | [1] 2026-11-13T12:10:17Z | changed | PowerShell command: Get-ChildItem Env:ANTHROPIC* → — | [1] 2026-11-13T12:10:17Z | changed | Diagnostic command: env | grep ANTHROPIC → — | [1] 2026-11-13T03:04:06Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/claude-code/troubleshooting/fix-invalid-api-key/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/claude-code/troubleshooting/fix-invalid-api-key POST: https://latestn.com/dispute/tool/claude-code/troubleshooting/fix-invalid-api-key with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/claude-code/troubleshooting/fix-invalid-api-key?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I fix the Claude Code "Invalid API key" error? Revision 8, last verified 2026-11-20T12:20:35Z. https://latestn.com/tool/claude-code/troubleshooting/fix-invalid-api-key (accessed 2026-11-21T09:54:43Z). @misc{LatestN_tool_claude_code_troubleshooting_fix_invalid_api_key_r8, title = {How do I fix the Claude Code "Invalid API key" error?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/claude-code/troubleshooting/fix-invalid-api-key}}, note = {Revision 8; digest sha256:656ad74844f8cbcf; last verified 2026-11-20T12:20:35Z; accessed 2026-11-21T09:54:43Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/claude-code/troubleshooting/fix-invalid-api-key