Skip to main content
POST
Edit an image

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

multipart/form-data
model
enum<string>
required

Model ID. gpt-image-2 is the official model; gpt-image-2-c is the cost-efficient variant (supports response_format)。

Available options:
gpt-image-2,
gpt-image-2-c
Example:

"gpt-image-2"

prompt
string
required

Edit instruction text.

Example:

"Replace the image background with a sunset over the sea"

image
file

A single source image file (PNG or JPEG). Use image[] for multiple images.

image[]
file[]

Multiple source image files (PNG or JPEG), up to 16 per request. Use this instead of image for multiple images.

mask
file

Mask image file (with an alpha channel) that marks the region to edit. Must match the source image format and size (< 50MB). Select the Direct group in the console.

output_format
enum<string>
default:png

Output image format. Defaults to png.

Available options:
png,
jpeg
output_compression
integer

Compression level for jpeg (0–100).

Required range: 0 <= x <= 100
n
integer
default:1

Number of images to return, 1–10, default 1. Select the Direct group in the console.

Required range: 1 <= x <= 10
Example:

1

size
string
default:1024x1024

Output image size in {width}x{height} format, with the same constraints as the image generation API (flexible resolution).

Example:

"1024x1024"

response_format
enum<string>
default:url

Response format. Supported only by gpt-image-2-c (cost-efficient variant). Currently only url.

Available options:
url
Example:

"url"

Response

Image edited successfully.

data
object[]

Array of edited images.