Skip to content

Error responses

Parse the common Router error envelope and recover according to status and code.

Router returns errors as JSON before a stream starts.

json
{  "error": {    "message": "No provider is available for this model",    "type": "server_error",    "code": "no_priced_provider_available"  }}

Use the HTTP status for broad control flow, the stable code for a specific product message, and message for a human-readable explanation.

Common API errors

StatusCode or categoryRecovery
400Invalid body, unknown model, output_limit, prompt_too_large, or unsupported inputCorrect the request before trying again.
400context_length_exceededThe messages exceed the edition’s context window in tokens. Shorten them before trying again.
400stream_requiredA non-streaming request asked for more than 512 output tokens or sent more than about 24 KB of message text. Set stream to true, or shorten the request.
400idempotency_key_requiredSend a caller-generated UUID in Idempotency-Key.
401auth_no_token or invalid_api_keySupply a valid bearer key or rotate an expired or revoked key.
402insufficient_creditsAdd shared credits or lower the request maximum.
402budget_exhaustedRouter's UTC monthly spending cap is reached.
402charge_limit_exceededThis request's worst-case charge exceeds its authorized maximum.
403account_disabledResolve account access; repeated requests will not help.
409provider_price_changedReview the current selected offer price and explicitly accept its new revision in a new logical request.
409provider_offer_unavailableSelect another published eligible offer, or explicitly omit the selection for Auto.
409idempotency_conflictThis UUID was already used with a different body, credential, or X-Max-Charge-Credits value. Resend the original terms, or use a new UUID for a new request.
409request_in_progressRouter is still admitting the earlier request with this UUID. Check its credit receipt, then retry with the same UUID and body if needed.
409request_already_existsA streaming request with this UUID already exists. Streams are not replayed; check its credit receipt.
429Request-rate or concurrency limitRespect Retry-After and reduce parallel work.
503no_priced_provider_availableNo eligible paid provider can accept this model now.
503no_provider_for_lengthNo online provider serves a request this long right now. Shorten the messages or the answer limit; an immediate retry will not help, so respect Retry-After (60 seconds).
503selected_provider_unavailableThe selected computer is busy or offline; Router does not silently fall back.
503self_provider_onlySelect a provider owned by another account.
503request_capacityRouter’s bounded active-request capacity is full; retry later.
503credit_admission_unavailable or settlement_pendingKeep the request UUID and check its credit receipt; never start a new paid request just to recover.
503slippage_tolerance_exceededNo charge or reservation. Review error.minimum_slippage_tolerance and submit new terms with a new request UUID if appropriate.
503pricing_pendingPricing research is running; no charge or reservation. Retry unchanged terms after Retry-After.
503suggested_price_unavailableBaseline storage or generation is unavailable; no charge or reservation. Retry later or choose another model.
503Generation or dependency failureShow a temporary failure and retry the same logical request ID only when safe.

Error messages can evolve. Branch application behavior on status and code rather than matching the English message.

Streaming errors

After streaming headers are sent, a generation failure arrives as an SSE data event with an error object and the request's request_id. The HTTP status may already be 200.

bash
data: {"error":{"message":"Generation or settlement interrupted","type":"server_error","code":"provider_timeout"},"request_id":"$REQUEST_ID"}
data: [DONE]

An error event is terminal for that generation. A [DONE] marker may still follow; it does not turn the reply into a success. Do not treat already-received content as a complete answer, and check the request's credit receipt before retrying. Codes vary by failure.

When streaming, an input longer than the model's context window arrives this way too, as "type":"invalid_request_error","code":"context_length_exceeded" with no answer text. Retrying the same messages fails again: shorten them first. No tokens were generated, so the request's reservation is released.

Retry headers

429 and temporary capacity responses can include Retry-After. Interpret an integer value as seconds, add jitter before retrying, and keep the total number of attempts bounded.

See retries, timeouts, and cancellation for an application strategy.