Skip to main content
The /v1/images/generations endpoint takes a text prompt and returns one or more images. It is compatible with the OpenAI images.generate() SDK method — only the base URL and key need to change.

Basic example


Request parameters


Response object


Saving images locally

URLs expire after 1 hour. Download the image immediately if you need to keep it.
Alternatively, request response_format: "b64_json" to receive the image bytes directly in the API response — no second HTTP request needed.

Generating multiple images

Set n to receive several variations in a single call. Each item in data is an independent generation.

Choosing size and quality

Available sizes and quality presets vary by model. As a general guide:
Use flux-1-schnell for iteration and prototyping — it generates in seconds. Switch to flux-1-dev or dall-e-3 when quality matters for production output.

Writing effective prompts

Image models are sensitive to how prompts are written. A few techniques that consistently improve results:
Vague prompts produce generic results. Name a style, medium, or artist reference to anchor the output.
Tell the model where to place things and from what angle.
Terms like shallow depth of field, 35mm lens, shot on film, bokeh, and golden hour reliably improve photorealistic outputs.
Some models (like FLUX) accept a negative_prompt parameter to exclude unwanted elements.

Error handling

Common errors: