Skip to navigation

Generate images

Creates images from a prompt. Every image is returned as a link in data[].url, never as base64. A size, quality or count the model doesn’t offer is refused before anything is held.

Authentication

AuthorizationBearer

Your API key, sk-..., from Console → API keys.

Request

This endpoint expects an object.
modelstringRequired
promptstringRequired
nintegerOptional>=1
How many images. Each model has its own maximum.
sizestringOptional

One of the model’s sizes, such as 1024x1024.

qualitystringOptional

One of the model’s qualities, such as low, medium, high.

stylestringOptional
backgroundenumOptional
Allowed values:
output_formatenumOptional
Allowed values:
userstringOptional
metadatamap from strings to stringsOptional

Response

Links to the images.
createdintegerOptional
datalist of objectsOptional
usageobjectOptional
Token usage, for models billed by tokens.

Errors

400
Bad Request Error
401
Unauthorized Error
402
Payment Required Error
403
Forbidden Error
404
Not Found Error
429
Too Many Requests Error
502
Bad Gateway Error