Invalid API key (invalid x-api-key)
The key in the environment or keychain was rejected outright.
99 issues · 6 open · 93 resolved (94%) · first seen Mar 12, 2025
First response · account
What to do now
Most likely: Authentication, usage state or session size blocked the request.
- Check the exact account, organization and usage window currently selected.
- Try a new short session before deleting credentials or local history.
- If the state is inconsistent across machines, preserve diagnostics and re-authenticate once.
These are conservative triage steps, not an official Anthropic fix. Use the issue and workaround evidence below before making a destructive configuration change.
Is this getting better or worse?
This class of problem is holding steady. 9 new reports in the last 90 days vs 9 in the 90 before — 0%. The open backlog peaked at 32 in 2025-10 and sits at 6 today.
Derived by counting each matching issue from its creation date until it closed. First-party
computation over the anthropics/claude-code tracker — the trend is not published
anywhere upstream.
Which builds report this
18 of these reports name the Claude Code build they were running, spanning 18 releases. Heaviest reporters:
- Claude Code v2.1.227
- Claude Code v2.1.226
- Claude Code v2.1.220
- Claude Code v2.1.179
- Claude Code v2.1.201
- Claude Code v2.1.198
- Claude Code v2.1.185
- Claude Code v2.1.149
Report volume, not a defect count: an issue can mention a build without that build having caused the failure. Versions come from the version string in the bug-report template, matched against real published tags.
Do these get fixed?
Median time to close is 14 days across 93 closures. Of the 93 closures with a recorded reason, 30% were closed as completed and 65 as not-planned or duplicate. The most recent completed fix landed in 2026-08.
Workarounds reported by the community
18 of these issues post a workaround someone says worked. The highest-engagement ones:
- [BUG] Sessions become unresponsive after upgrade to 2.0.60 (suspected background agent blocking)
- …tatic for at least an hour, until I got the idea to re-log. Workaround: None found, except to log out of anthropic and back in. Related but different issues found: - - Agent freeze but with 100% CPU (yours is silent) - -…
Found in the description of #13188 · resolved - Authentication Failure After Login in v1.0.68 at ssh remote
- …y" error, requiring repeated (unsuccessful) login attempts. Workaround: Downgrading to version 1.0.67 resolves the issue: Environment(remote machine): - Node.js version: v20.18.1 - npm version: 10.8.2 - Operating System:…
Found in the description of #5118 · resolved - [BUG] Missing API key · Run /login on Max subscription
- …e are no new API keys created in my Anthropic account. Temp workaround : I got this working on the new machine by copying the following files/directories from the old (working) device to the new device: This uses the sam…
Found in the thread of #5166 · resolved - Invalid API key · Please run /login
- …e are no new API keys created in my Anthropic account. Temp workaround : I got this working on the new machine by copying the following files/directories from the old (working) device to the new device: This uses the sam…
Found in the thread of #5167 · still open - [BUG] Authentication fails immediately after successful /login in Claude Code v1.0.71
- …on history - Issue persists even after cleaning config file Workarounds Attempted - Multiple /login attempts - Unsetting ANTHROPIC API KEY environment variable - Resetting project-specific configuration - Removing and re…
Found in the description of #5369 · resolved
Excerpts are quoted from the linked issue so you can judge relevance before opening it. Threads that only ask for a workaround, or report that there is none, are excluded. These are community suggestions, not official guidance from Anthropic — read the full thread before applying one.
Matching issues 1–99
Ranked by community engagement (reactions weighted over comments).
- [BUG] Sessions become unresponsive after upgrade to 2.0.60 (suspected background agent blocking)
- Authentication Failure After Login in v1.0.68 at ssh remote
- [BUG] Missing API key · Run /login on Max subscription
- [BUG] macOS OAuth authentication succeeds but auth token not persisted - shows 'Missing API key' after successful login
- [FEATURE] Disable reading ANTHROPIC_API_KEY from local `.env` files in the SDK
- Invalid API key · Please run /login
- [BUG] Authentication fails immediately after successful /login in Claude Code v1.0.71
- [BUG] VS Code extension 2.0.5.0: Invalid API key · Please run /login and black screen even after successful Anthropic Console OAuth and manual API key setup
- Non-Interactive Mode Fails to Authenticate Using Provided API Key
- [BUG] HTTP/SSE MCP Transport Ignores Authentication Headers
- [BUG] Missing API key · Run /login - Invalid API key · Please run /login
- [BUG] v2.0.14 macOS Keychain issue - OAuth authentication doesn't persist without security unlock-keychain each session
- Invalid API key · Please run /login
- Invalid API key · Please run /login
- Invalid API key · Please run /login
- [BUG] Invalid API Key - Fix external API key when running headless mode with -p
- Invalid API key · Please run /login
- Is it possible for the SDK to use CLAUDE_CODE_OAUTH_TOKEN
- [BUG] OAuth authentication succeeds but `claude auth status` shows "Invalid API key" error
- Invalid API key · Please run /login
- Invalid API key · Fix external API key
- Bundled GrowthBook clientKey intermittently returns 400 "Invalid API Key" → all feature flags fail → channels & Remote Control unavailable
- [BUG] Claude Code Web: "Invalid API key · Fix external API key" error on session start
- [BUG] Claude Pro authentication not persisting on Linux
- Invalid API key · Please run /login
- [BUG] claude code doesn't use different API keys for different claude profiles
- [BUG] Invalid API key · Fix external API key
- BUG] Claude Code hangs on launch — OAuth authentication page loads indefinitely (Pro subscription, macOS)
- Bug: Claude Code VS Code extension stuck in login loop / API key not recognized
- Invalid API key · Please run /login/lo
- Invalid API key · Please run /login
- Invalid API key · Please run /login
- Rate Limit Recovery Failure for Pro/Max Subscriptions in Claude Code
- [BUG] [Claude Desktop] Cowork VM agent sessions don't receive credentials (gateway mode or Bedrock direct mode)
- [BUG] Claude Code VS Code extension completes browser OAuth successfully but never receives the token, causing an infinite login loop
- [BUG] Anthropic disabled OAuth tokens for third-party apps
- [BUG] Regression - Azure Foundry auth failing since 2.0.70
- [BUG] Invalid API key · Please run /login in VSCode Plugin
- Authentication Failure: Browser Login Not Recognized After Successful Login
- Invalid API key · Please run /login
- [BUG] Using Max 200 Plan but Charged for API Usage!
- Invalid API key · Please run /login
- Cannot run /login
- `/cost` overstates cost when on max subscription
- [BUG] Invalid API key on MacOS
- [BUG] MAX Plan Paid. Access to IP Cut Off
- [BUG] Claude Code fails to login via the Anthropic Console in VSCode when using devcontainers
- [BUG] Invalid API key · Please run /login (Linux)
- [BUG]
- [BUG]
- Invalid API key · Please run /login
- [BUG] Prompted to log in and asked to confirm that I was being charged $5 when i have Max plan and not pay as you go.
- [BUG] Claude CLI print mode reads from .env
- [BUG] When running Claude Code from an Automator service on macOS, Claude cannot read my login credentials
- [BUG] [duplicate] Non-Interactive Mode Fails to Authenticate Using Provided API Key
- [ERROR] Error streaming, falling back to non-streaming mode: Connection error.
- [BUG] Claude Code 2.1.220: startup connectivity preflight hard-fails behind a corporate HTTPS proxy (ERR_SOCKET_CLOSED), even though the API is reachable through it
- [BUG] ECONNRESET on home Wi-Fi — curl succeeds at exact same moment Claude Code fails
- [DOCS] Errors reference omits the "Your organization has disabled API key authentication" message and v2.1.169 guidance about which credential source to check
- [Bug] Long-session agent degradation: silent audit bypass, state confabulation, and withheld diagnostics
- [BUG] CLI bridge sessions intermittently throw 401 authentication_error on Max plan (v2.1.92)
- [BUG] remote-control sessions show "invalid api key - fix internal api key"
- [BUG] Anthropic disabled OAuth tokens for third-party apps
- [BUG] Invalid API key · Please run /login
- [BUG] Auth broken in all IDE extensions since 2.1.32 — "Invalid API key" / "Invalid bearer token" 401
- Context7 plugin registers duplicate MCP servers - one broken, one working
- [BUG] Persistent "Invalid API key" despite all troubleshooting on Windows 10/11
- [Bug] Crashes whiles working in latest version
- [BUG] Auth conflict: Both a token (CLAUDE_CODE_OAUTH_TOKEN) and an API key (apiKeyHelper) are set
- Invalid API key · Please run /login
- [BUG] Cluade Code does not work for some projects on PyCharm
- [BUG] Claude Code SSH Authentication
- Invalid API key · Please run /login
- Invalid API key · Please run /login
- Invalid API key · Please run /login
- Invalid API key · Please run /login
- [BUG] Crash when triggering a prompt provided by MCP
- Invalid API Key Authentication Failure
- [BUG] MCP Task Tool: Incorrect API Call Routing in Desktop Authentication Context
- [BUG] Claude code -p mode authentication does not work
- Invalid Claude Code API Key Configuration on MacOS Claude Code-credentials vs Claude Code
- Invalid API key · Please run /login
- [BUG] firstParty dispatch returns 401 "User not found" for a valid OAuth token that the standard API accepts (VSCode remote-SSH ext 2.1.185)
- [BUG] 401 "Invalid API key" authentication error on Windows with Claude Pro subscription
- Invalid API key · Please run /login
- [BUG] Support JWT tokens in API key validation - Currently rejecting valid Bearer tokens with "Invalid API Key format" error
- Invalid API key · Please run /login
- [BUG] /login with pasting auth code doesn't work
- Unintentional crashing of a Claude node..
- Invalid API key · Please run /login
- Invalid API key · Fix external API key
- Locked out of Claude Code - `/login` disabled
- [BUG] Opening session sidebar wipes API key auth for current session
- Auth errors in claude -p are written to stdout instead of stderr
- Claude Agent SDKがLiteLLMプロキシ使用時に非Anthropic形式のAPIキーを拒否する
- Invalid API key · Please run /login
- Invalid API key · Please run /login
- apiKeyHelper written to fix an unrelated MCP key, silently overriding claude.ai auth
- [BUG] ElevenLabs Agents MCP connector returns 401 invalid_api_key, persists through reconnect and app restart