DocsAPI reference
Errors
Errors use OpenAI's format and HTTP status codes, so SDK error handling works unchanged.
{
"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
| Status | code | Meaning | What to do |
|---|---|---|---|
| 400 | (none) / context_length_exceeded | The request is invalid, or the model rejected it. | Fix the request. Not charged. |
| 401 | missing_api_key, invalid_api_key, api_key_revoked | No usable API key. | Send a valid key. |
| 402 | insufficient_credits | The available balance cannot cover the request's reservation. | Add credits or lower max_completion_tokens. |
| 403 | key_spend_limit | The key would pass its spending limit. | Raise or remove the limit in the dashboard. |
| 403 | account_disabled | The account is suspended. | Contact support. |
| 404 | model_not_found, unknown_endpoint | Unknown model id or path. | Check GET /v1/models. |
| 413 | request_too_large | The body is larger than 4 MB. | Send a smaller request. |
| 429 | rate_limit_exceeded | The key's per-minute request limit is reached. | Wait for retry-after seconds. |
| 503 | upstream_unavailable | Every deployment of the model failed. | Retry with backoff. Not charged. |
| 503 | model_unavailable | The model is temporarily out of service. | Retry later or use another model. |
| 503 | database_unavailable, catalog_unavailable | A temporary internal problem; the request was not sent. | Retry with backoff. Not charged. |
| 500 | internal_error | Unexpected 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.