Errors

Error responses return a JSON body with a single error field containing the message as a string. The HTTP status code carries the semantic meaning.

error.json
{
  #60a5fa]">class="text-emerald-400">"error": class="text-emerald-400">"Insufficient funds. Please top up your balance."
}

Status codes

CodeMeaningWhat to do
400Bad request — missing model, missing messages, invalid JSON, or upstream rejected the requestCheck the error message and fix your payload
401Missing Authorization header or invalid API keyVerify the key is set and active in your dashboard
402Insufficient balance or per-key spending cap reachedTop up balance or raise the per-key cap
405Method not allowed (endpoint expects POST or GET only)Check the HTTP method for the endpoint
413Request body exceeds 500 KBTrim the messages or shorten the prompt
429Rate limit exceeded (60 req/min)Back off and retry after the Retry-After header
500Internal server errorRetry with exponential backoff; contact support if persistent
502Upstream provider returned an errorRetry; the provider may be having an outage
503Upstream API not configured or unavailableContact support
504Request timed out after 60 secondsRetry; consider a shorter prompt or lower max_tokens

Retry strategy: for 429, 500, 502, 503, and 504, retry with exponential backoff (start at 1s, double up to 30s, max 5 attempts). Do not retry 400, 401, 402, 405, or 413 — those are client errors.