Generate image

Queues an image generation and returns the task straight away — generation itself is asynchronous. Follow the task by polling its status or by receiving a webhook. The cost is reserved up front and reconciled when the task finishes, so a partial failure is refunded.

POST/image/generate
AuthAPI keyorOAuth tokenHow to send it

Creates an image task and returns its id. Nothing in the response is an image yet. Wait for the task by polling or with a webhook, or let the SDK's image.generate() wait for you.

Always pass model. When it is omitted, the API uses auto, which is experimental. See the model field. Generate images covers sizes and the result.

Request body#

promptstringrequired

Positive prompt.

e.g. "Cute Cat"≥ 1 characters≤ 8192 characters
modelstring
default "auto""alibaba/qwen-image-2.0""alibaba/qwen-image-2.0-pro""alibaba/qwen-image-3.0""alibaba/qwen-image-3.0-pro""auto""black-forest-labs/flux-1-schnell""black-forest-labs/flux.1-dev""black-forest-labs/flux.2-dev"
countnumber
default 1≥ 1≤ 20
accessobject

Controls whether the create-task response should include a short-lived Public Access Token.

That token can be passed to browser or client-side code for polling task status and task images without exposing your API key.

patobjectrequired
enabledboolean
default true
destinationstring
e.g. "bunny-prod"≥ 1 characters≤ 64 characters
inputs(string | object)[]
≤ 20 items
sourceobjectrequired
type"url"required
urlstringrequired
type"image"required
asstring
"auto""reference""source"
magic_promptboolean
metadataobject
negative_promptstring
≤ 8192 characters
outputobject
formatstring
"jpg""png""webp"
ratingobject | boolean
true
mode"nsfw_sfw"
default "nsfw_sfw"
sizeobject | string
"16:9""16:9_4k""1:1""1:1_4k""1:2""1:2_4k""21:9""21:9_4k"
aspectRatiostringrequired
"16:9""1:1""1:2""21:9""2:1""2:3""3:2""3:4"
type"aspect_ratio"required
scalestring
default "base""4k""base"
webhookobject
customobject[]
≥ 1 items≤ 5 items
urlstringrequired
dashboardboolean

Set to false to disable dashboard-managed webhooks for this task. Request-level custom webhooks are still sent.

Response#

Image generation task created

dataobjectrequired
estimatedCoststringrequired

Estimated cost in USD reserved for this task. Failed images are refunded, so the final cost may be lower.

e.g. "0.03"
taskIdstringrequired

Task ID

e.g. "tsk_01KE7XWWEQ4MCGWKBQKJ1G47RP"
accessobject

Returned when access.pat.enabled is true.

publicAccessTokenstringrequired

Short-lived Public Access Token for polling task status and image results.

This token is safe to return to frontend code and can be used instead of your API key for polling public task state.

e.g. "pat_eyJhbGciOi..."

Errors#

A failed call names what went wrong in code, with a sentence in message. The codes, which of them are worth retrying, and how to read a validation failure are on Errors.