Image editing
OpenAI-compatible
Image editing
POST /v1/images/edits — image-to-image based on a source image and mask
POST
Image editing
Generate an edited version based on a source image (with an optional mask), for tasks like removal, outpainting and style transfer.
Request
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
image | file | ✅ | Source image (PNG / JPEG). gpt-image-1 accepts multiple (comma-separated or repeated fields) |
mask | file | Same size as the source; transparent areas are editable | |
prompt | string | ✅ | Editing instruction |
model | string | gpt-image-1 / dall-e-2 | |
n | integer | 1-10 | |
size | string | 256x256 / 512x512 / 1024x1024, etc. | |
response_format | string | url / b64_json | |
quality | string | low / medium / high (gpt-image-1) |
Response
Python example
Making a mask
- The mask must be the same size as the source + a PNG alpha channel.
- Transparent pixels mark the area the model is allowed to repaint.
- Opaque pixels mark the area that must stay as the original.
- You can create it with Photoshop / GIMP / PIL.
Multi-image blending (gpt-image-1)
gpt-image-1 supports using multiple images as input references: