Skip to main content

The envelope

Every response body — success or error — wraps its payload in a top-level envelope. The status field always mirrors the HTTP status code.

Success

Error

Error types

HTTP status alone does not determine error.type: an HTTP 500 may carry system_error, storage_error, billing_error (credit-ledger failures) or provider_error (generation failures). Always branch on error.code or error.dev, not on the status code.

Developer codes

The dev field is a 5-digit internal code that gives you a precise signal beyond the HTTP status. The first three digits mirror the HTTP status; the last two differentiate within that status. For example:
  • 40100unauthorized (HTTP 401)
  • 40200insufficient_credits (HTTP 402)
  • 40034invalid_image_url (HTTP 400)
  • 50000internal_error (HTTP 500)
See the Error Code Reference for the codes you are most likely to encounter.

Paginated responses

List endpoints wrap their payload in an additional data + pagination layer:
See Pagination for details on cursor-based traversal.