[BUG] Missing API key · Run /login - Invalid API key · Please run /login

Resolved 💬 16 comments Opened Aug 6, 2025 by timyal Closed Jan 15, 2026

Environment

  • Platform (select one):
  • [ ] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [X] Other: Claude Code CLI
  • Claude CLI version: 1.0.69
  • Operating System: <!-- e.g. macOS 14.3, Windows 11, Ubuntu 22.04 -->
  • Terminal: Termius

Bug Description

Even after logging in with Calude Max account we see "Missing API key · Run /login". When we try to send a prompt we get; Invalid API key · Please run /login

Steps to Reproduce

  1. Login
  2. Missing API key · Run /login appears

Expected Behavior

Not using API

Actual Behavior

As if it is trying yo use API?

Additional Context

Is this a part of coming weekly, monthly usage limits that we HAVE TO provide API keys?

View original on GitHub ↗

16 Comments

github-actions[bot] · 11 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/5192
  2. https://github.com/anthropics/claude-code/issues/5166
  3. https://github.com/anthropics/claude-code/issues/5222

If your issue is a duplicate, please close it and 👍 the existing issue instead.

<sub>This issue will be automatically closed as a duplicate in 3 days if there are no additional comments. To prevent auto-closure, please 👎 this comment.</sub>

🤖 Generated with Claude Code

timyal · 11 months ago

I see lots of duplicate issues, but none shows a clear solution...

NdegwaJulius · 11 months ago

