API Token Route

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.

Updated: 2026-12-02

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

  1. 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.
  2. Check the key format: starts with sk-atr-, no spaces or newline, still present in the console.
  3. Check the base URL: exact host, no /v1, no extra path.
  4. Check the model ID against the catalog. Claude IDs use hyphens.
  5. Check the balance. Authentication errors and balance errors are different failures.
  6. Check connectivity to the host. A proxy or firewall that blocks api.apitokenroute.com looks like a client failure.

Error table

What you seeWhat it meansFix
401 authentication_errorKey missing, malformed, or deleted; wrong variable or headerPut the key in ANTHROPIC_AUTH_TOKEN, reopen the shell, or create a new key.
403The request was rejectedCheck the key status in the console.
400 model_not_availableThe model ID is not in the catalogUse an exact catalog ID; use hyphens, not dots.
400 or 402 wallet balance is insufficientBalance cannot cover the requestTop up. Long-context requests reserve their maximum cost first.
404 or connection errorBase URL is wrong, often /v1 added to the Anthropic URLUse https://api.apitokenroute.com exactly.
429Requests-per-minute limitWait for retry-after, then retry with backoff.
529 overloaded_errorUpstream capacity, not your key or balanceRetry 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:

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 wroteUse instead
claude-opus-5.5claude-opus-5-5
claude-sonnet-5.5claude-sonnet-5-5
claude-sonnet-4-5claude-sonnet-4-6 or claude-sonnet-5-5
gpt-4o, gpt-4o-minigpt-5.5, gpt-5.4-mini
gemini-2.5-flashgemini-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.