# GPT-4o Image API

> High-fidelity image generation with strong text rendering.

- **Provider**: OpenAI
- **Model id**: `gpt-4o-image`
- **Modality**: image
- **Price**: 3.71 credits

## Overview

GPT-4o Image 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-4o-image` |
| input | object | Yes | Input parameters object (see below) |
| callbackUrl | string | No | https URL to receive a signed webhook on completion |

### input object parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| imageUrl | string | No | Image URL |
| prompt | string | Yes | Text value (default: A watercolor map of a fictional seaside town, hand-lettered street names, tiny sailboats in the bay, pastel palette.) |
| size | string | Yes | Options: 3:2 | 2:3 | 1:1 (default: 3:2) |
| isEnhance | boolean | No | In most cases, enabling this is unnecessary. However, for specific scenarios like generating 3D images, enabling it can produce a more refined effect. Use discretion. (true/false) (default: false) |

### Request example

```json
{
  "modelId": "gpt-4o-image",
  "input": {
    "imageUrl": "https://example.com/input.jpg",
    "prompt": "A photorealistic portrait of a red fox in a snowy forest, soft morning light, shallow depth of field, 85mm.",
    "size": "3:2",
    "isEnhance": false
  }
}
```

### Response example

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

## Query Task

`GET https://you.bot/api/v1/task/{taskId}?model=gpt-4o-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 |
| 422 | Parameter validation failed |
| 429 | Request rate limit exceeded |
| 500 | Internal server error |
