POST /v1/images/edits
Generates an edited version of an image based on a text prompt. You can optionally supply a mask image to restrict edits to a specific region. The request body must be sent asmultipart/form-data.
This endpoint is currently supported for providers that expose an
imageEdit operation, such as OpenAI (dall-e-2).Request headers
string
The provider to route the request to (e.g.
openai). Required when not using a config.string
Your provider API key.
string
A JSON config object or config ID that defines routing, fallbacks, retries, and more.
string
A virtual key ID from Portkey Cloud.
Request body
This endpoint accepts
multipart/form-data. The image and mask must be uploaded as file fields, not JSON.file
required
The source image to edit. Must be a valid PNG file, less than 4 MB, and square. The image must have an alpha channel (transparency) to indicate the area to edit.
string
required
A text description of the desired edit. Maximum 1000 characters.
file
An optional PNG mask image that defines which areas to edit. Fully transparent areas (alpha = 0) are edited; fully opaque areas are preserved. Must be the same size as the source image.
string
default:"dall-e-2"
The model to use for image editing.
integer
default:"1"
The number of edited images to generate. Must be between 1 and 10.
string
default:"1024x1024"
The size of the generated images. One of
256x256, 512x512, or 1024x1024.string
default:"url"
The format of the response. One of
url or b64_json.string
A unique identifier for the end user.
Response
integer
Unix timestamp of when the images were created.
object[]
An array of generated image objects.