Skip to main content

Edit Images

In this page's examples, {BASE_URL} is https://api.uniall.ai.

Use gpt-image-2 to edit reference images. The endpoint returns image URLs synchronously.

API Parameters and Examples​

Endpoint​

POST /v1/images/edits/

Request Body Parameters​

ParameterTypeRequiredDescription
modelstringYesUse gpt-image-2.
promptstringYesImage editing prompt.
imagestringYesReference image HTTP(S) URL.
sizestringYesOutput dimensions, such as 1024x1024.
qualitystringNolow, medium, or high. Default: medium.
output_formatstringNopng, jpeg, or webp.
backgroundstringNoFor gpt-image-2. auto (model chooses from the prompt), opaque (opaque background), or transparent (transparent background). Omitted or null: auto.
nintegerNoDefault: 1; range: 1 to 8.
response_formatstringNoUse url for image URL results.

Background Control​

Background control is pending release. Pass background at the top level of the request body.

  • auto: the model chooses the background from the prompt. This is the default when omitted or set to null.
  • opaque: request an opaque background.
  • transparent: request a transparent background. Set output_format to png or webp; if omitted, it defaults to png.

An invalid background value or a transparent/jpeg combination returns HTTP 400 during request validation, before generation starts.

Request Examples​

Transparent Background​

The transparent-background request below uses gpt-image-2 and returns an image URL.

curl -X POST "{BASE_URL}/v1/images/edits" \
-H "Authorization: Bearer sk-***" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "Keep the product shape and remove the background to make it transparent",
"image": "https://example.com/input.png",
"size": "1024x1024",
"quality": "medium",
"background": "transparent",
"output_format": "png",
"n": 1,
"response_format": "url"
}'

Response Fields​

FieldTypeRequiredTitleDescription

Response Examples​

Example 1​

{
"created": 1777107492,
"data": [
{
"url": "https://xxxxx.com/xxxx.png"
}
]
}