> For the complete documentation index, see [llms.txt](https://bountyv.gitbook.io/vdocs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bountyv.gitbook.io/vdocs/frontier-passthrough/frontier-chatgpt-image.md).

# ChatGPT Image

OpenAI's `gpt-image-2` on OpenAI's own parameters. Synchronous.

```
POST /api/v1/frontier/chatgpt-image
```

Send no references and the call routes to OpenAI's `images/generations`; send one or more and it routes to `images/edits`, which composes them into a single output. Same model and price as `engine=gptimage` on [Text-to-Image](/vdocs/image-api/images-txt2img.md).

## Authentication

```
Authorization: Bearer sk_live_...
```

## Request

**Content-Type:** `application/json`

| Field    | Type      | Required | Default       | Description                                                                         |
| -------- | --------- | -------- | ------------- | ----------------------------------------------------------------------------------- |
| `prompt` | string    | ✅        | —             | What to generate, or the edit instruction when references are supplied              |
| `images` | string\[] | —        | —             | Up to 16 references, in prompt order. `data:` URL, public https URL, or bare base64 |
| `image`  | string    | —        | —             | Single reference, same formats                                                      |
| `size`   | string    | —        | `"1024x1024"` | `"1024x1024"` \| `"1536x1024"` \| `"1024x1536"` \| `"auto"`                         |

`gpt-image-2` has no free-form width/height — those four buckets are the entire set it accepts. `"auto"` lets the model choose.

## Response

```json
{
  "image": "https://.../generations/<id>.png?token=...",
  "generation_id": "gJ8nP3kQ2m",
  "model": "gpt-image-2",
  "mode": "edit",
  "reference_images": 3,
  "max_reference_images": 16,
  "size": "1536x1024",
  "charged_cents": 39,
  "balance_cents": 4761,
  "elapsed_ms": 11402
}
```

| Field           | Type           | Description                                                                          |
| --------------- | -------------- | ------------------------------------------------------------------------------------ |
| `mode`          | string         | `"generation"` (no references) or `"edit"` (one or more) — which OpenAI endpoint ran |
| `image`         | string         | Signed URL when the generation persists, otherwise an inline `data:` URL             |
| `generation_id` | string \| null | Generation record ID                                                                 |
| `charged_cents` | integer        | Amount deducted                                                                      |

## Example

Compose three references into one scene:

```bash
curl -X POST https://substance-api.com/api/v1/frontier/chatgpt-image \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Put the product from image 1 on the desk in image 2, lit like image 3",
    "images": [
      "https://example.com/product.png",
      "https://example.com/desk.jpg",
      "https://example.com/lighting-ref.jpg"
    ],
    "size": "1536x1024"
  }'
```

## Errors

| Status | Meaning                                                                                                                              |
| ------ | ------------------------------------------------------------------------------------------------------------------------------------ |
| `400`  | Missing `prompt`, unsupported `size` (the four supported values are returned), an unreadable image value, or more than 16 references |
| `402`  | Balance below the call price                                                                                                         |
| `403`  | Your account doesn't have the `image` product enabled                                                                                |
| `502`  | OpenAI failed or refused the prompt. Moderation blocks surface here — the charge is refunded                                         |
| `503`  | The pipeline is disabled                                                                                                             |

## Pricing

$0.39 per image. Bills on `images.txt2img.gptimage`. See [Credits & pricing](/vdocs/account/credits.md).

SFW only — OpenAI moderates server-side and rejects adult content outright.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://bountyv.gitbook.io/vdocs/frontier-passthrough/frontier-chatgpt-image.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
