Image editing. Both the official OpenAI SDK's multipart/form-data upload and a
JSON body (base64 string) are accepted.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | ID of a model that supports editing |
prompt | string | Yes | 1–4000 characters |
image | string | file | Yes | Source image — a base64 string in JSON, a file part in multipart |
mask | string | file | No | Mask for the region to edit |
n | integer | No | Number of images to generate, 1–4 (default 1) |
size | string | No | 256x256 · 512x512 · 1024x1024 (default) |
response_format | string | No | url (default) · b64_json |
user | string | No | End-user identifier |
A request body larger than 5MB returns 413. Resize the image to 1024px or smaller before sending.
Request (JSON)
{
"model": "<ID of a model that supports editing>",
"prompt": "change the sky to sunset",
"image": "<base64-encoded-image>",
"n": 1
}Response
{
"created": 1709884800,
"data": [
{ "url": "https://..." }
]
}