Skip to content

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

ItemValue
MethodPOST
Path/v1/images/edits, also supports /images/edits
Content-Typemultipart/form-data or application/json
AuthenticationAuthorization: Bearer YOUR_API_KEY
General API keyRequires an OpenAI platform group with image generation enabled
Task API keyUses 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

ParameterTypeRequiredDescription
modelstringNoImage 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.
promptstringYesEdit instruction.
imagefileYesInput image. Multiple images can use repeated image fields or image[].
maskfileNoMask image.
sizestringNoOutput size.
nintegerNoNumber of images.
response_formatstringNoResponse format.
input_fidelitystringNoOpenAI Images API edit parameter. Availability depends on the selected model.

JSON Parameters

ParameterTypeRequiredDescription
modelstringNoImage 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.
promptstringYesEdit instruction.
imagesarrayYesItems support { "image_url": "https://..." }. file_id is not supported.
mask.image_urlstringNoMask image URL. mask.file_id is not supported.
sizestringNoOutput size.
nintegerNoNumber 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": "..."
    }
  ]
}
FieldDescription
createdUnix timestamp when the response was created.
data[].b64_jsonBase64 edited image payload when response_format is b64_json.
data[].urlEdited image URL when URL responses are available.

Errors

StatusCause
400Request body is invalid, an image file or images[].image_url is missing, or unsupported fields such as file_id are used.
401API key is missing or invalid.
403Balance, quota, or group permission check failed.
404Current API key group cannot call the OpenAI Images API.
429Rate limit or concurrency limit was reached.
504Task API key synchronous wait timed out. The response includes task_id when the final status can be queried later.
500 / 502 / 503Gateway or upstream provider failed.