Skip to main content
POST
OpenAI image edit
This endpoint is compatible with the OpenAI Images protocol and generates a new image from the source images you provide and an edit prompt. It supports inpainting, outpainting, and multi-image fusion scenarios.

Features

  • References source images through URL addresses or file IDs
  • Supports inpainting with the mask image to specify the edit area
  • Supports outpainting with the background image for canvas extension
  • Supports input_fidelity to control input image fidelity (high / low)
  • Supports png, jpeg, and webp output formats with output_compression control
  • Supports both url and b64_json response formats
  • Supports streaming (SSE) responses with intermediate results pushed via partial_images

Authentication

Include the Authorization header in the format Bearer YOUR_API_KEY.

Supported image models

Available image models in the Model Square, please refer to Model List.

Quick example

A successful edit returns the image data:

Next steps

Headers

Authorization
string
required

API Key token (Bearer sk-xxx)

Content-Type
string

Body

application/json
images
object[]
required

Source images to edit

prompt
string
required

Edit prompt describing the changes to apply to the image

model
string
required

Model name, e.g. "dall-e-2"

background
string

Background image data (for outpainting and similar extension scenarios)

input_fidelity
string

Input image fidelity control: high, low

mask
object

Mask image specifying the edit area (inpainting)

n
integer

Number of images to generate

output_compression
integer

Output compression level

output_format
string

Output image format, e.g. "png", "jpeg", "webp"

partial_images
integer

Number of intermediate result images pushed per update in streaming responses

response_format
string

Response format, "url" or "b64_json"

quality
string

Image quality, e.g. "standard", "hd"

size
string

Image size, e.g. "1024x1024"

stream
boolean

Whether to use streaming (SSE) responses

user
string

End-user identifier for monitoring and abuse detection

Response

200 - application/json
created
integer<int64>

Image generation timestamp (Unix seconds)

output_format
string

Output image format echo

background
string

Background image data echo

quality
string

Image quality echo

size
string

Image size echo

data
object[]

Generated image data list

usage
object

Token and image usage statistics