API Error Guide
Running into errors? This guide explains what each error means, when it happens, and exactly how to fix it.
| Code | Meaning | Quick Fix |
|---|---|---|
| 400 | Invalid request format | Check your request body |
| 401 | Authentication failed | Check your API key |
| 402 | Out of credits / budget | Deposit USDC or raise budget |
| 429 | Too many requests | Wait a few seconds, then retry |
| 502 | Provider auth failed | Auto-retried; contact support if repeated |
| 503 | No providers available | Retry in a few seconds |
| 504 | Provider timed out | Retry your request |
| 529 | Upstream overloaded | Wait 5–10s, then retry |
Can't Connect
You'll see these when there's a problem with your API key or login session.
Out of Credits
You'll see these when your account or a specific key runs out of funds.
Too Many Requests
You'll see these when you're sending requests faster than your key's limits allow.
Invalid Request
You'll see these when there's something wrong with how the request is formatted.
Other request errors (prompt too long, invalid tool format, etc.) are passed through from the upstream API with the original message.
No Providers Available
These are temporary — DeRouter can't find a provider to handle your request right now, but one should become available shortly. Note: 503 means DeRouter providers are temporarily unavailable, which is different from 529 (AI provider overloaded).
Upstream Issues
These come from the AI provider (Anthropic or OpenAI) after DeRouter has already tried multiple providers automatically.
Reading Error Responses
DeRouter returns errors in the same format as the AI provider you're calling, so your existing error handling code works without changes.
The error.type field in the response body tells you the error category, helping you determine the cause and how to handle it:
| error.type | HTTP Code | Meaning | Action |
|---|---|---|---|
| authentication_error | 401 | Authentication failed — invalid API key or token | Check your API key |
| billing_error | 402 | Insufficient balance or key budget exceeded | Deposit or raise budget |
| invalid_request_error | 400 | Bad request (missing model, invalid format, etc.) | Check request body |
| rate_limit_error | 429 | RPM or concurrency limit exceeded | Wait a few seconds, retry |
| api_error | 503 | DeRouter has no available providers | Retry in 2–5 seconds |
| api_error | 500/502/504 | Upstream server error (500/502/504) | Retry shortly |
| overloaded_error | 529 | AI provider (Anthropic/OpenAI) is overloaded | Wait 5–10 seconds, retry |
Every response includes a request-id header (e.g. req_a1b2c3...). Share this ID with us so we can trace exactly what happened with your request.
Still stuck? We're happy to help.