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

CodeTypeWhat to check
401invalid_api_keyMissing or invalid key. Check the Authorization: Bearer … header and the key value.
403insufficient_quota / access_deniedInsufficient funds or model access denied. Top up the balance and check the catalog.
404model_not_foundModel ID not found. Check the model against the current list.
429rate_limit_exceededRequest rate exceeded. Pause and retry with exponential backoff.
5xxupstream / gatewayTemporary 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.