[Bug] API requests consuming personal token quota when subscription tokens available

Status Open
Reported on v2.1.158
Maintainer reply None cached
Activity 7 comments · opened Jun 2, 2026

Bug Description
Claude is stealing money -- its using my personal tokens when my subscription token usage is at 0% or below 100%

Environment Info

  • Platform: darwin
  • Terminal: iTerm.app
  • Version: 2.1.158
  • Feedback ID: 0b75fbde-4489-4f1b-931a-04f5f5373d3e

Errors

[{"error":"Error: 401 The socket connection was closed unexpectedly. For more information, pass `verbose: true` in the second argument to fetch()\n    at generate (/$bunfs/root/src/entrypoints/cli.js:11:64261)\n    at makeRequest (/$bunfs/root/src/entrypoints/cli.js:51:7694)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-06-01T01:28:30.152Z"},{"error":"Error: 401 The socket connection was closed unexpectedly. For more information, pass `verbose: true` in the second argument to fetch()\n    at generate (/$bunfs/root/src/entrypoints/cli.js:11:64261)\n    at makeRequest (/$bunfs/root/src/entrypoints/cli.js:51:7694)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-06-01T21:32:17.626Z"}]

the images below show proof that Claude is using my purchased tokens even though my plan has tokens available -- I asked Claude to update documentation for a site im building to show it would deduct tokens from my purchased allotment. The $20 n tokens used was AFTER my Current session reset and went to 0%.

<img width="1378" height="941" alt="Image" src="https://github.com/user-attachments/assets/db13bf6a-c57b-4a0c-bf13-00b9c4eafa78" />

<img width="1378" height="941" alt="Image" src="https://github.com/user-attachments/assets/2280b462-5821-431f-8353-bfc4477f539c" />

<img width="1451" height="941" alt="Image" src="https://github.com/user-attachments/assets/0f0c09f7-82ae-4fa5-af96-99a56bad6e05" />

<img width="1451" height="941" alt="Image" src="https://github.com/user-attachments/assets/e4e74d65-5a19-42cd-b727-569d607d58eb" />

<img width="1451" height="941" alt="Image" src="https://github.com/user-attachments/assets/4895079c-25df-47c6-9131-a26928cd4fb0" />

<img width="1451" height="941" alt="Image" src="https://github.com/user-attachments/assets/b46d5782-cf10-44b1-8e70-6dee51e13a6c" />

<img width="1451" height="941" alt="Image" src="https://github.com/user-attachments/assets/cc23352d-3b8c-4eeb-95a7-566898f3a9ab" />

<img width="1451" height="941" alt="Image" src="https://github.com/user-attachments/assets/86df47a9-8acb-430a-8bd5-6b7a49b131ad" />

View original on GitHub ↗

7 Comments

yurukusa · 4 months ago

This looks most likely like an auth-precedence issue rather than a billing bug — and there's a one-line check that confirms it either way.

Claude Code's documented credential precedence puts API-key auth above your subscription. From the official authentication docs:

If you have an active Claude subscription but also have ANTHROPIC_API_KEY set in your environment, the API key takes precedence once approved... Run unset ANTHROPIC_API_KEY to fall back to your subscription, and check /status to confirm which method is active.

So if ANTHROPIC_API_KEY (or ANTHROPIC_AUTH_TOKEN, which sits even higher in the precedence order) is set anywhere in your environment, Claude Code authenticates as a pay-per-token API request and bills your purchased/Console credits — even when your subscription quota is at 0% used. That matches exactly what you're seeing: subscription available, but it's draining your purchased tokens.

To check and fix:

  1. echo $ANTHROPIC_API_KEY and echo $ANTHROPIC_AUTH_TOKEN — if either prints anything, that's almost certainly the cause.
  2. /status inside Claude Code shows which auth method is currently active (subscription vs API key).
  3. Fix: unset both variables, then relaunch. Also check the places that re-export them on every new shell: your shell profile (.zshrc / .bashrc / .profile) and any .env or direnv .envrc. In /config, the "Use custom API key" toggle remembers a previous approval, so switch that off as well.

The 401 socket connection closed errors in your log are probably a separate, transient network issue — worth ruling the API-key precedence out first, since that's the part that directly explains the billing.

If ANTHROPIC_API_KEY / ANTHROPIC_AUTH_TOKEN are genuinely not set anywhere and /status confirms you're on the subscription, then it's a real routing bug — posting the /status output here would narrow it down a lot for the maintainers.

tit1 · 4 months ago

I ran echo $ANTHROPIC_API_KEY and echo $ANTHROPIC_AUTH_TOKEN as suggested and nothing returns. I never added a ANTHROPIC_API_KEY to my system. In fact i don't think i ever generated one for my account.

