# Errors (/docs/api/errors)

> For AI agents, the [documentation index](https://bitrouter.ai/llms.txt) lists all pages. Append .md to a documentation URL to read its Markdown.

Each endpoint returns errors in the shape of the API it follows, so existing error handling keeps working.
`/v1/messages` uses Anthropic's shape; the others use OpenAI's. `error.code` is a stable machine-readable code.

| Status        | When                                                                                                                                                |
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400           | The request is malformed                                                                                                                            |
| 401           | The key is missing or invalid                                                                                                                       |
| 402           | Your balance can't cover the request. [Top up](https://bitrouter.ai/workspace/billing) and retry                                                    |
| 403           | The key lacks the scope this endpoint needs                                                                                                         |
| 404           | The model, or the request id, doesn't exist for this key                                                                                            |
| 429           | Rate limited. `error.code` is `rate_limit_exceeded` for our limit, `upstream_rate_limited` when every provider was; `Retry-After` is set when known |
| 502, 503, 504 | Every provider that could serve the model failed, was unavailable or timed out                                                                      |

When a provider fails, the request moves to the next provider that serves the model before you see an error.
`x-bitrouter-error-source: upstream` on an error means it came from the providers, not from us.