Image Edits
Edit images using text prompts, masks, and inpainting.
Edit images by providing a source image, an optional mask, and a text prompt describing the desired changes. This is commonly known as inpainting.
POST /v1/images/editsAuthentication
AuthorizationBearerrequiredAPI key as bearer token in the Authorization header. Create keys at
Manage API Keys.
Headers
Content-TypestringrequiredMust be multipart/form-data.
Body
imageFilerequiredThe image to edit. Must be a valid PNG file, less than 4MB, and square. Transparent areas will be used as the mask if no mask is provided.
promptstringrequiredText description of the desired edit or what should fill the masked area.
modelstringrequiredImage model id from GET /v1/models. Example: dall-e-2, gpt-image-1.
maskFileoptionalAn additional image whose fully transparent areas indicate where the
original image should be edited. Must be a valid PNG file, less than 4MB,
and the same dimensions as image.
nintegeroptionalDefault 1Number of images to generate. Range: 1-10.
sizestringoptionalDefault 1024x1024Output dimensions.
256x256512x5121024x1024response_formatstringoptionalDefault urlurl returns a temporary URL (valid ~1 hour), b64_json returns inline
base64 data.
urlb64_jsonuserstringoptionalEnd-user identifier for abuse tracking.
Mask behavior
The mask indicates where edits should be applied. Transparent areas in the mask are where the model will generate new content based on your prompt. If no mask is provided, transparent areas in the source image are used.
Response
createdintegeroptionalUnix timestamp (seconds) when the images were generated.
dataImage[]optionalArray of edited images. Each contains either url or b64_json
depending on response_format.
Use cases
- Inpainting: Fill in or replace specific parts of an image
- Object removal: Mask an object and prompt for background fill
- Object replacement: Mask an area and describe what should replace it
- Style transfer: Apply changes to masked regions