Troubleshooting · Cursor
Cursor: Request Failed With Status Code 401 — Anthropic Key Fix
A 401 inside Cursor chat means the provider answered and rejected the credentials: key and base URL mismatched, key revoked, or the wrong header reaching the endpoint. The fix path.
What you see
Request failed with status code 401Why it happens
- The key verified once but was later revoked or expired — Cursor keeps using it until the provider starts answering 401.
- The base URL override was changed after the key was saved, so the saved key now goes to an endpoint that has never seen it.
- The account behind the key was suspended or its access withdrawn.
How to fix it
- Re-check the pair as it exists right now: the override URL and the key must come from the same issuer. Fix whichever side changed.
- Test the exact key against the exact base URL with curl — it removes Cursor from the equation in one step.
- If curl also returns 401, the key itself is dead: check its status in the issuer's dashboard or reissue it.
Reproduce outside Cursor
curl https://api.apitoken.sale/v1/messages \
-H "x-api-key: sk-pool-•••" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-sonnet-5","max_tokens":32,"messages":[{"role":"user","content":"ping"}]}'Related searches
{"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"}}cursor 401 anthropic
FAQ
Cursor verified my key earlier — why 401 now?+
Verification is a snapshot. A key revoked afterwards, or a base URL changed afterwards, produces 401s on every later request even though the initial verify passed.
Is this Cursor's bug?+
Almost never. A 401 is the provider's answer passed through. Reproduce it with curl: if curl gets 401 too, the credentials are the problem.
What if curl succeeds but Cursor still gets 401?+
Then Cursor is sending different credentials than you think — re-open settings and re-paste the key with the override URL already enabled.