> ## Documentation Index
> Fetch the complete documentation index at: https://docs.yingtu.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# GPT Image 2 Web parameters

> Reference gpt-image-2-web text-to-image, single or multi-image input, three sizes, forwarded quality, idempotency, and native task results.

Use this exact model ID:

```text theme={"system"}
gpt-image-2-web
```

## Synchronous Generate body

| Field     | Contract                                                                    |
| --------- | --------------------------------------------------------------------------- |
| `model`   | Required; `gpt-image-2-web`                                                 |
| `prompt`  | Required string                                                             |
| `n`       | Omit or use `1`                                                             |
| `size`    | Set explicitly to `1024x1024`, `2048x2048`, or `3840x2160`                  |
| `quality` | `low`, `medium`, `high`, or `auto`; effect depends on the selected upstream |

```json theme={"system"}
{
  "model": "gpt-image-2-web",
  "prompt": "A blue ceramic teapot on a pale table, no text",
  "size": "1024x1024",
  "quality": "high",
  "n": 1
}
```

Send this JSON to `/v1/images/generations` for synchronous work.

Set `size` explicitly when downstream storage or layout depends on exact pixels. The public API does not define the output dimensions produced by an omitted value.

## Unified asynchronous body

Send JSON to `/v1/images/tasks`. Generation uses `action=generate` and omits `input_images`. Editing accepts 1–16 items; this two-image request combines references:

```json theme={"system"}
{
  "model": "gpt-image-2-web",
  "action": "edit",
  "prompt": "Keep the product and replace the background with pale blue",
  "input_images": [
    {"mime_type": "image/png", "data": "BASE64_SOURCE_IMAGE_1"},
    {"mime_type": "image/jpeg", "data": "BASE64_SOURCE_IMAGE_2"}
  ],
  "size": "1024x1024",
  "quality": "high",
  "n": 1
}
```

Use raw Base64 without a data URL prefix. Each decoded source must not exceed 20 MiB, all sources together must not exceed 64 MiB, and `mime_type` must match the PNG, JPEG, or WebP bytes. Omit `aspect_ratio`.

Add `Idempotency-Key` to retryable submissions. The key is limited to 255 bytes; the same key and body replay the task, while a changed body returns HTTP `409`.

## Edit form

`POST /v1/images/edits` uses `multipart/form-data`:

| Form field | Contract                                                      |
| ---------- | ------------------------------------------------------------- |
| `model`    | Required; `gpt-image-2-web`                                   |
| `prompt`   | Required edit instruction                                     |
| `image`    | Required source PNG, JPEG, or WebP file                       |
| `size`     | One documented preset                                         |
| `n`        | Omit or use `1`                                               |
| `quality`  | `low`, `medium`, `high`, or `auto`; upstream-dependent effect |

Synchronous multipart Edit covers one source image. Use the unified task endpoint for multiple references.

Synchronous multipart Edit does not publish one fixed source-image byte or pixel limit. If the gateway returns HTTP `413`, reduce the image and total multipart body before retrying; the unified JSON task limit remains 20 MiB decoded. See [errors and safe retries](/en/getting-started/errors-and-retries).

## Response

Successful Generate and Edit responses contain one image:

```json theme={"system"}
{
  "created": 1788307200,
  "data": [{"b64_json": "BASE64_IMAGE_DATA"}],
  "usage": {
    "input_tokens": 24,
    "output_tokens": 1756,
    "total_tokens": 1780
  }
}
```

Decode `b64_json` before writing the PNG. Do not expect a hosted image URL.

## Controls outside this reverse-image route

The public contract does not include masks, `n > 1`, partial-image streaming, output format/compression, transparency, callbacks, or cancellation. Completed tasks preserve native ImagesResponse under `result`, expose `result_expires_at`, and expire the image after 24 hours.

<Card title="Copy Web examples" icon="braces" href="/en/models/image/gpt-image/gpt-image-2-web/examples">
  Use complete synchronous, asynchronous, and editing flows.
</Card>
