Prompt
How do I create image variations from one prompt through an API?
Latest observation
Oct 11, 2026
OpenAI APIWeb search: off
To create multiple image variations from a single prompt via an API, you generally do one of these:
- Generate multiple images in one request by setting a
n/countparameter. - Generate one image and vary it using an image editing/variation endpoint, if the API supports it.
- Reuse the same prompt with different seeds/styles to get controlled diversity.
If you mean OpenAI’s image API specifically, the simplest approach is usually multiple images from one prompt.
Example: generate multiple images from one prompt
Python
from openai import OpenAI
client = OpenAI()
result = client.images.generate(
model="gpt-image-1",
prompt="A futuristic city skyline at sunset, cinematic lighting, highly detailed",
size="1024x1024",
n=4
)
for i, img in enumerate(result.data):
print(f"Image {i+1}: {img.url}")
cURL
curl https://api.openai.com/v1/images/generations \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-1",
"prompt": "A futuristic city skyline at sunset, cinematic lighting, highly detailed",
"size": "1024x1024",
"n": 4
}'
If you want more distinct variations
Try changing:
- style words: “photorealistic”, “anime”, “oil painting”, “minimalist”
- camera/composition: “wide angle”, “close-up”, “top-down”
- mood/lighting: “dramatic lighting”, “soft natural light”
- seed: if supported by your provider, use different seeds for reproducible variation
If you want variations of an existing image
Use an edit/variation endpoint with an input image, if available in your API. That’s better when you want to preserve composition while changing details.
Good practice for prompts
A strong prompt often includes:
- subject
- environment
- style
- lighting
- composition
- quality/detail hints
Example:
“A red sports car parked on a rainy Tokyo street at night, neon reflections, cinematic, ultra-detailed, shallow depth of field”
If you want, I can show you:
- a Node.js example
- a Python batch script
- or how to do image variations with seeds and prompt templates
Brands