Skip to main content
POST /v1/images/edits
Creates an edited or extended image given an original image and a prompt. The image must be provided as a file upload.

Request Body

This endpoint accepts multipart/form-data.
image
file
required
The image to edit. Must be a valid PNG file, less than 4MB, and square.
prompt
string
required
A text description of the desired edit.
model
string
required
The model to use for image editing.
mask
file
An additional image whose fully transparent areas indicate where the image should be edited. Must be a valid PNG file with the same dimensions as the original image.
n
integer
default:"1"
The number of images to generate. Must be between 1 and 10.
size
string
default:"1024x1024"
The size of the generated images.
response_format
string
default:"url"
The format of the generated images. Either url or b64_json.

Response

created
integer
Unix timestamp of when the images were created.
data
array
Array of edited images.

Examples

Edit with Mask

from openai import OpenAI

client = OpenAI(
    api_key="sk-voidai-your_key_here",
    base_url="https://api.voidai.app/v1"
)

response = client.images.edit(
    model="dall-e-2",
    image=open("original.png", "rb"),
    mask=open("mask.png", "rb"),
    prompt="A sunlit indoor lounge area with a pool containing a flamingo",
    n=1,
    size="1024x1024"
)

print(response.data[0].url)

Edit Without Mask

response = client.images.edit(
    model="dall-e-2",
    image=open("image.png", "rb"),
    prompt="Add a rainbow in the sky",
    n=1,
    size="1024x1024"
)

Response Example

{
  "created": 1701691200,
  "data": [
    {
      "url": "https://storage.voidai.app/images/edit-abc123.png"
    }
  ]
}

Notes

The mask image must have transparency where you want edits to occur. Fully opaque areas will remain unchanged.
For best results, ensure your original image and mask are both square PNG files with the same dimensions.