# GPT Image 2 (High) API

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

- **Provider**: OpenAI
- **Model id**: `gpt-image-2-text-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-text-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 high-end Japanese avant-garde couture fashion editorial photograph, 4:5 aspect ratio, featuring the woman from the reference image. Keep her face,… — 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-text-to-image",
  "input": {
    "prompt": "Create a high-end Japanese avant-garde couture fashion editorial photograph, 4:5 aspect ratio, featuring the woman from the reference image.\n\nKeep her face, identity, hairstyle, and overall appearance consistent with the reference image. Redesign only the outfit into a Japanese avant-garde couture style, inspired by traditional Japanese silhouettes, kimono construction, origami folds, layered fabric, asymmetrical forms, and contemporary Japanese architecture.\n\nThe outfit is highly sculptural and architectural, featuring dramatic geometric structures, exaggerated volumes, sharp folds, layered panels, and an innovative futuristic silhouette. Elegant yet unconventional, like wearable architecture. Do not use or reference any real fashion brands or copyrighted designs.\n\nPure black studio background. Add very subtle, translucent atmospheric smoke, softly drifting around the lower body and edges of the silhouette. The smoke should be thin, elegant, slightly hazy, and partially illuminated by the light, never obscuring the face or garment.\n\nUse one single hard key light only, creating dramatic highlights, deep shadows, and strong three-dimensional contours across the sculptural garment. High contrast, cinematic shadows, sophisticated Japanese noir atmosphere.\n\nAdd minimal editorial typography:\n“TOKYO NOIR”\nwith small secondary text:\n“BEYOND FORM”\n\nTypography should be elegant, minimalist, refined, and positioned like a luxury fashion magazine cover. No excessive text.\n\nUltra-realistic fashion photography, premium couture craftsmanship, detailed fabric texture, sophisticated composition, cinematic contrast, museum-like visual impact, luxury high-fashion magazine cover quality.\n\nNo logos, no real brand references, no watermark, no additional 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-text-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 |
