Skip to main content
POST
  1. After submission, a task_id will be returned. If you provided a callback_url, when the task status becomes finished or failed, a POST request will be sent to the callback_url.
  2. Regardless of whether callback_url is provided, you can retrieve the result through the unified Query Task Status endpoint.
Generate images from text prompts or edit one or more reference images with natural-language instructions using GPT Image 2 models.

Models

  • gpt-image-2 - Text-to-image generation, and optional reference-image-guided generation
  • gpt-image-2-edit - Image editing based on one or more reference images and a text instruction

Resolution

The resolution parameter controls the output image resolution.

Resolution Rules

  • Images with size set to auto or without a size parameter will always use 1K resolution, regardless of the resolution parameter.
  • Custom size (WIDTHxHEIGHT) requires resolution to be 2K or 4K.
  • 4K applies to 16:9, 9:16, 21:9, or custom sizes with a 3840-pixel edge. All other 4K selections are automatically downgraded to 2K.

Custom Size Constraints

Custom sizes use WIDTHxHEIGHT format (e.g., 2304x1536) and must meet the following requirements:
  • Both dimensions must be divisible by 16
  • Maximum edge length: 3840 pixels
  • Aspect ratio: up to 3:1
  • Total pixels: between 655,360 and 8,294,400

Examples

Generate Image

Edit Image

Notes

  • gpt-image-2-edit requires image_urls.
  • image_urls supports uploading multiple reference images.
  • prompt supports up to 20,000 characters.
  • Each request returns a single image.
  • quality controls output image quality. Possible values: low, medium, high. Default: low.
  • Supported size values: auto, 1:1, 2:3, 3:2, 4:3, 3:4, 4:5, 5:4, 16:9, 9:16, 21:9, or custom WIDTHxHEIGHT.

Authorizations

Authorization
string
header
required

All API endpoints require Bearer Token authentication

Get your API Key:

Visit the API Key Management Page to get your API Key

Add it to the request header:

Body

application/json
model
enum<string>
required

GPT Image 2 model identifier

Available options:
gpt-image-2,
gpt-image-2-edit
callback_url
string<uri>

Webhook callback URL for result notifications

Example:

"https://your-domain.com/callback"

input
object

Input parameters for generation or editing

Response

Task submitted successfully

code
integer
required

HTTP status code

Example:

200

data
object
required