Skip to content

Error codes

Use the HTTP status and error.code to handle errors in your application. The message text can change. The /v1/messages endpoint uses Anthropic’s format with error.type instead of code.

On every endpoint except /v1/messages, errors use OpenAI’s format:

{
"error": {
"message": "the API key provided is not valid",
"type": "invalid_request_error",
"code": "invalid_api_key",
"param": null
}
}

type is one of invalid_request_error, permission_error, insufficient_quota or api_error.

On /v1/messages, errors use Anthropic’s format, which has no code:

{
"type": "error",
"error": { "type": "authentication_error", "message": "the API key provided is not valid" },
"request_id": "req_..."
}
Status error.type on /v1/messages
401 authentication_error
402 billing_error
403 permission_error
404 not_found_error
429 rate_limit_error
503 overloaded_error
500, 502, 504 api_error
anything else, including 400 and 409 invalid_request_error

If an error happens partway through a stream, the HTTP status has already gone out as 200. The error arrives as the last event in the stream, and the stream closes without [DONE].

code What it means What to do
invalid_json, invalid_request_body The body isn’t valid JSON. Check the request body.
body_too_large The body is over the endpoint’s size limit. Make the request smaller, for example by sending a smaller image.
missing_model There’s no model field. Add a model ID.
invalid_messages The request carries no messages. Send at least one message.
invalid_output_cap max_tokens isn’t a positive whole number. Send a whole number above zero, or leave the field out.
conflicting_output_caps max_tokens, max_completion_tokens and max_output_tokens were sent with different values. Send only one, or give them the same value.
context_length_exceeded The input plus the output cap doesn’t fit the model’s context window. Shorten the input or lower max_tokens.
input_too_large The input alone is over what the model accepts. Shorten the input.
route_capacity_exceeded The request is larger than every route currently available for this model. Make the input or output smaller, or pick another model.
refused_request_field A field such as provider, fallbacks or service_tier isn’t forwarded. Remove the field. See Base URL and API keys.
refused_tool_type A hosted tool such as image_generation isn’t served. Remove the tool.
tools_not_supported This model doesn’t do function calling. Send the request without tools, or pick a model that supports them.
unsupported_content_part The model doesn’t take that kind of content (images, documents, audio, video), or a document has too many pages. Pick a model that takes that kind of content.
unsupported_media_source, vendor_object_reference A file was sent as a file_id or an unsupported URL. Send the file’s contents inline as a data: URL. Images can also be an https:// URL.
unreadable_document, unreadable_media We couldn’t read a PDF’s page count or an audio clip’s length. Send a standard PDF or audio file.
invalid_idempotency_key The Idempotency-Key is empty or longer than 255 bytes. Fix the header value.
responses_not_stored background: true and /cancel on /v1/responses aren’t served. Send the request without background.
invalid_request, policy_refusal The provider refused the request. The message starts with “the provider refused this request”. Read the provider’s message and change the request.

The image, audio, video, file and batch endpoints have 400 errors of their own. Each endpoint’s page lists them.

code What it means What to do
missing_api_key The request has no API key. Send an Authorization: Bearer <key> header.
invalid_api_key The key is wrong, revoked, or a console session token. Check the key, or create a new one on the API Key page.
api_key_expired The key’s expiry date has passed. Create a new key.
code What it means What to do
insufficient_funds Your balance doesn’t cover the largest amount this request could cost, or the balance is negative. Top up, or send a smaller max_tokens. See How billing works.
spend_cap_exceeded A daily or monthly spend cap on the key, the member or the account has been reached. Wait for the next day or month (WIB), or raise the cap in the console.
credit_limit_exceeded A postpaid account has reached its credit limit. Pay your open invoices, or contact us.
invoice_overdue An invoice is past its due date. Pay the invoice. Requests are accepted again once it’s paid.
credit_facility_expired, credit_facility_not_started The account’s credit facility has ended or hasn’t started yet. Contact us.
code What it means What to do
model_not_allowed This key is limited to certain models, and the one you asked for isn’t one of them. Use another key, or change the key’s model list.
provisioning_key_cannot_spend An admin key was used for a model request. Use an ordinary API key.
inference_key_cannot_provision An ordinary API key was used on /v1/keys. Use an admin key.
billing_account_inactive The billing account can’t start new requests. Contact us.
billing_account_closed The billing account has been closed. Any balance left is kept and can be refunded on request. Contact us.
code What it means
model_not_found The model ID is misspelled, doesn’t start with the vendor, or the model is served on another endpoint. The message names the right endpoint, for example /v1/images/generations for an image model.
not_found The path or HTTP method isn’t one we serve.
request_not_found, response_not_found, conversation_not_found, item_not_found, file_not_found, batch_not_found, video_not_found, api_key_not_found There’s no object with that ID on your account.
code What it means
idempotency_key_mismatch This Idempotency-Key was already used with a different body.
idempotency_key_in_use A request with this Idempotency-Key has already run. Its answer isn’t stored, so it can’t be sent again.
video_not_ready The video isn’t finished yet. Check its status again until it’s completed.
video_not_buildable The video can’t be edited or extended. The message says why: it isn’t a Gemini Omni video, isn’t finished, is more than two days old, or is too long.
batch_not_cancellable The batch has already finished, so it can’t be cancelled.
code What it means Retry-After
rate_limit_exceeded Your key or account is over its requests-per-minute or tokens-per-minute limit. Yes, the seconds until there’s room again.
too_many_requests Too many requests without a valid key from your IP address. Yes
key_concurrency_limit_exceeded This key already has as many requests running as its Requests at once limit. Yes, 1 second.
concurrency_limit_exceeded Your account already has as many picture or audio requests running as it may, or holds its full share of this model. Yes, 1 second.
video_queue_full Your account already has as many videos waiting as it may. Yes, 30 seconds.
all_routes_saturated Every route for this model is busy right now. Yes, 1 second.
vendor_daily_limit_reached The vendor’s daily request limit for this model is used up. Yes, until the daily limit resets.
rate_limited The provider is rate limiting requests to this model. Yes, 5 seconds.

Per-key and per-account limits are on Rate limits.

Before returning a 5xx error, we’ve already tried the model’s other routes, as long as no part of the answer had reached you yet.

Status code What it means
502 upstream_failed The provider didn’t complete the request.
502 upstream_incomplete The provider stopped before its answer was complete.
503 various “this model is temporarily unavailable” or “no provider is available for this model”. We can’t serve this model right now.
503 source_route_unavailable The route that made the source video isn’t serving right now, and only that route can edit or extend it. Try again later.
504 upstream_timeout The provider didn’t answer in time.
504 upstream_idle The provider stopped sending partway through the answer.
504 max_duration The answer ran for more than an hour and was ended.
500 internal_error The request couldn’t be completed because of a problem on our side.

Retry on 429, 500, 502, 503 and 504. If there’s a Retry-After header, wait that long. If there isn’t, wait a moment and lengthen the wait each time you try again. If you use Idempotency-Key, send a new key when you retry after an error, because a key that’s been used is refused with 409. Reusing the same key only helps when the connection dropped before you got any answer at all.

Don’t retry 400, 401, 402, 403 or 404 without changing the request or your account, because you’ll get the same result. The exception is 409 video_not_ready: check the video’s status again later.

If an error keeps coming back, send the x-request-id from the response to support@indorouter.ai.