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
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Use gpt-image-2. |
prompt | string | Yes | Image editing prompt. |
image | string | Yes | Reference image HTTP(S) URL. |
size | string | Yes | Output dimensions, such as 1024x1024. |
quality | string | No | low, medium, or high. Default: medium. |
output_format | string | No | png, jpeg, or webp. |
background | string | No | For gpt-image-2. auto (model chooses from the prompt), opaque (opaque background), or transparent (transparent background). Omitted or null: auto. |
n | integer | No | Default: 1; range: 1 to 8. |
response_format | string | No | Use 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 tonull.opaque: request an opaque background.transparent: request a transparent background. Setoutput_formattopngorwebp; if omitted, it defaults topng.
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
| Field | Type | Required | Title | Description |
|---|
Response Examples
Example 1
{
"created": 1777107492,
"data": [
{
"url": "https://xxxxx.com/xxxx.png"
}
]
}