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