OpenAI Edits
/v1/images/edits is the OpenAI Images API compatible synchronous image editing endpoint.
Interface
| Item | Value |
|---|---|
| Method | POST |
| Path | /v1/images/edits, also supports /images/edits |
| Content-Type | multipart/form-data or application/json |
| Authentication | Authorization: Bearer YOUR_API_KEY |
| Regular API key | Requires an OpenAI platform group with image generation enabled |
Multipart Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | No | OpenAI Images compatible 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 | OpenAI Images API edit parameter. Availability depends on the selected model. |
JSON Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | No | OpenAI Images compatible 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. |
For JSON requests, image URLs must be accessible by the service. Use multipart upload when the source image is local to the client.
Multipart Example
bash
curl https://api.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://api.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"
}'Response — 200 OK
json
{
"created": 1779912000,
"data": [
{
"b64_json": "..."
}
]
}| Field | Description |
|---|---|
created | Unix timestamp when the response was created. |
data[].b64_json | Base64 edited image payload when response_format is b64_json. |
data[].url | Edited image URL when URL responses are available. |
Errors
| Status | Cause |
|---|---|
400 | Request body is invalid, an image file or images[].image_url is missing, or unsupported fields such as file_id are used. |
401 | API key is missing or invalid. |
403 | Balance, quota, or group permission check failed. |
404 | Current API key group cannot call the OpenAI Images API. |
429 | Rate limit or concurrency limit was reached. |
500 / 502 / 503 | Gateway or upstream provider failed. |