Skip to content

Claude Code API Error: what each message means behind a gateway

An API Error line in Claude Code means a request to the model endpoint failed, after Claude Code's own retries where they apply: per its errors reference (checked 2026-12-04), Claude Code retries transient failures up to 10 times with exponential backoff, and for a server error it shows the status code and the endpoint's message, as in API Error: 500 Internal server error. When ANTHROPIC_BASE_URL points at a gateway such as Router One, that endpoint is the gateway: the reference says the text after a 401 is the gateway's message rather than Anthropic's, and that the closing sentence of a 5xx or 529 error names the gateway host instead of status.claude.com. Find your message in the table below: each row points to a section on this page or to the page with the full fix.

Find your message

Messages as Claude Code prints them, per its errors reference (checked 2026-12-04), except Router One's own messages: the model '<id>' message in the first row, and the 402 and 403 rows, since the reference has no entry for those statuses behind ANTHROPIC_BASE_URL:

Find your message
What you seeWhat it means behind a gatewayGo to
API Error: 400 with model '<id>' must be called via /v1/chat/completionsRouter One does not serve that model ID on /v1/messages, the endpoint Claude Code calls400 section
API Error: 400 ... context_management: Extra inputs are not permitted, or a 400 naming defer_loading or tool_referenceA beta field Claude Code sends was not accepted on the way to the model400 section
API Error: 400 ... "thinking.type.enabled" is not supported for this modelYour Claude Code version is older than the selected model needs400 section
Not logged in · Please run /login, Invalid auth token · Fix external auth token, Please run /login · API Error: 401 Invalid authentication credentialsNo usable credential reached the session, or the gateway refused the key401 section and https://router.one/claude-code-403
A 402 whose message starts with insufficient balance, api key spend cap reached, api key daily budget reached or api key monthly budget reachedRouter One's wallet, the key's spend cap or the key's period budget cannot cover the request402 section
A 403 whose message starts with model "<id>" is not in this API key's model allowlistThe Router One key has a model allowlist without this model403 section
API Error: Request rejected (429) · …, API Error: Server is temporarily limiting requests (not your usage limit), You've hit your session limitA rate limit, or the usage limit of a Claude subscription sign-inhttps://router.one/claude-code-usage-limit, then the 429 section
API Error: Repeated 529 Overloaded errorsThe model is at capacity for now; not a usage limit429 and 529 section
API Error: 500 Internal server error, API Error: 502 Bad GatewayA server-side failure at the gateway or behind it5xx section
Request timed out, API Error: No response from API, API Error: Connection lost mid-response. The response above may be incomplete.No complete response arrived in time, or the stream ended early5xx section
Unable to connect to API. Check your internet connection, Connection refused — a firewall or proxy may be blocking it (ConnectionRefused)No HTTP response at all: check the address in ANTHROPIC_BASE_URL and the network pathhttps://router.one/api-connection-troubleshooting
Prompt is too long, Context limit reached · /compact or /clear to continueThe conversation no longer fits the model's context windowhttps://router.one/claude-code-context-window

Which side sent it

A line with a status code after API Error: carries the message of the endpoint Claude Code called, which behind ANTHROPIC_BASE_URL is the gateway or the model behind it. Request timed out, API Error: No response from API and Unable to connect to API mean no complete HTTP response reached Claude Code; match any other line in the table above. To see the raw answer, send one small request with the same base URL, key and model from the shell that starts claude, with the placeholder replaced by the model ID Claude Code was using:

check-gateway.sh
echo "$ANTHROPIC_BASE_URL"   # expect https://api.router.one, with no /v1
curl -i -X POST "$ANTHROPIC_BASE_URL/v1/messages" \
  -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"model": "<model-id>", "max_tokens": 16,
       "messages": [{"role": "user", "content": "ping"}]}'
  • Router One returns /v1/messages errors in the Anthropic envelope {"type":"error","error":{...}}, and every response carries an X-Request-ID header: give support that value when the body has no request_id.
  • A request refused at Router One's own checks (401 for the key, 402 for funds or the key's cap or budget, 403 for the key's allowlist, 429 for the key's or account's limits, 400 or 404 for the model ID or endpoint) has no row in Dashboard → Logs and is not billed. A request that reached a model normally has a row with its status; a stream that failed before any output may not.
  • If the test request reaches a model, it follows the same billing rules as any other request.

400: model ID, endpoint and beta fields

