API reference

Errors

Errors use standard HTTP status codes and an OpenAI-style error body on both surfaces.

json
{
  "error": {
    "type": "insufficient_balance",
    "message": "Balance $0.02 is below the estimated cost of this request.",
    "code": 402
  }
}

Codes

StatusTypeWhat to do
400invalid_requestFix the request body. The message names the field.
401invalid_api_keyCheck the key, or create a new one.
402insufficient_balanceTop up from Balance.
404model_not_foundUse an id from GET /v1/models.
429rate_limitedWait for retry-after seconds.
502upstream_errorAll upstreams for this model failed. Retry, or pick another model.
503overloadedTemporary. Retry with backoff.
Retries

Retry 429, 502 and 503 with exponential backoff. Don't retry 400, 401, 402 or 404 without changing something first.