Image Generation

An API for generating and editing images from text prompts using gpt-image-2.5-sunburst and gpt-image-2.5-flare.

Verified

Definition

The API lets you generate and edit images from text prompts using gpt-image-2.5-sunburst and gpt-image-2.5-flare. The Image API provides two endpoints, each with distinct capabilities. The Responses API allows you to generate images as part of conversations or multi-step flows.

The Responses API supports image generation as a built-in tool, and accepts image inputs and outputs within context. Both the Image API and the Responses API let you customize output by adjusting quality, size, format, and compression.

At a glance

gpt-image-2.5-sunburst and gpt-image-2.5-flare add xhigh and max quality settings. Earlier GPT Image models support quality settings up to high.

  • The Generations endpoint of the Image API generates images from scratch based on a text prompt.
  • The Edits endpoint of the Image API modifies existing images using a new prompt, either partially or entirely.
  • The Image API returns base64-encoded image data.
  • The output format defaults to png, and jpeg or webp can also be requested.
  • The compression option sets the compression level for JPEG and WebP formats, in a range of 0-100%.
  • For transparent backgrounds with gpt-image-2.5-sunburst or gpt-image-2.5-flare, the background is set to transparent and a png or webp output format is used.
  • For image generation using GPT Image models, the moderation parameter controls moderation strictness.
  • The moderation value auto is the default and applies standard filtering that seeks to limit creating certain categories of potentially age-inappropriate content, while the value low applies less restrictive filtering.

The source does not state the order of these points, so they are listed without arrows.

How it works

With the Responses API, you can build multi-turn conversations involving image generation by providing image generation call outputs within context (or just the image ID), or by using the previous_response_id parameter. If you force edit without providing an image in context, the call will return an error. The Responses API and the Image API both support streaming image generation.

You can adjust the partial_images parameter to receive 0-3 partial images, and if you set it to 0, you will only receive the final image. When using the image generation tool in the Responses API, the mainline model (for example, gpt-5.5) automatically revises the prompt, and the revised prompt can be accessed in the revised_prompt field of the image generation call. You can set the n parameter to generate multiple images at once in a single request, and by default the API returns a single image.

When streaming with the partial_images parameter, each partial image incurs an additional 100 image output tokens. Responses API requests include the mainline model's token usage in addition to image generation costs.

Example

You can use one or more images as a reference to generate a new image. In the reference-image example, 4 input images are used to generate a new image of a gift basket containing the items in the reference images. With the Responses API, input images can be provided in 3 different ways.

You can provide a mask to indicate which part of the image should be edited. If you provide multiple input images, the mask is applied to the first image. Masking with GPT Image is entirely prompt-based.

The mask image must also contain an alpha channel.

Sources

This page is written from the official sources below. Open them to check the original text.

Verified ·

This page is written by AI from the official sources above and checked automatically. This site has not tested it. Found a mistake? Tell us.