The quoted strings below come from Claude Code's errors reference (checked 2026-12-04), except the first, which is Router One's own message:

  • model '<id>' must be called via /v1/chat/completions: POST /v1/messages, the endpoint Claude Code calls, serves the currently listed Claude-family models and the DeepSeek ids deepseek-v4.1-flash and deepseek-v4-flash, and Router One refuses other chat-model IDs there before any model is called. Pick a model whose detail page on /models lists POST /v1/messages and set it with ANTHROPIC_MODEL or /model.
  • API Error: 400 ... context_management: Extra inputs are not permitted, or a 400 naming defer_loading or tool_reference: Claude Code sends these beta fields with the anthropic-beta header that enables them, and the reference says the 400 appears when the header is dropped on the way or the field reaches a service that does not accept it. Router One passes the anthropic-beta header through as sent; whether each model behind it accepts these fields was not checked for this page. Anthropic's fixes: update to v2.1.304 or later, which retries once without context_management, or v2.1.305 or later, which retries without the tool search fields; as a fallback, set CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 before launching.
  • API Error: 400 ... "thinking.type.enabled" is not supported for this model: Claude Code is older than the minimum for the selected model. Run claude update and restart; the reference lists v2.1.219 for Opus 5, v2.1.280 for Opus 5.5 and v2.1.284 for Sonnet 5.5. Through Router One, a legacy thinking {"type": "enabled"} sent to either ID of Claude Opus 5.5 or Claude Sonnet 5.5 is rewritten to {"type": "adaptive"} before the call, per Router One's API compatibility facts (https://router.one/facts/api-compatibility.md); update Claude Code anyway.
  • API Error: 400 ... max_tokens must be greater than thinking.budget_tokens: raise CLAUDE_CODE_MAX_OUTPUT_TOKENS above the thinking budget.
  • API Error: 400 due to tool use concurrency issues. Run /rewind to recover the conversation.: the conversation history reached the API in an inconsistent state. If you use Opus 4.7 or Opus 4.8, run claude update first: the reference says versions before v2.1.156 can trigger this error during normal tool use, and /rewind does not clear it. After that, or with any other model, run /rewind as the message says, or press Esc twice, to step back to a checkpoint before the corrupted turn.
  • API Error: 400 Request rejected as unprocessable by the model (too many or oversized images, or unsupported parameters): if it keeps appearing in a conversation with images or documents, press Esc twice to step back past the turns that added them, or run /clear.

401 and sign-in messages

Behind a gateway, the errors reference (checked 2026-12-04) says the text after 401 is the gateway's message rather than Anthropic's, and /login does not change it: fix the credential the gateway expects. For Router One, that is a key starting with sk- in ANTHROPIC_AUTH_TOKEN, which Claude Code sends as Authorization: Bearer, with ANTHROPIC_BASE_URL set to https://api.router.one (no /v1); ANTHROPIC_API_KEY is not required. Router One returns its 401 before any model is called. Each sign-in message, such as Not logged in · Please run /login or Invalid auth token · Fix external auth token, is mapped to its fix on the Claude Code 401 & 403 checklist (https://router.one/claude-code-403). If all requests still fail with a 401 once the key is right, the reference points at the tool search fields covered in the 5xx section. Set these in the shell you start claude from, then restart claude:

claude-code-env.sh
export ANTHROPIC_BASE_URL=https://api.router.one
export ANTHROPIC_AUTH_TOKEN=sk-your-router-one-key
unset ANTHROPIC_API_KEY

402: wallet, key spend cap or period budget

Claude Code's errors reference (checked 2026-12-04) has no entry for HTTP 402, so this page does not show how Claude Code prints that line. On Router One, a 402 is a billing_error returned before any model is called, with no row in Dashboard → Logs and no charge. On /v1/messages the 402s in the table below carry no code, so read how the message starts:

