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

[Bug] Anthropic API Credential Restriction Preventing API Requests

Open chandarith-chea opened this issue 1 year ago • 102 comments

Bug Description I always got this message when request to do something: "This credential is only authorized for use with Claude Code and cannot be used for other API requests"

Environment Info

  • Platform: darwin
  • Terminal: WarpTerminal
  • Version: 1.0.120
  • Feedback ID: d283f24e-36b3-445f-a47c-2a3cd427c3fd

Errors

[{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"This credential is only authorized for use with Claude Code and cannot be used for other API requests.\"},\"request_id\":\"req_011CTQmv1MVzrMnxDP9yRrLF\"}\n    at i9.generate (file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:992:2412)\n    at IP.makeStatusError (file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1009:2131)\n    at IP.makeRequest (file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1009:5344)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async RJB.ZI1.showErrors (file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1919:29907)\n    at async ZI1 (file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1919:18054)\n    at async RJB (file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1919:29690)\n    at async file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1919:24439\n    at async aq0 (file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1919:4362)\n    at async u01 (file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1919:24409)","timestamp":"2025-09-23T05:24:32.974Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"This credential is only authorized for use with Claude Code and cannot be used for other API requests.\"},\"request_id\":\"req_011CTQmwFaHqwWFkrKLKXHox\"}\n    at i9.generate (file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:992:2412)\n    at IP.makeStatusError (file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1009:2131)\n    at IP.makeRequest (file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1009:5344)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async RJB.ZI1.showErrors (file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1919:29907)\n    at async ZI1 (file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1919:18054)\n    at async RJB (file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1919:29690)\n    at async file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1919:24439\n    at async aq0 (file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1919:4362)\n    at async u01 (file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1919:24409)","timestamp":"2025-09-23T05:24:49.873Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"This credential is only authorized for use with Claude Code and cannot be used for other API requests.\"},\"request_id\":\"req_011CTQnAR1BkGSfwnuM36VMN\"}\n    at i9.generate (file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:992:2412)\n    at IP.makeStatusError (file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1009:2131)\n    at IP.makeRequest (file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1009:5344)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async RJB.ZI1.showErrors (file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1919:29907)\n    at async ZI1 (file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1919:18054)\n    at async RJB (file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1919:29690)\n    at async file:///Users/macbookpro16m2max/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1919:24439\n    at async aq0 (file:///Users/macboo

Note: Error logs were truncated.

chandarith-chea avatar Sep 23 '25 05:09 chandarith-chea

started this morning

dcmumby avatar Sep 23 '25 06:09 dcmumby

same here Windows VSCode Using Claude Code > claude doctor ⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"This credential is only authorized for use with Claude Code and cannot be used for other API requests."},"request_id":"req_011CTQxWurzPBesaHzT67FW6"} UPD: relogin helped

romeo143 avatar Sep 23 '25 07:09 romeo143

I've tried running claude setup-token again and the issue still persists. Started this morning for me too.

ghostwriternr avatar Sep 23 '25 07:09 ghostwriternr

Yes, I see the same error. Yesterday it worked fine.

Image

AlexeyEfimchik avatar Sep 23 '25 08:09 AlexeyEfimchik

I see this error (Mac VSCode, using claude code)

Image

hibestil avatar Sep 23 '25 08:09 hibestil

Seems to be affecting zed through ACP too.

mikesimons avatar Sep 23 '25 08:09 mikesimons

My experience is that when Claude fixed Claude App and API connectivity errors, certain users are required to re-anthentic their account but the API error didn't prompt that. The workaround is to run claude /login

viper7882 avatar Sep 23 '25 08:09 viper7882

My experience is that when Claude fixed Claude App and API connectivity errors, certain users are required to re-anthentic their account but the API error didn't prompt that. The workaround is to run claude /login

This worked for me. Just re-login.

mtcorread avatar Sep 23 '25 08:09 mtcorread

My experience is that when Claude fixed Claude App and API connectivity errors, certain users are required to re-anthentic their account but the API error didn't prompt that. The workaround is to run claude /login

This worked for me. Just re-login.

Yes, work for me too with re-login.

chandarith-chea avatar Sep 23 '25 09:09 chandarith-chea

Not for me. After Re-Login it's the same

yngwi avatar Sep 23 '25 09:09 yngwi

Still failing after claude setup-token

clsung avatar Sep 23 '25 09:09 clsung

still failing after re-login here, but I still had an export for an existing CLAUDE_CODE_OAUTH_TOKEN. Once I removed that export and tried "claude /login" it worked for me.

apmontgo avatar Sep 23 '25 09:09 apmontgo

Also affects the Claude GitHub integration for PR reviews

dusalex avatar Sep 23 '25 11:09 dusalex

Hi, also fixed with claude /login, thanks

TheSegfault avatar Sep 23 '25 11:09 TheSegfault

Also having the problem seems today with OpCode (name was 'Claudia' before), re-logged in without any better result. It seems I can still use Claude Code by selecting Claude Sonnet 4 but not anymore using Claude Opus 4.1 where I do have this error 400.

3kynox avatar Sep 23 '25 12:09 3kynox

Confirming claude /login fixes this problem for me in Claude Code.

oshoma avatar Sep 23 '25 12:09 oshoma

Hi, Confirming as well that claude /logout and then claude /login fixes in Claude Code.

Chesars avatar Sep 23 '25 13:09 Chesars

I can confirm that logging out and then back in (claude /logout and then claude /login) resolved the issue. By the way, before it was fixed, I had access to Opus 4.1 despite being only on the Pro plan. Now back to normal.

martintomsik avatar Sep 23 '25 13:09 martintomsik

I found the cause of the problem, because after the claude code update, the recommended configuration was updated, but this recommended configuration is not applicable to Pro subscribers. You can use the /model command to see the model currently used by Claude Code, which will output:

│  Select Model                                                                │
│  Switch between Claude models. Applies to this session and future Claude     │
│  Code sessions. For custom model names, specify with --model.                │
│                                                                              │
│     1. Default (recommended)   Opus 4.1 for up to 50% of usage limits,       │
│                                then use Sonnet 4                             │
│     2. Opus                    Opus 4.1 for complex tasks · Reaches usage    │
│                                limits faster                                 │
│   ❯ 3. Sonnet                  Sonnet 4 for daily use ✔                      │
│     4. Opus Plan Mode          Use Opus 4.1 in plan mode, Sonnet 4           │
│                                otherwise

The default configuration uses the Opus 4.1 model, which is not available for the pro subscription, which is also the root cause of the error. Select "3. Sonnet", problem solving.

zorth44 avatar Sep 23 '25 14:09 zorth44

@zorth44 Thank you, this works! So it's only a problem for Pro users.

timotk avatar Sep 23 '25 14:09 timotk