Core concepts

Errors

A refused request gets a 4xx or 5xx status and a body with the same shape on every route.
json
{
"error": {
"type": "invalid_request_error",
"code": "parameter_invalid",
"message": "A request parameter is missing or invalid. See 'param'.",
"param": "limit"
},
"request_id": "req_8fK2mQ4vTn7cX1bZ9wLp3hRs"
}
FieldDescription
error.typeError family, derived from the status.
error.codePrecise and stable reason: the field to read in code.
error.messageEnglish explanation, for the developer. Not to be shown to end users.
error.paramParameter or header at fault (image, layers[0].action, Idempotency-Key…), or null.
request_idRequest identifier, identical to the request-id header.
Statustype
400, 404, 405, 409, 413, 415, 422invalid_request_error
401authentication_error
402billing_error
403permission_error
429rate_limit_error
500, 503api_error
StatusCodeCause
400parameter_invalidMissing or invalid parameter, header or JSON body; param names it.
400request_invalidRequest refused with no more precise reason, a malformed multipart/form-data form for example.
400image_unreadableUnreadable image (see Input images).
400image_dimensions_invalidImage over 8,192 pixels per side or 36 million pixels; upscaling: see Upscaling.
400image_url_unreachableImage cannot be downloaded: private or unreachable URL, error response, timeout.
400mask_invalidEdit mask that is not a readable PNG.
400mask_dimensions_mismatchMask with proportions different from the image, or a long side under 512 pixels (or the image's, if smaller).
400mask_colors_mismatchMask colors and layers do not match; param names the layer or mask.
401api_key_missingAuthorization: Bearer … header missing.
401api_key_invalidMalformed, unknown or revoked key, or deleted organization.
401api_key_expiredExpired key.
402insufficient_balanceBalance too low for the generation's price (see Billing).
402spend_limit_reachedThe generation would exceed the monthly limit.
403permission_deniedMissing permission; the message names it (see Authentication).
403ip_not_allowedIP address not in the key's list.
403origin_not_allowedRequest to /mcp sent from a web page (Origin header).
403organization_suspendedSuspended organization, whatever the key. Contact support.
404route_not_foundUnknown path under /v1.
404resource_not_foundResource that does not exist, belongs to another organization or to the other mode (test or live).
405method_not_allowedMethod not allowed; the Allow header lists the allowed methods.
409conflictThe request conflicts with the current state of the resource.
409generation_not_cancelableGeneration already started or ended.
409idempotency_key_reusedIdempotency-Key already used for another request (see Idempotency).
409idempotency_key_in_useA request with the same Idempotency-Key is still in progress.
413request_too_largeJSON body over 64 KB; in multipart/form-data, over 64 KB of text fields or a body beyond five 10 MB images.
413image_too_largeImage over 10 MB.
415unsupported_media_typeBody neither in application/json, nor in multipart/form-data for a generation creation.
415unsupported_image_typeImage that is not a JPEG, PNG or WebP by its content, or URL that does not return an image.
422content_policy_violationEdit instruction refused by moderation (param is prompt).
429rate_limit_exceededToo many requests per minute (see Rate limits).
429generation_rate_limit_exceededGenerations launched per minute or per hour allowed by the tier reached (see Rate limits).
500internal_errorInternal error.
503maintenanceAPI under maintenance.
503mode_unavailableThis generation type is temporarily unavailable.
503service_unavailableService temporarily unavailable (instruction moderation, transient outage).
503overloadedHeavy load: generation refused at admission, or received images not analyzed in time.
  • A generation request refused (4xx or 503) creates nothing and charges nothing.
  • A resource of another organization responds 404, never 403.
  • An accepted generation that fails later is not an HTTP error: its status is failed (see Generations).
  • 429 and 503: retry after the number of seconds in the Retry-After header, or later if it is missing.
  • 409 idempotency_key_in_use: retry later with the same idempotency key.
  • 500: a few attempts at most, doubling the wait (1 s, 2 s, 4 s).
  • Other 4xx: fix the request; resent as is, it gets the same response.
  • Unknown code: handle it from its status and its type; new codes can be added.
  • Log the request-id header, present on every response: support uses it to find the call.