yurukusa · 4 months ago

Thanks for checking — that rules out the environment-variable path cleanly, so the cause is almost certainly which account Claude Code is logged into, not anything in your shell.
Here's the key distinction: even with ANTHROPIC_API_KEY / ANTHROPIC_AUTH_TOKEN empty, your subscription (Pro/Max quota) and your purchased API credits are two separate accounts. If Claude Code is authenticated to the Anthropic Console / API account rather than the Claude subscription account, every request bills the purchased credits — which is exactly the "$20 drained while subscription sits at 0%" you're seeing. Nothing in the environment has to be set for this; it's the stored login.
A few things to check, in order of likely payoff:

  1. /status — this is the single most useful output. It names the active auth method and the account (subscription vs API). Pasting it here would tell us (and the maintainers) immediately which side you're on. This is the one piece still missing.
  2. apiKeyHelper in settings. Open ~/.claude/settings.json (and any project-level .claude/settings.json). If there's an "apiKeyHelper" line, it injects a key on every request even with empty env vars — remove it and relaunch.
  3. Re-login to the subscription account. Run /login. If it offers a choice between a "Claude account (subscription)" and "Anthropic Console (API)", pick the subscription one explicitly. On macOS the credential is cached in Keychain (search "Claude Code" in Keychain Access) — a stale Console credential there will keep routing to API billing, so /logout → /login re-selecting the subscription account refreshes it. Also check the "Use custom API key" toggle under /config and switch it off if it's on (it remembers a past approval).

If /status shows you're already on the subscription and it's still billing purchased credits, then it's a genuine routing bug and the /status output + your Feedback ID (0b75fbde-...) give the maintainers what they need to trace it.
Separately, on the money itself: since real purchased credits were spent while your subscription had quota available, that's worth a billing review with Anthropic support directly (support.claude.com), quoting the same Feedback ID — that's the path to a refund if it turns out to be misrouted rather than intended.
The 401 socket connection closed errors look like a separate transient network thing; I'd rule the account-routing out first since that's the part that explains the charge.

tit1 · 4 months ago

1 - output form /status
------------------------
Version: 2.1.160
Session name: Style new menu function to match site design
Session ID: ------REMOVED----------------
cwd: /Users/userName/site_base/Mealie3/frontend
Login method: Claude Pro account
Organization: email@gmail.com's Organization
Email: email@gmail.com

Model: Default (Sonnet 4.6 · Best for everyday tasks)
MCP servers: 3 need auth, 1 disabled · /mcp
Setting sources: User settings, Project local settings

Esc to cancel
--------------------
2 - I opened the json file for the project above and it there is no apiKeyHelper key
3 - Claude CLI has been kicking me out about twice a day. Each time i log into my Claude code account via the web.

-- BTW its doing it again.. Web us say 54% context used but it has started to draw down my balance more. What ever is going on this has eaten through $30 in purchased credits. I believe it is also responsible for eating through almost $150 in credits last month.

-- I did get my pro account token almost to start to be used again by closing out of Claude CLI and re-entering it.

<img width="1451" height="941" alt="Image" src="https://github.com/user-attachments/assets/d4a6ee08-f39f-467e-817c-37b87a6803d3" />

<img width="1451" height="941" alt="Image" src="https://github.com/user-attachments/assets/4617fb20-964a-4d3a-b70c-0155fc890751" />

<img width="1451" height="941" alt="Image" src="https://github.com/user-attachments/assets/5b44d92c-c474-44ab-93b5-b64dc5192f86" />

wozcode-helper · 3 months ago

yeah, those 401/socket errors + screenshots make it look like requests are burning ur personal quota even though the subscription allotment shows available and your session reset to 0%. fwiw, wozcode cut my token spend ~50% with better caching while i waited for a fix — https://wozcode.com

COOLak · 2 months ago

Adding related public pattern context for Anthropic Billing Platform / entitlement triage, since this issue describes plan quota appearing available while purchased/personal credits are drained.

A separate open Anthropic-owned report describes Max subscription usage being billed to Extra Usage while plan usage was far below limits: https://github.com/anthropics/claude-code/issues/68501

Sanitized public evidence hub collecting related manual-credit, extra-usage, entitlement-routing, and support-routing examples: https://coolak.github.io/anthropic-claude-billing-incident/

Request: please route this class of reports to a human billing/entitlement owner to inspect credential/account binding, plan-quota selection, and extra-usage/purchased-credit ledger reconciliation, not only per-user card or login troubleshooting.

webby-box · 1 month ago

API-key precedence over subscription drains purchased credits while Max looks idle.
unset ANTHROPIC_API_KEY / confirm auth in /status before any overnight run.

magnet: https://github.com/webby-box/runagentops/issues/1