# AI图像 API Documentation

> AI图像生成接口

## Overview

This document describes how to call the **AI图像** API.

- **Model / path slug**: `image/create`
- **Task type**: `sync` (`sync` = synchronous, `async` = create task then poll / callback)
- **HTML docs**: `/doc/13`

## Authentication

All API requests require your platform API key as the query parameter `key`:

```
?key=YOUR_API_KEY
```

Get API Key:
1. Sign in to the console
2. Open [API Key Management](/user/key) and create or copy your key
3. Append `key=YOUR_API_KEY` to the request URL (or pass it in form/JSON when the endpoint accepts it)

---

## API Information

- **URL**: `POST https://apis.xiaobao.ink/api/image/create`
- **Content-Type**: `application/json` (request body commonly `application/json` or `application/x-www-form-urlencoded` for POST)
- **HTTP Method**: `POST`

### Request Parameters

| Parameter | Required | Description |
|-----------|----------|-------------|
| `model` | Yes | 支持模型: nano-banana-fast nano-banana nano-banana-pro nano-banana-pro-vt nano-banana-pro-cl nano-banana-pro-vip nano-banana-pro-4k-vip |
| `prompt` | Yes |  |
| `aspectRatio` | Yes | 输出图像比例,支持的比例:auto 1:1 16:9 9:16 4:3 3:4 3:2 2:3 5:4 4:5 21:9 默认 auto |
| `imageSize` | Yes | 输出图像大小,支持的大小: 1K 2K 4K 默认 1K - 注意：分辨率越高，生成时间越长 |
| `urls` | Yes | 参考图URL 数组 |
| `notify` | Yes | 回调地址 |

> **Note**: `key` (API key) is required for authenticated calls even if omitted from the parameter list above.

### Request Example

```
https://apis.xiaobao.ink/api/image/create?key=你的密钥
```

## Details

## 请求HEADER：

| 名称 | 值 |
| --- | --- |
| Content-Type | application/json |

## 请求参数说明：

| 名称 | 必填 | 类型 | 示例值 | 说明 |
| --- | --- | --- | --- | --- |
| model | 是 | string | nano-banana-pro | 支持模型: nano-banana nano-banana-pro nano-banana-2 |
| prompt | 是 | string | 一只可爱的猫咪在草地上玩耍 | 提示词 |
| aspectRatio | 否 | string | auto | 输出图像比例,支持的比例: auto 1:1 16:9 9:16 4:3 3:4 3:2 2:3 5:4 4:5 21:9 默认 auto |
| imageSize | 否 | string | 1K | 支持模型： nano-banana-pro nano-banana-pro-vt nano-banana-pro-cl nano-banana-pro-vip(只支持1k，2k) nano-banana-pro-4k-vip(只支持4k) - 输出图像大小,支持的大小: 1K 2K 4K 默认 1K - 注意：分辨率越高，生成时间越长 |
| urls | 否 | array | ["https://example.com/example.png"] | 参考图URL |
| notify | 是 | string | https://xx.x.ocm | 回调地址 |

## 返回参数说明：

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| code | int | 状态码 |
| msg | string | 状态信息 |
| data | array | 请求结果数据集 |
| - task_id | string | 任务ID |
| exec_time | float | 执行耗时 |
| user_ip | string | 客户端IP |

## Response Example

```json
{
    "code": 0,
    "msg": "success",
    "data": {
        "task_id": "i44bcf50-f2d0-4c26-a467-26f2014a771b"
    }
}
```

## Error Codes

| Status / code | Description |
|---------------|-------------|
| 200 / success | Request successful |
| 400 | Invalid request parameters |
| 401 | Authentication failed, please check API Key |
| 402 | Insufficient account balance / points |
| 429 | Request rate limit exceeded |
| 500 | Internal server error |

## Usage Flow

1. Obtain your API Key from the console
2. Call the endpoint with `key` and required parameters
3. Parse the JSON (or binary) response according to the examples above

---

_Generated for AI / LLM consumption. Source of truth: `api_list` (same as HTML `/doc/{id}`)._
