⌘K

GPT Image 2 Edit

gpt_image_2_edit

GPT Image 2 Edit by OpenAI for high-quality image editing. Supports multiple image sizes (including 1024x1024, 1536x1024, 1024x1536, 2048x2048, 2048x1152, 3840x2160, and 2160x3840), batch generation (up to 4 images), and quality level control (low/medium/high) for various creative needs.

Authentication

authorization string required

All APIs require authentication via Bearer Token.

Get API Key:

Visit API Key Management Page to get your API Key.

Usage:

Add to request header:

Authorization: Bearer YOUR_API_KEY

Parameters

model string required

Model ID to use for the request

Options: gpt_image_2_edit


prompt string required

Text description of the desired edit, maximum length 32000 characters


images string | array required

Input image reference(s) to edit. A single string or an array of image references is accepted.

The runtime forwards this field as multipart image parts to the upstream image-edit API.


mask string | object

Optional mask image used to limit the edit area.


size string

Size of the generated image

Options: 1024x1024, 1536x1024, 1024x1536, 2048x2048, 2048x1152, 3840x2160, 2160x3840, auto

Default: auto


background string

Optional background handling mode. The value is forwarded to the provider.


output_format string

Optional output image format. The value is forwarded to the provider.


output_compression integer

Optional output compression level. The value is forwarded to the provider.


moderation string

Optional content-moderation mode. The value is forwarded to the provider.


user string

Optional end-user identifier for abuse monitoring and tracing.


n integer

Number of images to generate

Range: 1 - 4

Default: 1


quality string

Image quality level

Options: low, medium, high, auto

Default: auto


Polling

Since result generation takes time, you need to poll the task status after creating the task.

The initial response only returns information such as the task ID and initial status. The final result must be obtained by polling the task status endpoint using the task ID.

See the examples on the right for polling requests and responses.

Response Format

error object

Error information, only present when status is failed

code string

Error code

message string

Detailed error message


output array

Generation results, only present when status is completed

content array

List of generated resource content

type string

Resource type

Value: image|video

url string

Processed resource URL

jobId string

Remote task ID


usage object

Usage statistics, only present when status is completed

cost string

Total cost in USD

discount number

Discount amount


metadata object

Metadata information