Edit an image
Edit images with the OpenAI Images Edits API.
/v1/images/editsSupports Multipart file uploads or JSON image references; mask and markup are mutually exclusive. Set stream: true to receive SSE image events.
Authorization
bearerAuth Use a platform API key in the format Authorization: Bearer your-api-key.
In: header
Request Body
multipart/form-data
Upload files with Multipart or reference images with JSON; each format uses its own fields.
TypeScript Definitions
Use the request body type in TypeScript.
JSON image references
Use `application/json` to reference image URLs or file IDs; other parameters are the same as for file uploads.
| Field | JSON representation |
|---|---|
images | Required, 1–16 items, replaces `image`; each item uses exactly one of `image_url` (image URL or Base64 Data URL) or `file_id` |
mask / markup | Optional, using the same image-reference structure; cannot be supplied together |
curl -X POST "https://api.agtcloud.cn/v1/images/edits" \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "MODEL_ID",
"images": [
{
"image_url": "https://example.com/source.png"
}
],
"prompt": "Replace the background with a light-colored wall, preserving the subject"
}'Response Body
application/json
application/json
application/json
Streaming response events
These fields describe the JSON in one data: event, not the complete SSE text stream.