402: wallet, key spend cap or period budget
Message starts withWhat cannot cover the requestWhat to do
insufficient balanceThe wallet cannot cover a request billed to itTop up in Dashboard → Deposit
api key spend cap reachedThe key's cumulative wallet cap (maxSpend)Raise or clear maxSpend in Dashboard → API Keys; a top-up does not lift it
api key daily budget reached or api key monthly budget reachedThe key's daily or monthly budget; the message gives the reset timeWait for the reset, or raise or clear the budget in Dashboard → API Keys; a top-up does not raise it
  • A billed request draws plan quota when your plan covers that model and has quota left, and the wallet otherwise, so insufficient balance can also appear on a subscription: for a model outside the plan, or once the plan quota is used. /pricing lists what each plan covers.
  • A 402 is not a rate limit: Router One answers with 402 when the wallet, the key's cap or its budget cannot cover the request, and that can happen before any of them is used up. A request is refused when what is available does not cover the minimum it has to reserve, and requests still running hold part of the funds until they settle (X-Billing-Funds-Reason wallet_reserved, key_reserved or key_period_reserved): wait for them to finish and send again before you top up or raise a limit.
  • The X-Billing-Funds-Reason value behind each case is in the error-code reference (https://router.one/llm-api-error-codes); caps, budgets and allowlists are explained in the key controls guide (https://router.one/llm-api-key-budgets).

403: the key's model allowlist

Claude Code's errors reference (checked 2026-12-04) has a gateway 403 entry only for a Claude apps gateway sign-in, whose line starts with Gateway refused the request. On Router One, check the key's model allowlist first: when the key has one and the model is not on it, Router One returns 403 permission_error with code API_KEY_MODEL_NOT_ALLOWED, and the message starts with model "<id>" is not in this API key's model allowlist (observed 2026-12-01). The request never reaches a model and has no row in Dashboard → Logs. Add the model to the key's allowlist in Dashboard → API Keys, or switch to a model already on it. With ANTHROPIC_AUTH_TOKEN set as in the 401 section, Claude Code runs background tasks on the main model unless ANTHROPIC_DEFAULT_HAIKU_MODEL pins one (per Claude Code's gateway compatibility guide, checked 2026-12-04), so if you set that variable, put its model on the allowlist too. For requests through the haiku alias, such as subagents defined with model: haiku and the built-in claude-code-guide subagent, which runs on Haiku per Claude Code's subagents docs (checked 2026-12-04), allow the model that alias resolves to. ANTHROPIC_DEFAULT_HAIKU_MODEL sets that model (per Claude Code's model configuration docs, checked 2026-12-04), so you can also point it at a model already on the list.

429 limits and 529 Overloaded

Claude Code's own 429 lines, such as Request rejected (429) and Server is temporarily limiting requests, and its subscription usage-limit messages are explained on the Claude Code usage-limit page (https://router.one/claude-code-usage-limit). On Router One's side, a gateway limit on the key, the account or the account's use of one model returns 429 before any model is called, with Retry-After, an X-RateLimit-Scope of api_key, subject or subject_model, and no row in Dashboard → Logs; a scope of upstream_provider points at the model vendor's limit. Key and account limits start at platform defaults and can be raised on request through support@router.one. For API Error: Repeated 529 Overloaded errors, the errors reference (checked 2026-12-04) says a 529 is not your usage limit and does not count against your quota, and suggests /model to switch models, since capacity is tracked per model. When a route fails with a 429, a 5xx or a timeout, Router One can retry the request on another healthy route serving the same model, when one is available; the model you asked for is not swapped for a different one.

5xx, timeouts and cut-off responses

Per the errors reference (checked 2026-12-04), Claude Code shows the status code and the API's error message for any 5xx, and an HTML error page from a proxy or gateway appears as its title, such as API Error: 502 Bad Gateway. Router One's own codes are in the error-code reference (https://router.one/llm-api-error-codes): 502 when the upstream response failed; 503 PROVIDER_UNAVAILABLE, which can mean that no eligible route is available now; and 504, which can be a timeout or deadline error that Router One normalized, so a 504 does not prove the upstream returned HTTP 504. Once output has reached Claude Code, do not assume the gateway can replay the request on another route.

  • If all requests fail behind a gateway, whether as a 500, a 401, Connection dropped or There's an issue with the selected model, the reference points at tool search: by default Claude Code sends defer_loading tool fields and tool_reference blocks with the anthropic-beta header that enables them. This was not checked through Router One for this page. From v2.1.305, Claude Code resends a request without those fields after a 400 or 422 that names tool search or that it does not recognize; for other statuses, set ENABLE_TOOL_SEARCH=false, which loads all MCP tools upfront (environment variables docs, checked 2026-12-04), or CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1.
  • API Error: No response from API, with the waits in parentheses: no response headers arrived within the first-byte deadline, and the retry timed out too. The message itself suggests raising API_TIMEOUT_MS or CLAUDE_STREAM_FIRST_BYTE_TIMEOUT_MS when a proxy or gateway holds responses until they complete.
  • Request timed out: the request timeout is 10 minutes by default and is set with API_TIMEOUT_MS.
  • API Error: Connection lost mid-response. The response above may be incomplete.: the connection dropped, or a proxy or gateway ended the body cleanly, before the response finished. Claude Code keeps the blocks that completed; reply continue to pick up from the last one.
  • The Waiting for API response banner is not an error: from v2.1.309 it appears after 45 seconds without data behind a gateway set with ANTHROPIC_BASE_URL (20 seconds on earlier versions), and it clears once data resumes.

Check your Claude Code version

Several fixes on this page depend on the version: v2.1.304 and v2.1.305 add the retries without context_management and without the tool search fields, v2.1.309 moves the waiting banner to 45 seconds behind a gateway, and each recent model has a minimum version (errors reference, checked 2026-12-04). On the npm registry (checked 2026-12-04), Claude Code's latest tag is 2.1.336 and its stable tag 2.1.332, so either includes these changes. Run claude --version, then claude update, and restart Claude Code.

FAQ

What does API Error mean in Claude Code?

Claude Code could not get a usable response from the model endpoint, after whatever retries apply to that failure: per its errors reference (checked 2026-12-04), it retries transient failures up to 10 times with exponential backoff. When the line shows a status code, the status and message come from the endpoint, which is the gateway when ANTHROPIC_BASE_URL is set; match the message in the table above.

Why does Claude Code show API Error 400 with a third-party API?

It depends on the message. If it says model '<id>' must be called via /v1/chat/completions, the 400 is Router One's own: /v1/messages, the endpoint Claude Code calls, does not serve that model ID, so use a model whose detail page lists POST /v1/messages. If it names context_management, defer_loading or tool_reference, a beta field was not accepted on the way to the model, which was not checked through Router One for this page; Claude Code's errors reference (checked 2026-12-04) says to update to v2.1.304 or later for context_management or v2.1.305 or later for defer_loading or tool_reference, with CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 as the fallback. If it says thinking.type.enabled is not supported for this model, the reference says Claude Code is older than the selected model needs. Through Router One, a legacy thinking {"type": "enabled"} sent to either ID of Claude Opus 5.5 or Claude Sonnet 5.5 is rewritten to {"type": "adaptive"} before the call; run claude update and restart anyway. The 400 section above covers the other 400 messages.

What does a Claude Code 402 insufficient balance error mean?

Router One's wallet could not cover a request billed to it. The request was refused before any model was called, so nothing was charged and no log row was written. Top up in Dashboard → Deposit. If the message starts with api key spend cap reached, api key daily budget reached or api key monthly budget reached instead, the key's own cap or budget cannot cover the request, and a top-up does not lift it; adjust it in Dashboard → API Keys. Either way, what is left need not be zero: a request is refused when what is available does not cover the minimum it has to reserve, and requests still running hold part of it until they settle, so letting them finish can also clear the 402.

Is API Error: Repeated 529 Overloaded errors my usage limit?

No. Per Claude Code's errors reference (checked 2026-12-04), a 529 is not your usage limit and does not count against your quota. Try again in a few minutes or switch models with /model. Through Router One, a retryable failure can be retried on another healthy route for the same model, when one is available; the model you asked for is not replaced by another.

Does /login fix API Error 401 when I use a gateway?

No. Claude Code's errors reference (checked 2026-12-04) says that behind a gateway the text after 401 is the gateway's message and /login does not change it. Put your Router One key in ANTHROPIC_AUTH_TOKEN in the shell that starts claude, unset ANTHROPIC_API_KEY and restart; the 401 & 403 checklist (https://router.one/claude-code-403) covers each sign-in message.

Can Claude Code use DeepSeek models through Router One?

Router One serves deepseek-v4.1-flash and deepseek-v4-flash on /v1/messages, the endpoint Claude Code calls. Anthropic's LLM gateway docs (checked 2026-12-04) say Anthropic doesn't support routing Claude Code to non-Claude models through any gateway, and whether those IDs accept every field Claude Code sends was not checked for this page. If a 400 appears only with a DeepSeek ID, try CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 or switch back to a Claude model.

Why is the failed request missing from Dashboard → Logs?

Dashboard → Logs records each request the gateway forwards to a model. Requests refused at the gateway's own checks (401, 402, 403, 429, and 400 or 404 for the model ID or endpoint) leave no row and are not billed. A stream that fails before any output may leave no row either. When you contact support, include the X-Request-ID response header from a test request.

Which Claude Code version do I need?

Per Claude Code's errors reference (checked 2026-12-04), v2.1.304 or later resends a request once without context_management after a 400 that rejects that field, v2.1.305 or later resends it without the tool search fields after a 400 naming defer_loading or tool_reference, v2.1.309 or later waits 45 seconds before showing the waiting banner behind a gateway, and each model has a minimum, such as v2.1.280 for Opus 5.5 and v2.1.284 for Sonnet 5.5. On npm (checked 2026-12-04), the latest tag is 2.1.336 and the stable tag 2.1.332, so either covers these.