OpenAI Edits
/v1/images/edits is the OpenAI Images API compatible synchronous image editing endpoint. General API keys use the synchronous image gateway. Task API keys use Task API models and pricing, and wait synchronously for the edit result.
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 |
| General API key | Requires an OpenAI platform group with image generation enabled |
| Task API key | Uses Task API model and billing configuration |
With a Task API key, this endpoint waits for up to 120 seconds. If the wait times out and the response includes task_id, use the Task API to query the final status.
Multipart Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | No | Image model. Defaults to gpt-image-2. General API keys must use an OpenAI Images compatible model; Task API keys may use any available Task API image model. |
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 | Image model. Defaults to gpt-image-2. General API keys must use an OpenAI Images compatible model; Task API keys may use any available Task API image model. |
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. |
504 | Task API key synchronous wait timed out. The response includes task_id when the final status can be queried later. |
500 / 502 / 503 | Gateway or upstream provider failed. |