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

# GPT-Image-2.6-All Generation & Editing

> GPT image generation on the ChatGPT web reverse route: gpt-image-2.6-all, $0.025 per image, 10–46 s; native ChatGPT quality up to 1536 (with fingerprint), native GIF / SVG, 2K/4K super-resolution for large-canvas compatibility, transparent background and multi-image edits.

> [!NOTE]
>
> All image APIs are **synchronous**: there is no task ID, so if the client disconnects the result is lost while the request is still billed. Set a generous timeout (600 seconds recommended). See [Image API Best Practices](https://docs.apiyi.com/en/api-capabilities/image-api-best-practices.md).

## Overview

**gpt-image-2.6-all** is APIYI's **GPT image generation model on the ChatGPT web reverse route**, built on Images 2.6. Unlike the older `-all` route, which only accepted a size hint inside the prompt, this route **actually honors `size`, `n`, `background` and `output_format`**, and can return GIF, SVG and multi-image edits — a better fit for production code that needs to pin dimensions, formats and image counts.

The three things this route does best: **GIF, SVG, and native ChatGPT quality at 1536 and below (with fingerprint)**. 2K/4K is a **super-resolution tier for large-canvas compatibility** — bigger, not necessarily more detailed; for quality, stay around 1.5K.

It uses the standard OpenAI Images API endpoints: `POST /v1/images/generations` for text-to-image and `POST /v1/images/edits` for editing.

* **Price**: **\$0.025 per image**, billed per call; 2K/4K costs the same
* **Speed**: about **10–46 s** (1K 10–22 s, 2K 12–24 s, 4K 15–42 s; tail latency can exceed 60 s)
* **Quality**: long edge **512–1536 is native** — the most controllable ChatGPT web quality and fingerprint; **2K/4K is super-resolution**, which solves large-canvas size, not necessarily more detail than 1.5K
* **Formats**: PNG / JPEG / GIF / SVG, transparent background and 24-hour URLs; **GIF / SVG are native to this route and not available on 2.5-all**
* **Chinese**: native Chinese prompts; strong text rendering for posters, signage and infographics

> [!NOTE]
>
> Model pricing follows the official price list and may change. The price here is for reference only; the **Model Pricing** tab in the top navigation is authoritative: [Model Pricing](https://docs.apiyi.com/en/models/index.md).

> [card] GIF loops
>
> Native `output_format=gif`; frame count and duration are exact, dimensions are upstream-decided.

> [card] SVG vectors
>
> Native `output_format=svg`; true vector, `viewBox` follows `size`, 2K–8K.

> [card] Native ChatGPT quality
>
> Up to 1536 keeps the ChatGPT web look and fingerprint — the most controllable quality tier.

> [card] 2K/4K large-canvas compatibility
>
> Super-resolution with exact common sizes; bigger does not mean more detailed.

> [!NOTE]
>
> **How to read 2K/4K**: use it for posters, print and large screens that need a bigger canvas. It is not a sharper 1.5K and is not promised to carry more detail. For stable quality, stay at or below **1536 (around 1.5K)**.

## Quickstart

### Text to image (curl)

```bash theme={null}
curl https://api.apiyi.com/v1/images/generations \
  -H "Authorization: Bearer $APIYI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2.6-all",
    "prompt": "A beige paper-textured autumn reading club poster, vertical Chinese title in the center, hand-drawn maple leaf at the bottom right",
    "size": "1536x1024",
    "response_format": "b64_json"
  }'
```

The default is `b64_json` (raw base64, no `data:` prefix). Pass `"response_format": "url"` for a signed link that expires in about 24 hours; download and re-host it promptly.

### Image editing (Python, multipart)

```python theme={null}
import base64
import os

from openai import OpenAI

client = OpenAI(
    api_key=os.environ["APIYI_API_KEY"],
    base_url="https://api.apiyi.com/v1",
    timeout=600,
)

with open("input.png", "rb") as f:
    result = client.images.edit(
        model="gpt-image-2.6-all",
        image=f,
        prompt="Replace the background with light gray, keep the subject and text",
        size="1536x1024",
    )

image_bytes = base64.b64decode(result.data[0].b64_json)
with open("edited.png", "wb") as f:
    f.write(image_bytes)
```

## Capabilities

| Capability | Support | Notes |
| - | - | - |
| Text to image | ✅ | `/v1/images/generations` |
| Image editing | ✅ | Single image / mask / multiple references via `/v1/images/edits` |
| `size` | ✅ | Native long edge 512–1536; 2K/4K super-resolution |
| Native ChatGPT quality (fingerprint) | ✅ ≤1536 | 2K/4K super-resolution does not promise native detail or fingerprint |
| `n` | ✅ 1–10 | Billed per image; 2K `n=2` returned two images |
| Output formats | ✅ PNG / JPEG / GIF / SVG | **WebP is not supported** and returns 400 |
| Transparent background | ✅ up to 2K | `background=transparent` + PNG; 4K is unstable |
| GIF | ✅ | `output_format=gif` is required; `size` is not honored |
| SVG | ✅ | 2K–8K, `viewBox` follows `size` |
| URL response | ✅ | `response_format=url` works in the Default group |
| `quality` | ⚠️ Accepted | `low` may return 2048x1153 at 2K; do not rely on it |
| mask | ⚠️ Accepted | Does not guarantee edits stay inside the mask; describe the target area |

## Sizes

### Native range (≤1536, ChatGPT web native)

| Aspect | Common `size` values |
| - | - |
| 1:1 | 512x512, 768x768, 896x896, 1000x1000, 1024x1024, 1536x1536 |
| 4:3 / 3:4 | 1024x768, 1536x1152, 768x1024, 1152x1536 |
| 3:2 / 2:3 | 1024x683, 1536x1024, 683x1024, 1024x1536 |
| 16:9 / 9:16 | 1280x720, 1536x864, 720x1280, 864x1536 |
| 3:1 / 1:3 | 1536x512, 512x1536 |
| Non-standard | Any integer with long edge 512–1536 and aspect ratio ≤3:1, returned exactly |

* No 16/64 alignment required. `1537`, `1600x900` and `1920x1080` are rejected on the native route.
* `size=auto` is decided upstream. We have seen 1312x1199, 1402x1122 and 1448x1086; **no fixed value is promised**.
* On the native route, the response `size` equals the actual output size.

### Super-resolution range (2K / 4K, large-canvas compatibility)

2K/4K uses super-resolution to enlarge the long edge to 2048/4096 for larger canvases. **Bigger does not mean more detailed** — it is not native pixels, and it is not promised to be sharper than the 1536 native tier. Measured results:

| Requested `size` | Actual output | Notes |
| - | - | - |
| 2048x2048 | 2048x2048 | 2K square |
| 2048x1152 | 2048x1152 | 16:9 |
| 2048x1536 | 2048x1536 | 4:3 |
| 1920x1080 | 1920x1080 | Exact |
| 1600x900 / 3000x2000 | Exact | — |
| 2000x2000 / 1792x1024 / 1024x1792 | Exact | — |
| 3840x2160 | 3840x2160 (usually) / 4096x2731 (occasionally) | 4K 16:9 |
| 4096x4096 / 3840x3840 / 3200x3200 | 2880x2880 | Square cap is 2880 |
| 1152x2048 | 1152x2048 (usually) / 1365x2048 (occasionally) | 9:16 may snap to 2:3 |
| 4096x1024 | **400** | Wider than 3:1; rejected |
| 3840x2160 + transparent | 4096-long-edge with varying height | **`size` is not honored**; do not promise |

> [!WARNING]
>
> 2K/4K responses **may omit the `size` field**, and aspect-ratio snapping can produce `1365x2048` or `4096x2731`. **Always read the actual image dimensions** instead of trusting the requested `size`.

### Choosing a size

* **Best ChatGPT-native feel / stable quality**: keep `size` at or below **1536**; around 1.5K is ideal. This is the most controllable tier, with the ChatGPT fingerprint.
* **2K large-canvas compatibility**: use `2048x2048`, `2048x1152`, `2048x1536`; common sizes are exact, but do not expect more detail than 1.5K.
* **4K landscape**: use `3840x2160`; it usually returns 3840x2160, occasionally 4096x2731 — verify actual pixels.
* **Large squares**: the cap is **2880**; `4096x4096` comes back as 2880x2880.
* **4:1 banners**: not supported; `4096x1024` returns 400.

## Formats

| Format | Request | Notes |
| - | - | - |
| PNG | Default | Transparent background supported; lossless |
| JPEG | `output_format=jpeg` | Smaller files; transparent background fails |
| GIF | `output_format=gif` | Frame parameters required; output size is decided upstream |
| SVG | `output_format=svg` | True vector; `viewBox` follows `size` |
| WebP | ❌ | Returns 400; do not send it |

* **Transparent background**: `background=transparent` + PNG. At 2K the result is RGBA with about 40% fully transparent pixels. **4K transparent output does not follow `size`; no dimensions are promised.**
* **URL**: `response_format=url` works in the `Default` group; no `Image2_OSS` group is needed. The link is a 24-hour signed URL.
* **No WebP**: the error is `output_format 'webp' is not supported; use png, jpeg, gif or svg`.

## GIF

```bash theme={null}
curl https://api.apiyi.com/v1/images/generations \
  -H "Authorization: Bearer $APIYI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2.6-all",
    "prompt": "A looping animation of a yellow doll frowning, puffing its cheeks and stomping, pure white background, seamless loop",
    "size": "2048x2048",
    "output_format": "gif",
    "frame_count": 8,
    "frame_duration_ms": 150
  }'
```

* **`output_format=gif` is mandatory**. If you only ask for a loop in the prompt and omit the format, the compatibility layer expects PNG and the request fails with 502 `image 1 is gif, png was asked for`.
* `frame_count` / `frame_duration_ms` are honored exactly: 8 frames / 150 ms, 4 frames / 300 ms and 6 frames / 120 ms all matched the request.
* **`size` does not determine the output size**: 1K results have included 384x512, 507x506 and 619x623; 2K returned 327x585; 4K returned 621x621. **Only frame count and duration are promised.**
* To get a fixed GIF size, resize or crop on the client after generation.

## SVG

```bash theme={null}
curl https://api.apiyi.com/v1/images/generations \
  -H "Authorization: Bearer $APIYI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2.6-all",
    "prompt": "A flat rocket icon, exactly three colors, no text",
    "size": "2048x2048",
    "output_format": "svg"
  }'
```

* **True vector**: the response is `<svg>` text, not a bitmap. 2048², 3840x2160, 4096², 6144² and 8192² all passed.
* **`viewBox` follows `size`**: 2048x2048 gives `viewBox="0 0 2048 2048"`; 3840x2160 gives `viewBox="0 0 3840 2160"`.
* **No `svg` object needed**: `output_format=svg` is enough. Official routes or some SDKs add `"svg": {"model": "..."}`; 2.6-all **accepts but ignores** that field — it does not fail and does not change the result, so do not depend on it.
* The output contains no `<script>` or embedded raster image.

## Image editing

* **Endpoint**: `POST /v1/images/edits`, `multipart/form-data`.
* **Single image / mask / multiple references** are accepted. A mask is treated as a reference; **edits are not guaranteed to stay inside the mask**, so describe what to change and what to keep.
* **An explicit `size` is exact**, including 2K/4K (2048x2048 and 3840x2160 both verified).
* **Without `size` or with `auto`**, the output is normalized to about **1.57 MP** while preserving the input aspect ratio; the original pixel size is not guaranteed.
* Two reference images work in practice. For more, compose them on the client or edit in steps.

## `n` and responses

* `n` supports **1–10** and is billed per image. At 2K, `n=2` returned two 2048x2048 images; `n=3` returned three images with `usage.image_count=3` and `output_image_tokens=8160` (3 × 2720). At \$0.025 per image that is \$0.075; the final charge is whatever the bill shows.
* The default is `b64_json`; `response_format=url` returns only `url`, never both.
* Common response fields: `created`, `data[]`, `usage`. **The `size` field may be missing for 2K/4K**; 1K usually echoes it.
* URLs are signed for 24 hours; regenerate after expiry.

## Timeouts and concurrency

* **Set the client timeout to 600 seconds**: 1K takes about 10–22 s, 2K 12–24 s, 4K 15–42 s, and tail latency can exceed 60 s. Loosen reverse proxies, serverless limits and queue consumers as well.
* **Concurrency**: at 1K, 12×2, 16×1 and 8×1536 all passed without 429s. 2K/4K has not been load-tested; start with 4–8 concurrent requests and watch tail latency.
* **Billing is synchronous**: the request is billed when sent; a client disconnect is not refunded and the result is not retained.

## Limits

* **2K/4K is super-resolution, for large-canvas compatibility.** It is not native pixels and is not promised to carry more detail than the 1536 native tier; for stable quality, stay at or below 1536.
* **2K/4K depends on a fallback route.** Requests first hit the native route and are switched to the super-resolution route when the size is out of range. If the fallback is unavailable, the API may return 400 `wide_fallback_required`; retry or stay at or below 1536.
* **GIF size is not guaranteed.** 1K, 2K and 4K can all return small images; only frame count and duration are promised.
* **WebP is not supported.** Only PNG / JPEG / GIF / SVG.
* **4:1 is not supported.** `4096x1024` returns 400; the maximum aspect ratio is 3:1.
* **4K transparent output is unstable.** We have seen several 4096-long-edge heights; do not promise 3840x2160. Keep transparent output at or below 2K.
* **Do not rely on `quality`.** `low` / `medium` / `high` are accepted, but `low` may return 2048x1153 at 2K while `medium` / `high` return 2048x2048; no same-seed quality difference has been verified.
* **Editing with `auto` rescales.** The output is about 1.57 MP, not the input size.
* **Content policy**: upstream moderation returns 400 `content_policy_violation`; revise the prompt and retry.

## Errors

| HTTP | `code` | Meaning | Action |
| - | - | - | - |
| 400 | `invalid_request_error` | Invalid parameter (size format, aspect ratio, format) | Fix the parameter |
| 400 | `wide_fallback_required` | 2K/4K fallback temporarily unavailable | Retry, or use a size at or below 1536 |
| 400 | `content_policy_violation` | Content moderation rejection | Revise the prompt |
| 401 | `invalid_api_key` | Wrong key or group | Check `APIYI_API_KEY` and the Default group |
| 429 | `rate_limit_exceeded` | Rate or quota limit | Back off and retry |
| 502 | `image 1 is gif, png was asked for` | GIF requested without `output_format=gif` | Send `output_format=gif` explicitly |

## Let an AI agent wire it up

**Copy this prompt into Codex / Claude Code / Cursor**

It first fetches the plain-text version of this page (append `.md` to any docs URL) and then writes code for your stack. The timeout, 2K/4K verification, GIF format and WebP limits are baked in.

9 requirements in total — use the button below to copy the full prompt.

Wire up or troubleshoot gpt-image-2.6-all text-to-image and image editing in this project.

Read the docs first: fetch [https://docs.apiyi.com/en/api-capabilities/gpt-image-2-all/gpt-image-2-6-all.md](https://docs.apiyi.com/en/api-capabilities/gpt-image-2-all/gpt-image-2-6-all.md) for the plain-text version of this page. For more detail, append `.md` to the text-to-image and image-edit pages as well.

Requirements:

1. Timeout: set the client timeout to 600 seconds. Image APIs are synchronous; there is no task ID. If the client disconnects, the result is lost but the request is still billed. Loosen reverse proxies, gateways and serverless limits too.

2. Rendering: the default is base64 (`b64_json`, no `data:` prefix). You can pass `response_format: "url"` for a 24-hour signed link. **Always pass `response_format` explicitly** rather than relying on the default. With URL mode, download and re-host immediately.

3. Sizes: long edge 512–1536 is native, with any integer dimensions and an aspect ratio up to 3:1. 2K/4K is super-resolution for large-canvas compatibility, not native pixels. **2K/4K responses may omit `size`, so read the actual image dimensions.** Ratios beyond 3:1 such as `4096x1024` return 400.

4. GIF: pass `output_format=gif` plus `frame_count` / `frame_duration_ms`. **`size` does not determine GIF dimensions**; do not use it to control pixels.

5. SVG: pass `output_format=svg`. `viewBox` follows `size`; no extra `svg` object is needed. The result is a real vector, not a bitmap.

6. Transparent background: `background=transparent` + PNG, preferably at or below 2K. 4K transparent dimensions are unstable; do not promise 3840x2160.

7. `n` supports 1–10 and is billed per image. `quality` is accepted but do not rely on it; `low` may return 2048x1153 at 2K.

8. Read the key from `APIYI_API_KEY` and use [https://api.apiyi.com/v1](https://api.apiyi.com/v1) as the base URL. Never hard-code or commit the key.

9. After wiring it up, run one text-to-image and one edit; report the actual dimensions, latency and cost of both calls.

> [accordion] What this prompt prevents
>
> | Requirement | Pitfall it avoids |
> | - | - |
> | 600-second timeout | Common HTTP clients default to 30–60 s and cut off a request that is still generating; disconnected requests are still billed |
> | Explicit `response_format` | The default has changed before; without it you must handle both `url` and `b64_json` |
> | Read actual dimensions | 2K/4K may omit `size`; 9:16 can snap to 1365x2048 and 4K can return 4096x2731 |
> | GIF format | Omitting `output_format=gif` returns a 502 with a hard-to-read message |
> | Transparent at or below 2K | 4K transparent output drifts to a 4096 long edge with unpredictable height |
> | No WebP | Only PNG / JPEG / GIF / SVG are supported; WebP returns 400 |

## FAQ

### Is 2K/4K native resolution?

No. 2K/4K uses super-resolution to solve size / large-canvas compatibility, not native detail. Native quality is at 1536 and below, with the ChatGPT fingerprint. For stable quality, stay around 1.5K; use 2048–3840 for posters and print.

### Why is `size` missing from a 2K/4K response?

2K/4K is delivered by the super-resolution route, which does not always echo `size`; the 1K route usually does. Read the actual image width and height (for example, the PNG IHDR) instead of trusting the requested `size`.

### Can it produce a 4K transparent image?

Not reliably. At 2K, transparent output is stable (RGBA, about 40% fully transparent pixels). At 4K we have seen 4096x4096, 4096x3552 and 4096x2731 — do not hard-code 3840x2160. Keep transparent output at or below 2K.

### Can I set the GIF dimensions?

No. `size` does not affect GIF output: 1K has produced 384x512, 507x506 and 619x623; 2K returned 327x585; 4K returned 621x621. Only frame count and duration are promised. Resize or crop on the client if you need fixed pixels.

### Is WebP supported?

No. Only PNG / JPEG / GIF / SVG; `output_format=webp` returns 400.

### Does `quality` matter?

`low` / `medium` / `high` are accepted, but do not rely on them: `low` may return 2048x1153 at 2K, while `medium` / `high` return 2048x2048. No same-seed visual difference has been verified.

### Why does `4096x1024` fail?

The maximum aspect ratio is 3:1; `4096x1024` is 4:1 and is rejected during parameter validation. Use a ratio within 3:1 (for example, up to `4096x1536`) or stitch two images.

## Related

* [Text to image API](https://docs.apiyi.com/en/api-capabilities/gpt-image-2-all/text-to-image.md)
* [Image editing API](https://docs.apiyi.com/en/api-capabilities/gpt-image-2-all/image-edit.md)
* [GPT-Image-2.5-All overview](https://docs.apiyi.com/en/api-capabilities/gpt-image-2-all/overview.md)
* [Official vs reverse comparison](https://docs.apiyi.com/en/api-capabilities/gpt-image-2/vs-gpt-image-2-all.md)
* [Image API best practices](https://docs.apiyi.com/en/api-capabilities/image-api-best-practices.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.