/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
- Python
- Node.js
- cURL
Request parameters
Response object
Saving images locally
URLs expire after 1 hour. Download the image immediately if you need to keep it.- Python
- Node.js
response_format: "b64_json" to receive the image bytes directly in the API response — no second HTTP request needed.
Generating multiple images
Setn 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:Writing effective prompts
Image models are sensitive to how prompts are written. A few techniques that consistently improve results:Be specific about style and medium
Be specific about style and medium
Vague prompts produce generic results. Name a style, medium, or artist reference to anchor the output.
Describe composition and perspective
Describe composition and perspective
Tell the model where to place things and from what angle.
Add technical photography terms
Add technical photography terms
Terms like
shallow depth of field, 35mm lens, shot on film, bokeh, and golden hour reliably improve photorealistic outputs.Use negative prompts where supported
Use negative prompts where supported
Some models (like FLUX) accept a
negative_prompt parameter to exclude unwanted elements.