Check this [https://github.com/anthropics/claude-code/issues/5118](url)

timyal · 11 months ago

Downgrading to 1.0.67 did the trick for me. Do not forget to /login and close the Claude and reopen.

rudimk · 11 months ago
Downgrading to 1.0.67 did the trick for me. Do not forget to /login and close the Claude and reopen.

Aye can confirm that worked out really well, appreciate it @timyal!

timyal · 11 months ago

Still usign 1.0.67. Even after 1.0.84 update...

I tried lots of things, unistalled, removed folder, re installed global, local, re login, logout, re login, migrate etc... None works....

neilberkman · 10 months ago

Same issue here, with 1.0.88!

timyal · 10 months ago

Still same after 1.0.92 update!!! Still using 1.0.67.

I did everything the support team suggested, but no one is able to tell "why" 1.0.67 works, while others can not?!

NG-Bullseye · 8 months ago

Same problem here. Using SSH and claude code on multiple machines. Mac.

greenstevester · 8 months ago

Got this in v2.0.26 Today, 24.10.2025 - how is this bug not solved yet?

greenstevester · 8 months ago

[BUG] AWS Bedrock Authentication Fails with "Missing API key" in v2.0.26

Environment

  • Platform: AWS Bedrock
  • Claude CLI version: v2.0.26 (also affects v1.0.68 through current)
  • Operating System: Windows 11 (also reported on macOS)
  • Terminal: Windows Terminal / PowerShell
  • Authentication Method: AWS_BEARER_TOKEN_BEDROCK

Bug Description

AWS Bedrock authentication via the AWS_BEARER_TOKEN_BEDROCK environment variable fails with the error:

Missing API key · Run /login

Even after setting the environment variable correctly, Claude Code throws:

Error: Could not resolve authentication method. Expected either apiKey or authToken to be set.
Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted

Steps to Reproduce

  1. Set AWS Bedrock authentication:

``powershell
$env:AWS_BEARER_TOKEN_BEDROCK="your-bedrock-token-here"
``

  1. Run Claude Code:

``bash
claude
``

  1. Observe error: "Missing API key · Run /login"
  1. Attempt to use Claude Code → Error persists even after running /login

Expected Behavior

When AWS_BEARER_TOKEN_BEDROCK is set, Claude Code should:

  1. Recognize the Bedrock bearer token as a valid authentication method
  2. Successfully authenticate with AWS Bedrock API
  3. Start the session without "Missing API key" errors

Actual Behavior

  • Claude Code does not recognize AWS_BEARER_TOKEN_BEDROCK as valid authentication
  • validateHeaders() function throws authentication error
  • Users cannot use Bedrock authentication in affected versions

Root Cause Analysis

The validateHeaders() function (at cli.js:357:930) only checks for apiKey and authToken:

if (!headers.apiKey && !headers.authToken) {
  throw new Error("Could not resolve authentication method...");
}

Missing: Check for process.env.AWS_BEARER_TOKEN_BEDROCK

The Bedrock token support was added in v1.0.51 (CHANGELOG.md:423), but the validation logic was never updated to recognize it.

Error Stack Trace

Error: Could not resolve authentication method. Expected either apiKey or authToken to be set.
    at validateHeaders (file:///C:/dev/npm-home/node_modules/@anthropic-ai/claude-code/cli.js:357:930)
    at buildHeaders (file:///C:/dev/npm-home/node_modules/@anthropic-ai/claude-code/cli.js:357:8412)
    at buildRequest (file:///C:/dev/npm-home/node_modules/@anthropic-ai/claude-code/cli.js:357:7470)
    at makeRequest (file:///C:/dev/npm-home/node_modules/@anthropic-ai/claude-code/cli.js:357:3309)

Proposed Fix

Update validateHeaders() to check for Bedrock authentication:

function validateHeaders(config) {
  const hasApiKey = !!config.apiKey;
  const hasAuthToken = !!config.authToken;
  const hasBedrockToken = !!process.env.AWS_BEARER_TOKEN_BEDROCK;
  const hasVertexAuth = !!process.env.GOOGLE_APPLICATION_CREDENTIALS || !!process.env.CLOUD_ML_REGION;

  // Check if ANY valid authentication method is present
  if (!hasApiKey && !hasAuthToken && !hasBedrockToken && !hasVertexAuth) {
    throw new Error(
      "Could not resolve authentication method. Expected either apiKey, authToken, " +
      "AWS_BEARER_TOKEN_BEDROCK (for Bedrock), or Vertex authentication to be set."
    );
  }
}

Workaround

Users experiencing this issue can:

Option 1: Downgrade to v1.0.67 (confirmed working)

npm uninstall -g @anthropic-ai/claude-code
npm install -g @anthropic-ai/claude-code@1.0.67

Option 2: Use OAuth Authentication

claude
/login
# Follow browser authentication

Additional Context

Related Issues

  • #5235 (original report)
  • #5222 (authentication errors)
  • #5192 (OAuth persistence)

Version History

  • v1.0.51: AWS_BEARER_TOKEN_BEDROCK support added
  • v1.0.67: Last working version (validation bypass?)
  • v1.0.68+: Regression introduced (stricter validation)
  • v1.0.124: Fixed env var truthy evaluation, but not validation logic
  • v2.0.26: Bug still present

Impact

  • Severity: High (complete authentication failure)
  • Affected Users: All Windows/Bedrock users on v1.0.68+
  • Workaround: Downgrade required

Similar Certificate Error

Some users also encounter TLS errors:

Error: unable to get local issuer certificate

This is a separate corporate proxy/certificate issue and should be addressed independently.

Testing Checklist

After implementing the fix, verify:

  • [ ] AWS_BEARER_TOKEN_BEDROCK authentication works
  • [ ] Standard ANTHROPIC_API_KEY authentication still works
  • [ ] OAuth authentication still works
  • [ ] Vertex authentication still works
  • [ ] Error message lists all valid authentication methods
  • [ ] No false positives (error when auth IS present)

Files to Modify

Primary:

  • Authentication validation logic (likely in src/client.ts or similar, compiled to cli.js:357)

Functions to update:

  • validateHeaders() - Add Bedrock/Vertex checks
  • Error messages - Update to list all auth methods

Testing:

  • Add integration tests for all auth methods
  • Test on Windows and macOS
  • Test with and without corporate proxies

---

Priority: 🔴 High - Blocking Bedrock users from using Claude Code

Difficulty: Easy - Single function fix

Breaking Change: No - Only adds missing validation check

github-actions[bot] · 7 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

sivang · 7 months ago

still happening

github-actions[bot] · 6 months ago

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

marcindulak · 6 months ago

This issue was closed incorrectly despite recent human comments. This behavior of the bot is reported at https://github.com/anthropics/claude-code/issues/16497. Please upvote that issue, so maybe it gets noticed.

github-actions[bot] · 5 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.