OpenAI Edits
/v1/images/edits is the OpenAI Images API compatible synchronous image editing endpoint. It uses the same platform, group permission, content moderation, concurrency, and billing checks as image generation.
Interface
| Item | Value |
|---|---|
| Method | POST |
| Path | /v1/images/edits |
| Content-Type | multipart/form-data or application/json |
| Authentication | Authorization: Bearer YOUR_API_KEY |
| Platform requirement | OpenAI platform group with image generation enabled |
Multipart Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | No | Image model. Defaults to gpt-image-2. |
prompt | string | Yes | Edit instruction. |
image | file | Yes | Input image. Multiple images can use repeated image fields or image[]. |
mask | file | No | Mask image. |
size | string | No | Output size. |
n | integer | No | Number of images. |
response_format | string | No | Response format. |
input_fidelity | string | No | Native OpenAI edit parameter, forwarded when supported upstream. |
JSON Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | No | Image model. Defaults to gpt-image-2. |
prompt | string | Yes | Edit instruction. |
images | array | Yes | Items support { "image_url": "https://..." }. file_id is not supported. |
mask.image_url | string | No | Mask image URL. mask.file_id is not supported. |
size | string | No | Output size. |
n | integer | No | Number of images. |
Multipart Example
bash
curl https://llmapi.site/v1/images/edits \
-H 'Authorization: Bearer YOUR_API_KEY' \
-F 'model=gpt-image-2' \
-F 'image=@input.png' \
-F 'prompt=change the background to a clean studio setting' \
-F 'size=1024x1024'JSON Example
bash
curl https://llmapi.site/v1/images/edits \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-image-2",
"prompt": "replace the background with a bright studio",
"images": [
{ "image_url": "https://example.com/input.png" }
],
"size": "1024x1024"
}'Common Errors
| Error | Meaning |
|---|---|
Images API is not supported for this platform | The current key group is not OpenAI. |
images[].image_url is required | JSON edit request is missing an input image URL. |
images[].file_id is not supported | JSON edit requests do not currently support file_id. |
image file is required | Multipart edit request is missing an image file. |