API Docs

Errors

One shape for every failure.

On failure the HTTP status is non-2xx and the body contains a single error object:

json
{
  "error": {
    "message": "Insufficient credits: this request needs 60 credits. Top up and try again.",
    "type": "insufficient_quota",
    "param": null,
    "code": "insufficient_credits"
  }
}

Fields

FieldDescription
messageHuman readable English. Do not branch on it — wording changes
typeBroad category, see below
codeSpecific reason. Branch on this
paramOffending parameter name, or null when not attributable

Common codes

HTTPcodeMeaning
401missing_api_keyNo Authorization header, or not in Bearer sk-xxx form
401invalid_api_keyUnknown, disabled or deleted key — deliberately indistinguishable
400invalid_requestBad parameters; read message. Empty prompt, image mode with no image, etc.
402insufficient_creditsOut of credits. Top up, and check /v1/credits before retrying
429rate_limit_exceededToo many calls. Back off and retry
429concurrency_limit_reachedConcurrency or daily quota reached. Retry later
404not_foundTask does not exist, or does not belong to this account
502generation_failedEvery image failed during a synchronous call. Credits already refunded
504generation_timeoutSynchronous call timed out. The task keeps running and credits are not refunded — fetch it from /v1/tasks/{id} using the id in the message
500internal_errorServer side. Retryable; contact us if it persists
An asynchronous job that fails after being accepted does not use this shape: the call is 200, the task object carries status failed, and the reason sits in error. Only synchronous image calls surface a failure as 502.