claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Invalid API key · Please run /login

Open titofebus opened this issue 6 months ago • 9 comments

Bug Description I'm getting "Invalid API Key" even though I just logged in again, and again.. this seems to be only happening on one computer I SSH into. I have logged out and logged back in and restarted the computer. When I first got the error I was in the middle of a conversation and when i exited out it said I had consumed 99$ of api even though i am on the 200$ max plan.. also when logging in to check my api usage, it all says 0 (correctly)

Environment Info

  • Platform: darwin
  • Terminal: cursor
  • Version: 1.0.69
  • Feedback ID:

Errors

[{"error":"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\n    at file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1270:6454\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)","timestamp":"2025-08-05T21:49:53.163Z"}]

titofebus avatar Aug 05 '25 21:08 titofebus

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/5151
  2. https://github.com/anthropics/claude-code/issues/5167
  3. https://github.com/anthropics/claude-code/issues/5166

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

🤖 Generated with Claude Code

github-actions[bot] avatar Aug 05 '25 21:08 github-actions[bot]

No solutions on those duplicate issues!

timyal avatar Aug 06 '25 11:08 timyal

This issue is still happening I'm noticing it happens every day maybe 24 hours? The way I fix it is:

  1. Uninstall Claude Code
  2. Install 1.00.67
  3. LogIn
  4. /Exit
  5. Open Claude Code

This resolves the problem temporarily for at least 24 hours.

When first exiting CC after getting the message I get this:

Image

I am not using the API. I'm a MAX user. I do have a API account with usage limits just in case

titofebus avatar Aug 08 '25 12:08 titofebus

Update, Still having this issue daily. No permanent fix yet.

titofebus avatar Aug 10 '25 21:08 titofebus

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....

timyal avatar Aug 19 '25 21:08 timyal

I'm seeing this too if we can try to address this better.

Steve-Albers avatar Sep 01 '25 12:09 Steve-Albers

im getting this now too. first VS code, then cursor.. ive deleted all storage key files etc. nothing works. CLI works just fine in the IDE but this is a real problem that we need to address asap. its getting very messy with short term repair techniques, if any exist anymore..

who has an update, anybody?

wokipedia avatar Nov 24 '25 01:11 wokipedia

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.

github-actions[bot] avatar Dec 24 '25 10:12 github-actions[bot]

Commenting here as well since this feels a bit more recent. My coworker solved this issue via https://github.com/anthropics/claude-code/issues/64#issuecomment-2683207735

which we both think is a bit of an oddity fix-wise, but if it works for any of the other people struggling w/ this issue, hopefully it can unblock 'em...

j-weave avatar Jan 02 '26 20:01 j-weave