Generate images
Creates an image given a text prompt.A text description of the desired image(s). Maximum length is 32000 characters for GPT image models, 1000 for DALL-E.
The model to use for image generation. Options:
dall-e-2, dall-e-3, gpt-image-1.5, gpt-image-1, gpt-image-1-mini, chatgpt-image-latest.The number of images to generate. Must be between 1 and 10. For
dall-e-3, only n=1 is supported.The size of the generated images. Options include
1024x1024, 1536x1024 (landscape), 1024x1536 (portrait), 256x256, 512x512.The quality of the image. Options:
standard or hd. HD quality is available for dall-e-3 and GPT image models.The style of the generated images. Options:
vivid or natural. Only supported for dall-e-3.The format in which images are returned. Options:
url or b64_json.Set transparency for the background. Options:
opaque or transparent.The format for generated images. Supported for GPT image models. Options include
png, jpeg, webp.The compression level (0-100%) for the generated images. Only for GPT image models.
Control the content-moderation level. Options:
off, low, medium, high. Only for GPT image models.A unique identifier representing your end-user.
Response
Returns anImagesResponse object.
Unix timestamp of when the image was created.
List of generated image objects.
Examples
Basic image generation
HD quality with specific size
Multiple images
Streaming image generation
Edit images
Creates an edited or extended image given one or more source images and a prompt.The image(s) to edit. Must be a valid PNG file, less than 4MB, and square.
A text description of the desired image(s). Maximum length is 1000 characters.
An additional image whose fully transparent areas indicate where to edit. Must be a valid PNG file.
The model to use. Supports GPT image models and
dall-e-2.The number of images to generate. Must be between 1 and 10.
The size of the generated images. Same options as generate.
The format in which images are returned:
url or b64_json.The quality of the image. Options:
standard or hd.Control how much effort the model exerts to match the style and features. Options:
auto, low, medium, high.Examples
Edit an image
Edit with mask
Streaming edit
Create image variations
Creates a variation of a given image. Only supportsdall-e-2.
The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.
The model to use. Only
dall-e-2 is supported at this time.The number of images to generate. Must be between 1 and 10.
The size of the generated images. Options:
256x256, 512x512, or 1024x1024.The format in which images are returned:
url or b64_json.Examples
Create variations
Download and save images
Best practices
- Be specific: More detailed prompts generally produce better results
- Choose the right model: Use
dall-e-3or GPT image models for highest quality - Image format: For edits and variations, ensure images are PNG format and square
- File size: Keep images under 4MB for best performance
- Experiment with parameters: Try different quality, style, and size settings
- Use streaming: For real-time feedback with GPT image models