Errors

What each error means, when to retry, and what to tell your vendor.

No error costs credits, and a failed generation is refunded automatically.

Error format

JSON
{
  "error": {
    "code": "invalid_request",
    "message": "The Idempotency-Key header is required. Send one unique value per photo, such as a UUID, and reuse it when you retry.",
    "param": "Idempotency-Key",
    "request_id": "req_9Tz3Kw7Qp2Lx5Nv8Bd4Hs6Jy"
  }
}

Build your logic on code. message is for developers: don't show it to vendors. param names the field at fault, and request_id helps us when you contact us.

Request errors

These come back as the answer to your request, and no job is created.

HTTPCodeWhat it meansRetry?
400invalid_requestA field, parameter or header is missing or wrong; see paramNo, fix the request
400style_not_availableThe style doesn't exist or was retiredNo, pick another style
400image_unreadableThe photo file is damagedNo
400image_too_smallThe photo is under 512 px on its short sideNo
400image_fetch_failedWe couldn't download your image_urlYes, once the URL works
401invalid_api_keyThe key is missing, wrong or revokedNo
402insufficient_creditsYour live credits have run outAfter credits are added
403permission_deniedNot allowed, for example a live key used from a browserNo
403account_suspendedYour account is suspendedNo, contact us
404not_foundNo such generation, file or pathNo
409idempotency_conflictThis Idempotency-Key was used with a different bodyNo
413image_too_largeThe photo is over 20 MB or 100 megapixelsNo
413payload_too_largeThe request body is over 10 MBNo, send image_url
415unsupported_media_typeThe photo isn't JPEG, PNG, WebP or HEIC, or the body isn't JSONNo
429rate_limitedToo many requests for this keyYes, after Retry-After
429queue_full500 jobs are already waitingYes, after Retry-After
429daily_limit_reachedYou reached today's job capYes, after 00:00 UTC
429busyWe are briefly busyYes, after Retry-After
500internal_errorSomething went wrong on our sideYes
503service_unavailableWe can't take the request right now, or your access isn't open yetYes, after Retry-After

Failed generations

A job that was accepted can still fail. You get status: "failed" and a generation.failed webhook, with one of these codes in error.code. The credit is refunded.

CodeWhat it meansRetry?
content_refusedThe photo or the instruction was refusedNot with the same photo
image_unprocessableNo result could be made from this photoNot with the same photo
generation_timeoutIt took too longYes, with a new Idempotency-Key
generation_failedIt failed for another reasonYes, with a new Idempotency-Key
queue_timeoutIt wasn't finished within 24 hoursYes, with a new Idempotency-Key

Retrying

  • Timeouts, network errors, 429 and 5xx: retry with the same Idempotency-Key and the same body. Wait for Retry-After when it is there; otherwise wait 1, 2, 4, 8 seconds and so on.
  • A failed generation: create it again with a new Idempotency-Key.
  • Other 4xx errors: don't retry. Fix the request, or ask the vendor for another photo.
  • An error code you don't know: we may add codes. Act on the HTTP status: retry 429 and 5xx, and don't retry other 4xx.

Some 429 and 5xx answers come from our hosting platform without our JSON body. Retry them the same way.

What to tell your vendor

CodeMessage for the vendor
image_too_small"This photo is too small. Please upload the original photo, not a screenshot."
image_too_large"This photo is too large. Please upload a smaller one."
image_unreadable"We couldn't open this photo. Please upload it again from your camera."
unsupported_media_type"Please upload a JPEG, PNG, WebP or HEIC photo."
content_refused"We couldn't use this photo. Please upload a photo that shows only the dish."
image_unprocessable"We couldn't create a picture from this photo. Please try a sharper, brighter photo of the whole dish."
style_not_available"This style is no longer available. Please choose another one."

Other codes need nothing from the vendor.

On this page