Images
Edit Images
POST
Edit Images
Creates an edited or extended image given one or more source images and a prompt.
This endpoint supports GPT Image models (
gpt-image-1.5, gpt-image-1, gpt-image-1-mini, and chatgpt-image-latest) and dall-e-2.
Method Signature
Parameters
file
required
The image(s) to edit. Must be a supported image file or an array of images.For GPT image models:
- Each image should be a
png,webp, orjpgfile less than 50MB - You can provide up to 16 images
chatgpt-image-latestfollows the same input constraints
dall-e-2:- You can only provide one image
- Must be a square
pngfile less than 4MB
string
required
A text description of the desired image(s). The maximum length is:
- 32000 characters for GPT image models
- 1000 characters for
dall-e-2
file
An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where
image should be edited. If there are multiple images provided, the mask will be applied on the first image. Must be a valid PNG file, less than 4MB, and have the same dimensions as image.string
The model to use for image generation. Options:
gpt-image-1.5(default)gpt-image-1gpt-image-1-minichatgpt-image-latestdall-e-2
integer
The number of images to generate. Must be between 1 and 10.
string
The size of the generated images:
- GPT image models:
1024x1024,1536x1024(landscape),1024x1536(portrait), orauto(default) dall-e-2:256x256,512x512, or1024x1024
string
The format in which the generated images are returned. Must be one of
url or b64_json.Only supported for dall-e-2 (default is url). GPT image models always return base64-encoded images.string
The quality of the image that will be generated for GPT image models:
auto(default)standardlowmediumhigh
string
Allows to set transparency for the background of the generated image(s). Only supported for GPT image models:
transparentopaqueauto(default) - model automatically determines the best background
transparent, the output format needs to support transparency (png or webp).string
Control how much effort the model will exert to match the style and features, especially facial features, of input images. Only supported for
gpt-image-1 and gpt-image-1.5 and later models, unsupported for gpt-image-1-mini:low(default)high
string
The format in which the generated images are returned. Only supported for GPT image models:
png(default)jpegwebp
integer
The compression level (0-100%) for the generated images. Only supported for GPT image models with
webp or jpeg output formats. Defaults to 100.boolean
Edit the image in streaming mode. Defaults to
false. See the Image generation guide for more information.integer
The number of partial images to generate. Used for streaming responses. Value must be between 0 and 3. When set to 0, the response will be a single image sent in one streaming event.
string
A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more.
Returns
Returns anImagesResponse object containing the edited images.
integer
The Unix timestamp (in seconds) of when the image was created.
array
The list of generated images.
Examples
Edit with mask (DALL-E 2)
Edit without mask (GPT Image model)
Edit multiple images
Edit with transparent background
Edit Images