Errors¶
Errors use an OpenAI-style JSON body together with a meaningful HTTP status:
{
"error": {
"message": "Currently only n=1 is supported",
"type": "invalid_request_error",
"code": "invalid_request",
"request_id": "202612010702385241957128268d9d69A16epuN"
}
}
- Branch on the HTTP status code.
typeandcodeare informative. On some endpointscodemay be empty, and the request ID may be appended tomessageinstead of being a separate field. - When contacting support, include the request ID. It is also returned in
the
X-Oneapi-Request-Idresponse header.
Status codes¶
| HTTP | Meaning | Charged? | What to do |
|---|---|---|---|
400 |
Invalid request: missing prompt, unsupported size / resolution, n other than 1, multipart upload, invalid reference image URL. On the synchronous endpoint, a generation that fails also returns 400. |
No (failed generations are refunded) | Fix the request; read message. |
401 |
Missing or invalid API key | No | Check the Authorization header. |
403 |
Insufficient balance, or the key's own spending limit is used up | No | Add credit or raise the key limit. |
404 |
Task ID not found (or it belongs to another account); image link expired | No | Check the ID; image links last 30 days. |
429 |
Too many requests | No | Retry with exponential backoff. |
500 / 503 |
Temporary service problem | No | Retry after a few seconds. |
504 |
Synchronous request exceeded the 10-minute wait | The job may still finish and be billed | Use the async endpoint for long jobs. |
Async task failures¶
A task that was accepted but could not be completed is not an HTTP error.
The status endpoint returns 200 with "status": "failed" and an error
object, and the reserved charge is refunded automatically:
{
"status": "failed",
"error": { "code": "image_generation_failed", "message": "image generation failed" }
}
Retry advice¶
- Retry
429,500,503with backoff (for example 2 s, 4 s, 8 s). - Do not blindly retry a
504on the synchronous endpoint: the first job may still complete and be billed. Switch to async for long jobs. - Do not retry
400,401or403without changing something.