# GPT Image 2 (High) API

> GPT Image 2 — fast, high-fidelity AI image generation & editing.

- **Provider**: OpenAI
- **Model id**: `gpt-image-2-image-to-image`
- **Modality**: image
- **Price**: 2.5–7.2 credits

## Overview

GPT Image 2 (High) is called in two steps: create a generation task, then poll the task until the result is ready.

## Authentication

All requests require a Bearer Token in the request header:

```
Authorization: Bearer YOUR_API_KEY
```

## Create Task

`POST https://you.bot/api/v1/generate`

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| modelId | string | Yes | Model id: `gpt-image-2-image-to-image` |
| input | object | Yes | Input parameters object (see below) |
| callbackUrl | string | No | https URL we POST the finished task to. Signed with `X-Webhook-Signature` once you create a webhook signing key in Dashboard → Settings |

### input object parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| prompt | string | Yes | Used to describe the generated images. Max 20000 characters. (example: Create a 1K editorial cover treatment from the uploaded image. Keep the subject's face, pose and identity exactly as uploaded and restyle only the surroundings… — full value in the request example) |
| input_urls | string[] | No | Image for reference (image URL) |
| resolution | string | No | Image resolution (options: 1K \| 2K \| 4K) (default: 1K) |
| aspect_ratio | string | Conditional | when `resolution` is `1K`: For 2K and 4K resolution, the following aspect ratios are not supported: 5:4, 4:5, 3:1, 1:3, and 9:21. (options: auto \| 1:1 \| 3:2 \| 2:3 \| 4:3 \| 3:4 \| 16:9 \| 9:16 \| 2:1 \| 1:2 \| 3:1 \| 1:3 \| 21:9 \| 9:21 \| 5:4 \| 4:5) · when `resolution` is `2K`/`4K`: For 2K and 4K resolution, the following aspect ratios are not supported: 5:4, 4:5, 3:1, 1:3, and 9:21. (options: auto \| 1:1 \| 3:2 \| 2:3 \| 4:3 \| 3:4 \| 16:9 \| 9:16 \| 2:1 \| 1:2 \| 21:9) |

### Request example

```json
{
  "modelId": "gpt-image-2-image-to-image",
  "input": {
    "prompt": "Create a 1K editorial cover treatment from the uploaded image. Keep the subject's face, pose and identity exactly as uploaded and restyle only the surroundings into a blue-hour rooftop at dusk, city lights soft behind. One hard key light from camera left, deep shadows, cinematic contrast. Add the words \"AFTER HOURS\" in a small refined sans-serif at the lower left. Ultra-realistic photography, visible fabric texture. No logos, no brand references, no watermark, no extra people.",
    "input_urls": [
      "https://you.bot/examples/grok-imagine-text-to-image.jpg"
    ],
    "resolution": "1K",
    "aspect_ratio": "auto"
  }
}
```

### Response example

```json
{
  "taskId": "281e5b0…f39b9",
  "creditsCharged": 2.5
}
```

## Query Task

`GET https://you.bot/api/v1/task/{taskId}?model=gpt-image-2-image-to-image`

When `state` is `success`, the output is in `resultUrls`: `{ "state": "success", "resultUrls": [ ... ] }`. (Text models return inline in the create response.)

## Error Codes

| Code | Description |
|------|-------------|
| 200 | Request successful |
| 400 | Invalid request parameters |
| 401 | Authentication failed — check API Key |
| 402 | Insufficient account balance |
| 403 | IP not allowed for this key, or the key is restricted to other models |
| 404 | Task not found, or it has expired |
| 409 | Duplicate request — an identical submit arrived moments ago. Nothing was charged; retry is safe |
| 413 | Payload too large — see the character and file-size limits for this model |
| 429 | Rate limit exceeded — retry after the Retry-After header |
| 500 | Internal server error |
| 504 | Upstream timed out — nothing was delivered; retry is safe |
