Skip to main content
POST
Generate an image
See the Images guide for runnable examples, edit / image-to-image, and model discovery.

Authorizations

Authorization
string
header
required

API key authentication. Pass your API key as a Bearer token.

Body

application/json
model
string
required

A model id from GET /v3/images/models, such as openai/gpt-image-2.5-flare. Ids name the provider; a bare model name answers 400 with the ids that serve it.

prompt
string
required
aspect_ratio
string

Shape such as 16:9, for models that list params.image.aspect_ratios.

async
boolean

Run generation on the background worker and return a job to poll (202) instead of waiting inline (200). Use for slow models. Single-image only.

callback_url
string

HTTPS URL that receives a signed image.completed or image.failed webhook when the job ends, so you do not have to poll. Rules, each answered with a 400 that names it: https only, port 443 (or none), no user:password@, no #fragment, at most 2048 characters, and a host that is a public IP address or a public name resolving only to public addresses (no localhost, private, link-local, metadata or internal names). Verify the signature with the project's secret from GET /v3/webhooks/secret; see the jobCompleted webhook for the payload, headers and retries. Only with async: true; a synchronous request with callback_url answers 400.

image
string

The image to edit: URL, data-URI or file_<id>. Needs the image_edit capability.

mask
string

Inpaint mask marking the region of image to change.

n
integer
parameters
object

Provider settings, forwarded verbatim. The keys each model takes are listed with descriptions in its params.image.parameters (GET /v3/images/models).

quality
string

A tier from the model's params.image.qualities. On Gemini image models it also sets the size: the default gives about 1K, high 2K and 4k 4K.

reference_images
string[]

Further images the result draws on (subject, product, style).

resolution
string

Output-resolution tier for models that declare one (e.g. xAI 1k/2k). Separate axis from quality.

response_format
string
size
string

Pixel size WxH. A model with params.image.size_constraints takes any size inside them (GPT Image: 2K is 2048x2048, 4K 3840x2160), else one of params.image.sizes.

store
boolean

Persist each generated image to /v3/files and return a reusable file_id per image. Defaults to false; set true to store.

Response

Successful response

created
integer
required
data
object[]
required
id
string
required
model
string
required
usage
object
required
Last modified on June 16, 2026