# Image generation and edits

**Last updated:** 2026-11-15T13:17:19-03:00 (UTC-3)

The gateway serves the OpenAI Images API on two routes: `/v1/images/generations` creates images from a prompt, and `/v1/images/edits` creates images from a prompt and input images. Both pass the request through to the provider with only the model replaced, and both are valued like a generation of the same model.

| Route | Capability | Key scope | Flag |
| --- | --- | --- | --- |
| `/v1/images/generations` | `images` | `route:images` | `image_generation` |
| `/v1/images/edits` | `image_edits` | `route:image_edits` | `image_generation` |

One operational switch, `image_generation` (off by default), turns on both routes. The capability on the alias and the scope on the key are separate: a key with `route:images` alone cannot edit, and an alias without `image_edits` answers `422 capability_unsupported` on the edit route.

## gpt-image-2.6-flare

`gpt-image-2.6-flare` (OpenAI, 2026-11-04) takes text and image input and returns images. OpenAI documents it on these two routes only: Chat Completions, Responses, Realtime and Batch do not serve it. Its published prices, per million tokens, are text input US$ 5, cached text input US$ 1.25, image input US$ 8, cached image input US$ 2 and image output US$ 30; there is no per-image price.

```yaml
features:
  image_generation: true
  # Optional: value each answer per token (see "Pricing" below).
  usage_valuation: true
  automatic_price_catalog: true
  external_model_catalog: true
  price_source_cost_map: true
  image_token_pricing: true
providers:
  - {id: openai, preset: openai}
models:
  - id: flare
    capabilities: [images, image_edits]
    targets: [{provider: openai, model: gpt-image-2.6-flare}]
keys:
  - id: design-app
    scopes: [route:images, route:image_edits]
    allowed_models: [flare]
```

The request options pass through as the client sends them; the gateway does not rewrite them. What OpenAI documents for this model family: `quality` (`low`, `medium`, `high`, `auto`; `xhigh` and `max` on the 2.5 models), `size` (`1024x1024`, `1536x1024`, `1024x1536`, `auto`, or a custom `WIDTHxHEIGHT` in multiples of 16), `background` (`transparent` needs `png` or `webp`), `output_format` (`png`, `jpeg`, `webp`, `gif`, `svg`), `output_compression` (0-100, `jpeg` and `webp`), `complexity` (`low`, `medium`, `high`), `n` (1-10), `stream` and `partial_images` (0-3). The provider answers an option the model does not accept with its own error, which the client receives as it came.

## Generate

```bash
curl http://localhost:8080/v1/images/generations \
  -H "Authorization: Bearer $GATEWAY_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"model": "flare", "prompt": "A lighthouse at dusk", "size": "1024x1024", "quality": "low"}'
```

## Edit

The edit route takes either of the two encodings OpenAI documents.

JSON, with 1 to 16 images as `image_url` references (a `data:` URL carried inline, or an `https` URL the provider fetches) and an optional `mask` or `markup` in the same form:

```bash
curl http://localhost:8080/v1/images/edits \
  -H "Authorization: Bearer $GATEWAY_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"model": "flare", "prompt": "Add a red kite to the sky",
       "images": [{"image_url": "data:image/png;base64,<base64>"}],
       "size": "1024x1024", "quality": "low"}'
```

Multipart, with the image files under `image` (or `image[]`, repeated up to 16 times) and an optional `mask` or `markup` file:

```bash
curl http://localhost:8080/v1/images/edits \
  -H "Authorization: Bearer $GATEWAY_API_KEY" \
  -F model=flare -F prompt='Add a red kite to the sky' \
  -F 'image[]=@photo.png' -F 'mask=@mask.png'
```

The gateway replaces the `model` field and forwards every other byte, file parts included.

What the gateway refuses before any provider call:

| Request | Answer |
| --- | --- |
| A `file_id` key anywhere in a JSON body, in any case, or a multipart field whose name contains `file_id` | `422 file_id_unsupported`. A file ID names a file in the provider account that every team shares; the gateway owns no such file for the caller. Send the image itself. |
| No image, more than 16, an `image_url` that is neither `data:` nor `https:`, or a JSON `image` field | `400 invalid_image_edit` |
| `markup` together with `mask` (OpenAI documents them as exclusive) | `400 invalid_image_edit` |
| Multipart with a file under another field name, `image`/`mask`/`markup` sent as text instead of a file, a text field named like them (`images`, `mask_url`...), the same text field twice, a text field over 128 KiB, more than 64 parts, or a part header the provider could read under another name (two `Content-Disposition` headers, an RFC 2231 `name*`/`filename*` parameter, a backslash escape, a `Content-Transfer-Encoding` header) | `400 invalid_image_edit` |
| A JSON `images`, `mask` or `markup` key in another case (`Mask`, `IMAGES`) | `400 invalid_image_edit` |
| A JSON body that repeats a member name at any depth (refused whatever the policies) | `400 invalid_request` |

The body limit is the route's (8 MiB by default); `models[].max_request_body_mib` raises it for one alias, up to 64 MiB. See [request body limits](/docs/operate/http-input-limits/#request-body-limits).

## Pricing

With `image_token_pricing` on, an edit is valued exactly like a generation (see [usage valuation](/docs/features/usage-valuation/#gpt-image-tokens)): the community cost map's row for the model gives the per-token prices, and the `usage` the answer reports after its images gives the counts. For `gpt-image-2.6-flare` the row carries the prices above: an edit that reports 50 text and 1,000 image input tokens and 2,000 image output tokens costs `0.00025 + 0.008 + 0.06 = 0.06825` USD.

An answer stays `unknown` when the profile cannot prove its cost: a streamed request (`stream: true`, also as a multipart field), a service tier other than the default, an SVG answer (its `svg_usage` is billed apart, at the authoring model's prices), and every case listed in [usage valuation](/docs/features/usage-valuation/#gpt-image-tokens). The usage reports no cached count, so cached prices are never applied: an estimate is at or above the bill.

## Streams and cancellation

A streamed edit relays the provider's `image_edit.partial_image` and `image_edit.completed` events unchanged. A client that disconnects cancels the provider request. Retries and fallback follow the alias's settings, as for a generation: a request is sent again only after a transport failure before any answer, or after a `429`/`5xx` answer; an answer the provider accepted is never sent to a second target.

## Not covered

- Budgets and token limits need `quota_image_tokens` and an approved image token rate; see [GPT Image budgets](/docs/features/quota-protocols/#gpt-image-budgets). Streams, partial images, SVG and GIF are refused under them.
- No console screen sends edits yet; the endpoint explorer shows the JSON example.
- The Responses API image tool is a Responses feature, not these routes; `gpt-image-2.6-flare` is not served there.
