Skip to main content

Parameters

string
required
Text description of the image to generate. Maximum 32,000 characters.
string
Render quality tier — directly affects cost. One of low, medium, high. Default: medium.
string
Output dimensions. One of 1024x1024, 1024x1536, 1536x1024, 1024x2048, 2048x1024, 688x2048, 2048x688, 880x2048, 2048x880, 1152x2048, 2048x1152, 1360x2048, 2048x1360, 1536x2048, 2048x1536, 2048x2048, 2160x3840, 3840x2160, auto. Default: 1024x1024.
integer
Number of images to generate. Range: 110. Default: 1. Each image is billed its own output cost, so n images cost (you’re charged only for images actually returned).
string
Background style. One of transparent, opaque, auto. Default: auto. transparent renders a true alpha channel and requires output_format png (the default) or webp — JPEG has no transparency.
string
Output file format. One of png, jpeg, webp. Default: png.
integer
Output compression quality, 0100. JPEG only.
string
Moderation strictness. One of low, auto. Default: auto.
string
HTTPS endpoint to POST the finished generation to. Delivered after the image is mirrored to storage, so it carries the final URL. Private and loopback addresses are rejected.
boolean
Stream the result over SSE instead of answering immediately. Default: false. See Getting the result.

Getting the result

Generation takes roughly 20-120 seconds, so the request does not return the image. It returns the generation id right away:
Collect the result in whichever of these three suits you.

Poll (default)

status becomes success (read data[0].url) or failed (read error_message).

Webhook

Pass callback_url and we POST it once the image is stored:
The URL must be publicly reachable over HTTPS; loopback, private-range and cloud-metadata addresses are refused.

Stream

Pass "stream": true for text/event-stream:
The first event arrives immediately, so you hold the id even if the connection drops later. Streaming keeps the connection open for the whole generation — if your client or a proxy times out below ~2 minutes, prefer polling or a webhook. There is no progressive preview: the upstream sends the image only when it is finished, so partial_images has no effect.
Send an Idempotency-Key header with every request. If the connection drops, repeating the request with the same key returns the original generation instead of creating and charging a second one. See Idempotency.

Example