Skip to main content
POST
curl

Authorizations

Authorization
string
header
required

An account API key. Send it as Authorization: Bearer <key>.

Body

application/json

The request body of POST /v1/images/generations.

POST /v1/images/edits asks for the same six fields as multipart form parts instead, beside the image files themselves, an optional mask and an optional background. Its prompt is bounded at 32000 characters rather than at 8192.

model
string
required

The model to generate with, named by its id or by one of its aliases. A name this gateway does not serve on this route is refused with 400 model_not_found; a name it served and has since retired, with 410 model_deprecated.

prompt
string
required

What to generate, in words. One to 8192 characters — characters, not bytes. The prompt is screened by the gateway's own moderation before the image model is called, and a flagged prompt is refused with 403 inappropriate_content naming the categories that fired.

quality
string | null

The provider's quality knob, passed through untouched. The gateway neither checks the value nor holds a menu of accepted ones. What a value means is the serving provider's business, and a provider with no such knob drops it.

size
string | null

The requested image size, written {width}x{height}, as in 1024x1024. The gateway checks the shape alone: two runs of decimal digits with an x between them. Any other shape is refused with 400. Whether the model can produce that particular size is the provider's answer.

n
integer<int64> | null

How many images to ask for. Absent means one. Less than 1 is refused with 400, and so is a value above the maximum a model declares for itself. How many images actually come back is the provider's answer — data carries what it produced.

response_format
enum<string>

Whether each image comes back as a link (url) or as inline base64 (b64_json). url when the key is absent, and the choice is what decides which field of every data[] entry is filled.

Available options:
url,
b64_json

Response

The produced images. Each entry of data carries either a link the gateway hosts or the bytes inline, whichever response_format asked for. usage carries the count the charge was computed from.

The body of a successful POST /v1/images/generations and of POST /v1/images/edits — one shape, answered by both routes.

created
integer<int64>
required

When the gateway rendered this body, in whole seconds since the Unix epoch. The clock is read after the provider has answered, so the value dates the answer rather than the request.

data
object[]
required

The produced images, in the order the provider returned them — one entry per image it produced, which need not be the n that was asked for.

usage
object
required

What the request was metered on. Always present, including for a provider that reports no usage of its own: the gateway fills the block from its own counting.