Skip to main content
POST
GPT-Image-2

Introduction

GPT-Image-2 offers real-world intelligence, multilingual understanding, 4K resolution support and a smart routing layer, exposed through two complementary endpoints: Both endpoints share the same response format: Base64 output (b64_json) plus usage token stats.

Capability comparison

In OpenAIโ€™s official definition, /v1/images/generations for gpt-image-2 is a text-only endpoint: it accepts a text prompt and does not support passing images for image-to-image; official I2I is available only through /v1/images/edits. We have extended /v1/images/generations with image-to-image support โ€” send a text prompt together with images and the model will re-create, restyle, reference or inpaint based on your input.
For full parameters and other image models, see Image generation.

Authentication

string
required
Bearer Token, e.g. Bearer sk-xxxxxxxxxx
string
required
application/json for JSON requests; multipart/form-data for file uploads

Supported models

Parameters

Both endpoints accept the same parameter set.
string
required
Fixed value gpt-image-2
string
required
Image description (text-to-image) or edit instruction (image-to-image)
string | string[]
Input image(s) for image-to-image. A string for one image, an array for several; URL or base64 data URI. Omit for text-to-image
integer
default:"1"
Number of images to generate, 1-10
string
default:"1024x1024"
Image size, see the size table below
string
default:"high"
Image quality: low, medium, high, auto
string
default:"auto"
Background opacity: auto or opaque. Passing transparent returns an error
string
default:"png"
Output image format: png, jpeg
number
default:"100"
Compression level 0โ€“100, applies to jpeg only
string
default:"auto"
Moderation strictness: auto or low (more permissive)
string
End-user identifier, used for abuse detection

size values

quality values

Text-to-image: POST /v1/images/generations

Generate an image from a text description. Pass model and prompt only, and the image is returned at the requested size and quality โ€” ideal for creative generation and asset production driven purely by text.

Request examples

Response example

This endpoint also supports image-to-image. Add an image field to a text-to-image request (URL or base64 data URI โ€” a string for one image, an array for several) and the request is routed to the image editing flow automatically: one unified endpoint, no switching required.There is no hard cap on the number of input images โ€” the limit comes from the upstream total token budget. Each image may be up to 50MB.
Image-to-image responses use the same structure as text-to-image, except that usage.input_tokens_details.image_tokens is greater than 0, reflecting the tokens consumed by the input images:

Image-to-image: POST /v1/images/edits

The standard OpenAI image editing endpoint: re-create, restyle, inpaint or blend multiple references on top of an input image. Accepts both JSON and multipart/form-data.

Option 1: multipart/form-data

Use this to upload local image files directly.
Images are passed via image[] โ€” use image[] even for a single file.

Option 2: JSON

Use this to pass image URLs or base64-encoded images. Parameters are identical to image-to-image on the generations endpoint.
This endpoint also supports text-to-image. Omit the image field and send only model and prompt: the request is handled as pure text-to-image and returns the same result as /v1/images/generations, so apps already wired to edits can keep a single endpoint.

Response fields

Both endpoints return the same structure:

usage fields

  • GPT-Image-2 always returns base64-encoded image data (b64_json); response_format=url is not supported.
  • output_tokens is entirely image output โ€” this model produces no text output.
  • Billing is token-based, with separate unit prices for text input, image input and image output.

Pricing

All prices are in USD per 1M tokens, billed on the usage tokens returned upstream.

Notes

  1. Image generation usually takes 10โ€“30 seconds, depending on size and quality
  2. Image data is always returned base64-encoded
  3. Supported input formats: PNG, JPEG, WebP; output formats: PNG, JPEG
  4. 4K generation takes noticeably longer โ€” prefer standard sizes when possible
  5. Setting quality to low speeds up generation significantly
  6. gpt-image-2 always processes input images at high fidelity; the input_fidelity parameter is neither needed nor supported
  7. Each uploaded image may be up to 50MB
  8. n (number of output images) ranges from 1 to 10
  9. There is no hard cap on input image count โ€” it is bounded by the upstream total token limit
  10. The model has no text output; output_tokens is entirely image output tokens
  11. background supports only auto (default) and opaque โ€” transparent returns an error

Image generation

Overview of the multi-model image generation API

Image edits

More usage and examples for the edits endpoint