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

# GPT-Image-2.6 Ext Image Generation

> Generate images at a fixed per-image price with gpt-image-2.6-ext. Select Flare or Sunburst with version; use references, SVG, or GIF output.

> [!NOTE]
>
> Use `gpt-image-2.6-ext` and select `flare` or `sunburst` with `version`. Billing is per image. Supported: **`resolution` `1k` / `2k` / `4k`** with **`n: 1`**, all quality levels, and PNG / JPEG / WebP / SVG / GIF output.

This is the Ext API. Its model name and parameter rules differ from the [token-billed GPT-Image-2.6 models](https://docs.apimart.ai/en/api-reference/images/gpt-image-2.6/generation.md).

```bash cURL theme={null}
curl --request POST \
  --url https://api.apimart.ai/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "gpt-image-2.6-ext",
  "version": "flare",
  "prompt": "An orange cat resting on a sunny windowsill, a city after the rain, warm cinematic lighting",
  "size": "16:9",
  "resolution": "1k",
  "quality": "high",
  "n": 1
}'
```

```python Python theme={null}
import time
import requests

base_url = "https://api.apimart.ai"
headers = {"Authorization": "Bearer <token>"}
payload = {
    "model": "gpt-image-2.6-ext",
    "version": "flare",
    "prompt": "An orange cat resting on a sunny windowsill, a city after the rain, warm cinematic lighting",
    "size": "16:9",
    "resolution": "1k",
    "quality": "high",
    "n": 1
}
response = requests.post(
    f"{base_url}/v1/images/generations",
    headers=headers, json=payload, timeout=30,
)
response.raise_for_status()
task_id = response.json()["data"][0]["task_id"]
print(task_id)

deadline = time.monotonic() + 300
while time.monotonic() < deadline:
    response = requests.get(
        f"{base_url}/v1/tasks/{task_id}", headers=headers, timeout=30,
    )
    response.raise_for_status()
    body = response.json()
    task = body.get("data", body)
    if task["status"] == "completed":
        print(task["result"]["images"][0]["url"])
        break
    if task["status"] == "failed":
        raise RuntimeError(task["error"]["message"])
    time.sleep(4)
else:
    raise TimeoutError(f"Continue polling task {task_id}")
```

```javascript JavaScript theme={null}
const baseUrl = "https://api.apimart.ai";
const headers = {
  Authorization: "Bearer <token>",
  "Content-Type": "application/json",
};
const response = await fetch(`${baseUrl}/v1/images/generations`, {
  method: "POST",
  headers,
  body: JSON.stringify({
    "model": "gpt-image-2.6-ext",
    "version": "flare",
    "prompt": "An orange cat resting on a sunny windowsill, a city after the rain, warm cinematic lighting",
    "size": "16:9",
    "resolution": "1k",
    "quality": "high",
    "n": 1
  }),
});
if (!response.ok) throw new Error(await response.text());
const taskId = (await response.json()).data[0].task_id;
console.log(taskId);

async function waitForTask(taskId) {
  const deadline = Date.now() + 300_000;
  while (Date.now() < deadline) {
    const response = await fetch(`${baseUrl}/v1/tasks/${taskId}`, { headers });
    if (!response.ok) throw new Error(await response.text());
    const body = await response.json();
    const task = body.data ?? body;
    if (task.status === "completed") return task.result.images[0].url;
    if (task.status === "failed") throw new Error(task.error.message);
    await new Promise(resolve => setTimeout(resolve, 4000));
  }
  throw new Error(`Continue polling task ${taskId}`);
}
console.log(await waitForTask(taskId));
```

```json 200 theme={null}
{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01EXAMPLE"
    }
  ]
}
```

```json 400 theme={null}
{
  "error": {
    "message": "quality \"ultra\" is not supported (supported: auto / low / medium / high / xhigh / max)",
    "type": "invalid_request_error",
    "param": "",
    "code": "invalid_request_error"
  }
}
```

## Authentication

**Authorization** `string` *required*

Authenticate with a platform API Key using Bearer Token. Get a key from the [API Key page](https://apimart.ai/keys). Submit requests with `Content-Type: application/json`.

## Version selection

| Version | Use case |
| - | - |
| `flare` | Default; prioritizes speed for everyday images, batches, and rapid iteration. |
| `sunburst` | Prioritizes composition and editing precision for finished assets, text in images, and detailed edits. |

## Request parameters

Enum values are case-insensitive and trimmed. Examples use lowercase.

**model** `string` *required*

Must be `gpt-image-2.6-ext`.

**prompt** `string` *required*

Required, non-empty generation or editing instructions. For multiple references, identify the first or second image and describe what to change and preserve.

**version** `string` (default: flare)

`flare` / `sunburst`; defaults to `flare`. Other values return HTTP 400. Prices may differ between versions.

**resolution** `string` (default: 1k)

`1k` / `2k` / `4k` (uppercase `1K` / `2K` / `4K` also accepted). Combined with the `size` ratio to determine output pixels; see the "Aspect ratios and dimensions" table below. The per-image price varies by tier; other values such as `hd` / `8k` return HTTP 400.

**size** `string` (default: auto)

Accepts `auto` or the 10 ratios below, not pixels such as `1024x1024`. For text-to-image, `auto` gives 1:1. For editing, it matches the closest supported ratio to the first reference whose dimensions can be read. For GIF, omit this field or use `auto`.

**aspect\_ratio** `string`

Alias for `size`; use either one. If both are provided, they must match or submission returns HTTP 400. For GIF, also omit it or use `auto`.

**n** `integer` (default: 1)

Currently use integer `1`.

**quality** `string`

`auto` / `low` / `medium` / `high` / `xhigh` / `max`. Omitted values are not forwarded; the upstream model chooses automatically. `auto` is not fixed to `low`. Quality does not change the per-image price; higher levels usually take longer. Other values return HTTP 400.

**output\_format** `string` (default: png)

`png` / `jpeg` / `webp` / `svg` / `gif`; `jpg` aliases `jpeg`. SVG and GIF support text-to-image only. Other formats return HTTP 400.

> [!WARNING]
>
> SVG output is not supported yet.

**complexity** `string`

`low` / `medium` / `high`; omitted values are not forwarded and the upstream model decides. Controls scene complexity: `low` suits simple icons and flat illustrations; `high` suits richer detail. Does not change the per-image price.

**image\_urls** `string[]`

Up to 16 images, each at most 20 MB; PNG / JPEG / WebP / GIF / BMP. Accepts public HTTP(S) URLs or image Base64 Data URLs such as `data:image/png;base64,...`. Providing references enables editing. SVG and GIF cannot include references.

> [!WARNING]
>
> When `resolution` is `2k` / `4k`, reference images cannot be GIF / BMP.

Accepted field aliases: `image_url`, `image`, `images`, `input_image`, `input_images`. Prefer `image_urls`. URLs must be publicly accessible without login.

## Aspect ratios and dimensions

| Ratio | `1k` | `2k` | `4k` |
| - | - | - | - |
| `1:1` | 1024×1024 | 2048×2048 | 2880×2880 |
| `3:2` | 1536×1024 | 2048×1360 | 3520×2336 |
| `2:3` | 1024×1536 | 1360×2048 | 2336×3520 |
| `4:3` | 1024×768 | 2048×1536 | 3312×2480 |
| `3:4` | 768×1024 | 1536×2048 | 2480×3312 |
| `5:4` | 1280×1024 | 2560×2048 | 3216×2576 |
| `4:5` | 1024×1280 | 2048×2560 | 2576×3216 |
| `16:9` | 1536×864 | 2048×1152 | 3840×2160 |
| `9:16` | 864×1536 | 1152×2048 | 2160×3840 |
| `21:9` | 2016×864 | 2688×1152 | 3840×1648 |

With `auto`, text-to-image uses 1:1: 1024×1024 at `1k`, 2048×2048 at `2k`, 2880×2880 at `4k`. Editing selects the closest ratio in this table; it does not guarantee the original pixel dimensions.

## Reference-image editing example

Editing also uses `POST /v1/images/generations`. Replace example URLs with accessible image files.

```json theme={null}
{
  "model": "gpt-image-2.6-ext",
  "version": "sunburst",
  "prompt": "Place the product from the first image into the scene in the second image. Preserve the logo and packaging text, and match the lighting.",
  "image_urls": [
    "https://example.com/product.png",
    "https://example.com/scene.jpg"
  ],
  "size": "auto",
  "quality": "high",
  "n": 1
}
```

## SVG output

Set `output_format: "svg"`. Text-to-image only, with `n=1`. `size` accepts aspect ratios; `complexity: "low"` suits simple vector artwork.

**svg** `object`

Optional SVG authoring-model configuration, for SVG output only. The entire object may be omitted. The text model that authors the SVG incurs no additional charge.

**svg**

**model** `string` *required*

Required if the `svg` object is provided. For example, `gpt-4.1-mini`.

**reasoning** `object`

**reasoning**

**effort** `string`

Optional: `none` / `minimal` / `low` / `medium` / `high` / `xhigh` / `max`. Supported values depend on the text model; omit if unsure.

```json theme={null}
{
  "model": "gpt-image-2.6-ext",
  "prompt": "A minimalist rocket icon in a single line color, flat vector style, no text",
  "size": "1:1",
  "output_format": "svg",
  "complexity": "low",
  "svg": {
    "model": "gpt-4.1-mini"
  },
  "n": 1
}
```

## Animated GIF output

Set `output_format: "gif"`. Text-to-image only. Omit `size` / `aspect_ratio` or use `auto`; ratios and pixel dimensions return HTTP 400. Describe the motion and loop in the prompt.

```json theme={null}
{
  "model": "gpt-image-2.6-ext",
  "prompt": "A cartoon puppy raises one paw to wave, then returns to the starting pose. White background, fixed camera, seamless loop.",
  "output_format": "gif",
  "quality": "medium",
  "n": 1
}
```

## Unsupported and ignored parameters

| Parameter | Behavior |
| - | - |
| `width` / `height` / `markup` / `markup_url` | Returns HTTP 400 at submission. Use aspect-ratio names for size; markup-guided editing is not supported. |
| `background` / `moderation` / `output_compression` / `seed` / `negative_prompt` / `style` | Accepted but has no effect. |
| `response_format` | Does not change delivery: results are file URLs, not Base64 images. |

## Submission and task results

Successful submission returns HTTP 200. Read `data[0].task_id`, then poll the [task status endpoint](https://docs.apimart.ai/en/api-reference/tasks/status.md) every 3–5 seconds until `completed` or `failed`. If the client times out, keep querying that task instead of resubmitting generation.

```bash theme={null}
curl --request GET \
  --url https://api.apimart.ai/v1/tasks/task_01EXAMPLE \
  --header 'Authorization: Bearer <token>'
```

The example below shows the task object. If the response uses a `{code, data}` wrapper, read `data` first. The Python / JavaScript examples handle either shape.

```json theme={null}
{
  "id": "task_01EXAMPLE",
  "status": "completed",
  "progress": 100,
  "result": {
    "images": [
      {
        "url": [
          "https://upload.apimart.ai/images/example.png"
        ],
        "expires_at": 1793923252
      }
    ]
  }
}
```

`result.images[0].url` is an array; its first link is `result.images[0].url[0]`. Download before `expires_at`; the recommended validity period is 24 hours after completion. `cost` / `credits_cost` report final charges.

| Status | Action |
| - | - |
| `pending` / `processing` | Continue polling. |
| `completed` | Read and save the output files. |
| `failed` | Inspect `error.message`. Failures are fully refunded and `cost` is 0. Correct the cause before submitting again. |

Batch queries use `POST /v1/tasks/batch` with `{"task_ids":["task_xxx","task_yyy"]}`.

## Billing

The per-image price depends only on `version` × `resolution`. Quality, format (including SVG / GIF), complexity, ratio, reference count, and `svg.model` do not affect it. Currently use `n=1`; failed tasks are fully refunded. Check current rates on the [APIMart pricing page](https://apimart.ai/pricing) or `/api/pricing`.

## Error handling

| Stage / status | Cause and action |
| - | - |
| HTTP 400 | Invalid parameters; rejected before task creation with no charge. Check enums, ratios, reference limits, and whether SVG / GIF fields match the output format. |
| HTTP 401 | Missing or invalid API Key; check Authorization. |
| HTTP 403 | `model_price_not_configured`: no price is configured for this `version` × `resolution`. Contact support or choose another tier. |
| HTTP 429 | Too many requests; reduce concurrency before retrying. |
| `status: "failed"` | Execution failed, for example with still-image / GIF `n=2`–`4`, inaccessible references, or a content-safety rejection. Read `error.message` and adjust the request. Charges are fully refunded. |


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