Home / Guides / Claude Code troubleshooting: 401, 400 model ID, 529, balance and base URL
Claude Code troubleshooting: 401, 400 model ID, 529, balance and base URL
Check the four environment settings first. They cause more failures than the Claude Code installation itself.
For Claude Code, ANTHROPIC_BASE_URL must be https://api.apitokenroute.com with no /v1, ANTHROPIC_AUTH_TOKEN must hold your sk-atr- key, ANTHROPIC_API_KEY must be empty, and the model ID must exist in the catalog. Fix those four before reinstalling Claude Code or changing your network.
The correct environment
export ANTHROPIC_BASE_URL="https://api.apitokenroute.com"
export ANTHROPIC_AUTH_TOKEN="sk-atr-..."
export ANTHROPIC_API_KEY=""Why ANTHROPIC_API_KEY must be empty: when it is set, Claude Code asks whether to use that custom key, defaults to No, and pressing Enter sends you to the official Anthropic login. The gateway key goes in ANTHROPIC_AUTH_TOKEN.
Optionally set a default model, for example export ANTHROPIC_MODEL=claude-opus-5-5. Use a catalog ID with hyphens.
Windows PowerShell uses the same values:
$env:ANTHROPIC_BASE_URL="https://api.apitokenroute.com"
$env:ANTHROPIC_AUTH_TOKEN="sk-atr-..."
$env:ANTHROPIC_API_KEY=""Check in this order
- Read the values in the shell that launches Claude Code:
echo $ANTHROPIC_BASE_URL,echo $ANTHROPIC_AUTH_TOKEN,echo "[$ANTHROPIC_API_KEY]". On PowerShell use$env:NAME. - Check the key format: starts with
sk-atr-, no spaces or newline, still present in the console. - Check the base URL: exact host, no
/v1, no extra path. - Check the model ID against the catalog. Claude IDs use hyphens.
- Check the balance. Authentication errors and balance errors are different failures.
- Check connectivity to the host. A proxy or firewall that blocks
api.apitokenroute.comlooks like a client failure.
Error table
| What you see | What it means | Fix |
|---|---|---|
| 401 authentication_error | Key missing, malformed, or deleted; wrong variable or header | Put the key in ANTHROPIC_AUTH_TOKEN, reopen the shell, or create a new key. |
| 403 | The request was rejected | Check the key status in the console. |
| 400 model_not_available | The model ID is not in the catalog | Use an exact catalog ID; use hyphens, not dots. |
| 400 or 402 wallet balance is insufficient | Balance cannot cover the request | Top up. Long-context requests reserve their maximum cost first. |
| 404 or connection error | Base URL is wrong, often /v1 added to the Anthropic URL | Use https://api.apitokenroute.com exactly. |
| 429 | Requests-per-minute limit | Wait for retry-after, then retry with backoff. |
| 529 overloaded_error | Upstream capacity, not your key or balance | Retry with backoff or switch model. Streaming helps when the client times out waiting for the first token. |
401: authentication
Common causes, in order of frequency:
- The key is in
ANTHROPIC_API_KEYinstead ofANTHROPIC_AUTH_TOKEN. Claude Code then prompts for a custom key and defaults to the official login. - The value was copied with a trailing space or newline.
- The key was deleted or rotated in the console.
- The variable was set with
setxbut the current window was not reopened.
Verify the key independently with the model list. This request does not spend model tokens:
curl https://api.apitokenroute.com/v1/models -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN"If this returns 200, the key is valid and the problem is in Claude Code's environment or header.
400 model ID and the /v1 mistake
Claude model IDs use hyphens: claude-opus-5-5, not claude-opus-5.5. Common old names and their replacements:
| You wrote | Use instead |
|---|---|
claude-opus-5.5 | claude-opus-5-5 |
claude-sonnet-5.5 | claude-sonnet-5-5 |
claude-sonnet-4-5 | claude-sonnet-4-6 or claude-sonnet-5-5 |
gpt-4o, gpt-4o-mini | gpt-5.5, gpt-5.4-mini |
gemini-2.5-flash | gemini-3.5-flash |
The base URL is the other half of this error. Anthropic clients need https://api.apitokenroute.com without /v1; OpenAI-compatible clients need https://api.apitokenroute.com/v1. Adding /v1 to the Anthropic URL produces 404s or connection errors, not a model error.
Also check the endpoint: /v1/responses only serves GPT models. Claude requests there return 400. Use /v1/messages.
529, 429 and balance
529 overloaded_error means the upstream provider is saturated. The key, base URL and balance are probably fine. Retry with exponential backoff or switch to another Claude model in the catalog. If the client times out waiting for the first token, stream the response as well; the server accepts requests up to 600 seconds.
429 is the per-account requests-per-minute limit, not a concurrency limit. Read the retry-after header and wait that long before retrying. Bulk jobs should add their own queue and backoff.
Insufficient balance returns 402 on the Anthropic format, and may surface as 400 in OpenAI-format clients. Long-context requests reserve their maximum possible cost first, so a request can fail while a few dollars remain. Top up and retry; a key or URL change will not help.
What these settings do not fix
Pointing Claude Code at the gateway does not bypass Anthropic account rules, subscriptions, KYC, regional availability or provider policies. If the gateway returns an authentication or quota error, changing the client will not change the answer.
If all four settings are correct and requests still fail, contact support with the request time, model ID, HTTP status and request ID. Do not send the API key.
Related: Anthropic native API, API integration guide, Claude Code setup, pricing.
FAQ
Should I set ANTHROPIC_API_KEY?
No. Leave it empty. Put the gateway key in ANTHROPIC_AUTH_TOKEN; a set ANTHROPIC_API_KEY sends Claude Code to the official Anthropic login prompt.
Does the Anthropic base URL include /v1?
No. Use https://api.apitokenroute.com. The SDK adds /v1/messages itself. OpenAI-compatible clients do need /v1.
The key works in curl but Claude Code returns 401. Why?
The variable is probably set in a different shell, named ANTHROPIC_API_KEY instead of ANTHROPIC_AUTH_TOKEN, or contains trailing whitespace. Check it in the same terminal that launches Claude Code.
Why does claude-opus-5.5 return 400?
Claude IDs use hyphens. Use claude-opus-5-5.
Is 529 my fault?
No. 529 means upstream capacity is exhausted. Retry with backoff, try another model, or stream the response.
I have credit but get insufficient balance. Why?
Long-context requests reserve their maximum possible cost before running. Top up enough to cover the reservation, or shorten the request.
Does this bypass my Claude subscription limits?
No. It routes API calls to a gateway; it does not bypass account rules, subscriptions, KYC, regional availability or provider policies.