Errors
Check the HTTP status and error.message. Some rate-limit responses use a message envelope and Retry-After. Error codes for a given status can vary by endpoint.
Response example
{
"error": {
"message": "Invalid or missing API key",
"code": "unauthorized"
}
}Responses are illustrative. IDs, usage, prices and results depend on the actual request.
Response fields
400 · invalid_requestHTTPInvalid body or parameter value
401 · unauthorizedHTTPMissing or invalid API key
402 · insufficient_creditsHTTPNot enough credits
403 · invalid_requestHTTPThe key or project does not allow this model, provider or request origin.
404 · not_foundHTTPUnknown model or generation
409 · not_cancelableHTTPThe task cannot be canceled (already finished, or the provider does not support canceling)
429 · rate_limited / concurrency_limitHTTPToo many requests — retry after the given seconds · Too many tasks running for this API key; wait for some to finish
502 · upstream_errorHTTPEvery provider rejected the task (credits refunded)
503 · no_provider / upstream_errorHTTPNo provider supports these parameters
504 · timeoutHTTPImage is still generating after the wait; poll GET /generations/:id
Usage notes
- Poll at intervals of at least 3 seconds. A 504 from the synchronous image endpoint means the task may still be running: poll its error.id instead of submitting it again.
Use with AI
Give your coding assistant the documentation index or the full API reference, including live model parameters.