Reference
Errors and retries
The gateway returns standard HTTP codes and an error body in the OpenAI-compatible format. Check what the code means and how to retry the request safely.
Error format
JSON
{
"error": {
"message": "Description of the problem",
"type": "invalid_api_key",
"code": "invalid_api_key"
}
}Code reference
| Code | Type | What to check |
|---|---|---|
| 401 | invalid_api_key | Missing or invalid key. Check the Authorization: Bearer … header and the key value. |
| 403 | insufficient_quota / access_denied | Insufficient funds or model access denied. Top up the balance and check the catalog. |
| 404 | model_not_found | Model ID not found. Check the model against the current list. |
| 429 | rate_limit_exceeded | Request rate exceeded. Pause and retry with exponential backoff. |
| 5xx | upstream / gateway | Temporary gateway or channel error. Retry later; if it persists, contact support. |
Retry strategy
- 429 and 5xx — retry with exponential delay (e.g. 1s, 2s, 4s) and a small jitter.
- 401 / 403 / 404 — do not retry automatically: fix the key, balance or model ID.
- Idempotency. Retries are safe for reads; for paid generations, make sure a retry does not create a second task unnecessarily.