# Errors (/docs/errors)

One error shape, a code to act on, and whether to retry.

Errors come back with a code your program can act on, and the request ID to quote when asking about it:

```json
{
  "error": {
    "type": "billing_error",
    "code": "insufficient_balance",
    "message": "…",
    "param": null
  },
  "request_id": "0193…"
}
```

On `/v1/messages`, the body has Anthropic's shape: `"type": "error"` at the top and no `param`. Act on `code`, not on `message`.

| Code | What to do |
|---|---|
| `invalid_request`, `body_not_json` <small>400</small> | Fix the request. The message says what is wrong. |
| `rejected_by_model` <small>400 / 422</small> | The model refused the request, or it asks for a feature that cannot be translated. Change the request or the model. |
| `invalid_api_key` <small>401</small> | Check the key; it may have been revoked. |
| `insufficient_balance` <small>402</small> | Top up. |
| `key_limit_reached` <small>402</small> | Raise the key's monthly limit, or wait for next month (UTC). |
| `account_suspended` <small>403</small> | Write to [contact@hackrouter.ai](mailto:contact@hackrouter.ai). |
| `country_not_supported` <small>403</small> | hackrouter is not available in mainland China. |
| `model_not_found` <small>404</small> | Use an ID from [Models](/docs/models) that offers the API you called. |
| `request_not_found` <small>404</small> | The request has not been charged yet, or is not yours. Try again in a minute or two. |
| `route_not_found` <small>404</small> | Check the path. |
| `method_not_allowed` <small>405</small> | Use a method from the `allow` header. |
| `body_too_large` <small>413</small> | The body is over 20 MiB. Send media by URL; see [Files](/docs/api#files). |
| `rate_limited` <small>429</small> | Wait for `retry-after` seconds. See [Rate limits](/docs/rate-limits). |
| `internal_error` <small>500</small> | Retry. |
| `model_unavailable` <small>503</small> | Every route for the model failed. Retry, or try another model. |
| `storage_unavailable` <small>503</small> | Retry later. |

None of these are charged. A stream that breaks after it started ends with an error event whose code is `stream_broken`; what was sent is charged. See [Streaming](/docs/streaming).

Every response carries an `x-request-id` header with the same ID.