Skip to content

DocsAPI reference

Errors

Errors use OpenAI's format and HTTP status codes, so SDK error handling works unchanged.

402 Payment Required
{
  "error": {
    "message": "Insufficient credits: this request may cost up to $0.0563 (32768 output tokens reserved), and your available balance is $0.02. …",
    "type": "insufficient_credits",
    "param": null,
    "code": "insufficient_credits"
  }
}

Status codes

StatuscodeMeaningWhat to do
400(none) / context_length_exceededThe request is invalid, or the model rejected it.Fix the request. Not charged.
401missing_api_key, invalid_api_key, api_key_revokedNo usable API key.Send a valid key.
402insufficient_creditsThe available balance cannot cover the request's reservation.Add credits or lower max_completion_tokens.
403key_spend_limitThe key would pass its spending limit.Raise or remove the limit in the dashboard.
403account_disabledThe account is suspended.Contact support.
404model_not_found, unknown_endpointUnknown model id or path.Check GET /v1/models.
413request_too_largeThe body is larger than 4 MB.Send a smaller request.
429rate_limit_exceededThe key's per-minute request limit is reached.Wait for retry-after seconds.
503upstream_unavailableEvery deployment of the model failed.Retry with backoff. Not charged.
503model_unavailableThe model is temporarily out of service.Retry later or use another model.
503database_unavailable, catalog_unavailableA temporary internal problem; the request was not sent.Retry with backoff. Not charged.
500internal_errorUnexpected failure.Retry; contact support with the x-request-id.

Retries

Retry 429, 500 and 503 with exponential backoff; the OpenAI SDKs do this by default. Avenro already retries failing deployments for you before answering, so a 503 means every deployment was tried. Don't retry 400, 401, 402, 403 or 404 without changing something.

Errors in the middle of a stream arrive as a final chunk with an error object; see streaming.