API docsIntegration guides

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

401 · application/json
{
  "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_request
HTTP

Invalid body or parameter value

401 · unauthorized
HTTP

Missing or invalid API key

402 · insufficient_credits
HTTP

Not enough credits

403 · invalid_request
HTTP

The key or project does not allow this model, provider or request origin.

404 · not_found
HTTP

Unknown model or generation

409 · not_cancelable
HTTP

The task cannot be canceled (already finished, or the provider does not support canceling)

429 · rate_limited / concurrency_limit
HTTP

Too many requests — retry after the given seconds · Too many tasks running for this API key; wait for some to finish

502 · upstream_error
HTTP

Every provider rejected the task (credits refunded)

503 · no_provider / upstream_error
HTTP

No provider supports these parameters

504 · timeout
HTTP

Image 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.