Troubleshooting · Claude Code

Claude Code API Error 402 billing_error — Insufficient Balance

Claude Code prints API Error: 402 billing_error when the prepaid balance cannot cover the request. Top up; do not retry 402 as a rate limit.

What you see

API Error: 402 {"type":"error","error":{"type":"billing_error","message":"insufficient balance or key spending limit reached for this request"}}

Why it happens

  • The prepaid balance on the key does not cover the request just submitted.
  • The key has a spending limit and has reached it, even though the account still has balance.
  • A pending top-up is not spendable until it is credited.

How to fix it

  • Top up any whole-dollar amount and retry after the payment is credited. Backoff never resolves a 402.
  • If this key has a spending limit, raise or remove it.
  • Read the live balance with the same key. Branch on HTTP 402 and error.type billing_error.

Check the balance for this key

curl https://router.apitoken.sale/balance \
  -H "x-api-key: $ANTHROPIC_API_KEY"

Related searches

  • claude code 402
  • claude code insufficient balance

FAQ

Is 402 the same as 429?+
No. 429 is per-minute throughput and is retryable. 402 is empty prepaid balance. Honour Retry-After on 429. Top up on 402.
Will Claude Code recover from 402 by itself?+
No. Retries cannot credit a balance. Top up, then send the request again.
Why did a request fail while the dashboard still shows some balance?+
The remaining number can be the account balance while this key has already hit its spending limit. Raise the key limit or top up.

Skip the broken setup

apiToken.sale serves the standard Anthropic API — same models, same SDKs, one prepaid balance. Point your tool's base URL at it, and the config on this page works as written.