latestOpenAPI 3.0.22026-08-15117255447.5 KB

4918f84cbfd7

images-edit

Edit images with GPT Image 2 from an instruction, by asset id or by uploaded bytes

Edit one or more source images by describing the change in plain language. Supply the sources either as image_asset_identifiers references (images already stored with Ideogram) or as raw images bytes (multipart requests only) — callers are never required to upload assets first. If both are supplied, the references win and the bytes are ignored.

By default the request blocks until the edited images are ready and returns them in data. Set async to true to return immediately after the request is accepted, then poll for completion and results with GET /v1/generations/{generation_id} using the returned generation_id.

post/v2/images/edit/gpt-image-2

Request body

promptstring required

The edit instruction to apply to the source images.

imagesstring[]

The source images to edit (max 16, max size 25MB per image), as raw bytes; only JPEG, PNG, and WEBP formats are supported. Multipart requests only; ignored if image_asset_identifiers is also supplied.

num_imagesinteger

The number of edited images to generate.

seedinteger

Random seed. Set for reproducible generation.

aspect_ratiostring

The requested output aspect ratio, for example "1:1", "16:9", or "9:16". Ignored when resolution is provided. Defaults to "1:1".

resolutionstring

Exact output resolution, formatted as "WIDTHxHEIGHT", for example "2048x2048" or "1920x1088". When provided, this takes precedence over aspect_ratio. The dimensions must satisfy GPT Image 2 constraints: each side is a multiple of 16, the largest side is at most 3840px, the long:short ratio is at most 3:1, and total pixels are between 655360 and 8294400 inclusive.

asyncboolean

When false (the default), the request blocks until the edited images are ready and returns them in data. When true, the request returns as soon as it is accepted; poll for completion and results with GET /v1/generations/{generation_id} using the returned generation_id.

Example request

{
  "image_asset_identifiers": [
    {
      "asset_type": "RESPONSE",
      "asset_id": "7uS_VESkRI6O3-sVgHQp_A"
    }
  ],
  "seed": 12345
}

Response

The edited images (synchronous requests), or an acknowledgement to poll with GET /v1/generations/{generation_id} (async requests).

generation_idstring required

URL-safe base64 ID of the accepted generation. Accepted by the GET /v1/generations/{generation_id} polling endpoint.

seedinteger required

Random seed. Set for reproducible generation.

widthinteger required

The output width in pixels this request resolved to.

heightinteger required

The output height in pixels this request resolved to.

Example response

{
  "data": [
    {
      "seed": 12345,
      "prompt": "prompt",
      "resolution": "2048x2048",
      "url": "https://openapi-generator.tech",
      "is_image_safe": true
    },
    {
      "seed": 12345,
      "prompt": "prompt",
      "resolution": "2048x2048",
      "url": "https://openapi-generator.tech",
      "is_image_safe": true
    }
  ],
  "seed": 12345,
  "generation_id": "generation_id",
  "width": 0,
  "height": 6
}