API Error Guide
What each API error means, when it happens, and how to fix it. Card messages are the English error.message the API actually returns — match on that string or on error.type.
| Code | Meaning | Quick Fix |
|---|---|---|
| 400 | Invalid request | Fix the request body — do not retry as-is |
| 401 | Authentication failed | Check your API key |
| 402 | Out of credits / budget | Deposit USDC or raise the key budget |
| 403 | Rejected by platform policy | Do not retry — contact support if this is a mistake |
| 413 | Request body too large | Shrink the prompt or split attachments |
| 429 | Rate limited | Wait Retry-After, then retry |
| 500 | Internal error | Retry shortly |
| 502 | Provider auth failed (remapped) | Already retried internally; contact support if it repeats |
| 503 | No providers available | Retry in a few seconds |
| 504 | Provider timed out | Retry your request |
| 529 | Anthropic overloaded (upstream) | Wait 5–10s; check status.anthropic.com |
Can't Connect
Your DeRouter API key (or dashboard login) is missing or invalid. This is about YOUR credential — not a provider node.
Out of Credits
402 only fires when remaining budget or wallet balance cannot cover even one worst-case request of this model. Occupied slots with remaining headroom return 429 instead.
If slots are merely busy (cap > 0), you get 429 with retry-after — not 402. Do not treat every money-related failure as “out of funds”.
Too Many Requests
Per-key, per-family, or platform-wide RPM / concurrency. Body includes scope, reason, retry_after_sec; headers Retry-After and x-ratelimit-scope.
If the message says “0 requests per …”, the key is blocked for that model (circuit breaker or admin) — waiting will not help; contact support. Upstream 429s are rewritten to: Rate limit exceeded. Please retry after a brief wait.
Invalid Request
The request itself is wrong. Changing providers will not help — fix the body.
Other invalid_request_error messages (prompt too long, bad tool_use, …) are passed through from upstream with ids/IPs stripped. Sampling-parameter rejections (temperature / top_p / top_k) only apply when that key has reject_sampling_params enabled.
Rejected by Platform Policy
Terminal 403. Failover will not change the outcome. Do not retry the same request.
Operators may attach a custom message; you might not see the default sentence. 403 here is NOT an expired provider credential — those are remapped to 502.
No Providers Available
Temporary — DeRouter has no healthy node for this model right now. 503 uses api_error (not overloaded_error) so SDKs do not treat it as Anthropic 529.
Upstream Issues
The AI vendor failed after DeRouter already failed over across providers. Raw upstream bodies are not forwarded (except actionable 400s).
Reading Error Responses
Envelope matches the vendor you called, so existing SDK error handling still works. Switch on error.type + HTTP status together — the same type can appear on more than one code.
error.type is the category. Combine it with the HTTP status before deciding to retry.
| error.type | HTTP Code | Meaning | Action |
|---|---|---|---|
| authentication_error | 401 | Your DeRouter API key is missing or invalid | Fix the key — do not retry |
| authentication_error | 502 | A provider node's vendor login failed (not your key) | Retry; contact support if repeated |
| billing_error | 402 | Wallet balance cannot cover one request | Deposit USDC |
| budget_exceeded | 402 | This key's budget cannot cover one request | Raise the key budget or use a cheaper model |
| invalid_request_error | 400 / 413 | Bad request (missing model, too large, long-context, third-party, …) | Fix the body — do not retry as-is |
| not_found_error | 404 | GET /v1/models/:id — model unknown or inactive | Pick a live model id |
| rate_limit_error | 429 | RPM / concurrency (yours or platform) or sanitized upstream 429 | Honor retry_after_sec; if limit is 0, contact support |
| content_refusal | 403 | Content matched a refusal rule | Do not retry — contact support |
| pool_no_capacity | 403 | Pool has no capacity / traffic classified as prohibited extraction | Do not retry — contact support |
| api_error | 503 | DeRouter has no available provider | Retry in 2–5 seconds |
| api_error | 500/502/504 | Gateway or upstream server error | Retry shortly |
| overloaded_error | 529 | Anthropic overloaded (HTTP 529) | Wait 5–10 seconds; check status.anthropic.com |
Every response includes a request-id header (e.g. req_a1b2c3...). Share this ID so we can trace the exact request.
Still stuck? We're happy to help.