概述
Nano Banana 图片生成接口,支持文生图(text-to-image)和图生图编辑(image-to-image edit)两种模式。
Base URL: https://api.apiverse.ai
认证方式
所有接口均需要在请求头中携带 Token 进行认证:
Authorization: Bearer {YOUR_AUTH_TOKEN}快速开始
cURL 示例
创建文生图任务
curl -X POST "https://api.apiverse.ai/api/v2/open/aigc/nano-banana" \
-H "Authorization: Bearer your_auth_token_here" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A surreal painting of a giant banana floating in space",
"imageSize": "16:9",
"outputFormat": "png"
}'创建图生图编辑任务
curl -X POST "https://api.apiverse.ai/api/v2/open/aigc/nano-banana" \
-H "Authorization: Bearer your_auth_token_here" \
-H "Content-Type: application/json" \
-d '{
"prompt": "将图片转换为水彩画风格",
"genType": "i2i",
"imageUrls": ["https://example.com/input.jpg"],
"imageSize": "1:1"
}'查询任务状态
curl -X GET "https://api.apiverse.ai/api/v2/open/aigc/task_abc123" \
-H "Authorization: Bearer your_auth_token_here"接口列表
1. 创建 Nano Banana 图片生成任务
POST /api/v2/open/aigc/nano-banana
创建一个 Nano Banana 图片生成任务。
Content-Type: application/json
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| prompt | string | 是 | 图片描述提示词,最多5000字符 |
| genType | string | 否 | 生成类型:t2i(文生图,默认) / i2i(图生图编辑) |
| imageUrls | string[] | 条件 | 参考图片 URL(i2i时必填,最多10张,JPEG/PNG/WebP,每张最大10MB) |
| outputFormat | string | 否 | 输出格式:png(默认) / jpeg |
| imageSize | string | 否 | 宽高比:1:1(默认) / 9:16 / 16:9 / 3:4 / 4:3 / 3:2 / 2:3 / 5:4 / 4:5 / 21:9 / auto |
| callbackUrl | string | 否 | 任务完成后的回调通知 URL |
说明:
- 图生图(i2i)时必须提供 imageUrls
请求示例
基础文生图:
{
"prompt": "A surreal painting of a giant banana floating in space"
}指定格式和尺寸:
{
"prompt": "一只可爱的猫咪坐在窗台上,阳光洒落,超写实风格",
"outputFormat": "jpeg",
"imageSize": "16:9"
}图生图编辑:
{
"prompt": "将图片转换为水彩画风格,保持构图不变",
"genType": "i2i",
"imageUrls": ["https://example.com/input.jpg"],
"imageSize": "1:1"
}带回调地址:
{
"prompt": "星空下的古老城堡,油画风格",
"imageSize": "21:9",
"callbackUrl": "https://your-server.com/callback"
}响应参数
| 参数 | 类型 | 说明 |
|---|---|---|
| code | int | 状态码,0 表示成功 |
| msg | string | 状态信息 |
| data.taskId | string | 任务 ID,用于查询任务状态 |
| data.status | string | 任务状态,创建时固定为 processing |
| data.createdAt | string | 创建时间 |
响应示例
成功
{
"code": 0,
"msg": "success",
"data": {
"taskId": "task_20260509150000_abc12345",
"status": "processing",
"createdAt": "2026-05-09 15:00:00"
}
}2. 查询任务状态
GET /api/v2/open/aigc/{taskId}
查询单个任务的执行状态。
响应示例
成功
{
"code": 0,
"msg": "success",
"data": {
"taskId": "task_20260509150000_abc12345",
"status": "success",
"result": [
"https://fc-gw-sh.oss-accelerate.aliyuncs.com/images/2026/05/09/output_001.png"
],
"createdAt": "2026-05-09 15:00:00",
"updatedAt": "2026-05-09 15:00:20"
}
}3. 批量查询任务状态
POST /api/v2/open/aigc/batch
批量查询多个任务的执行状态(最多 100 个)。
回调通知
当任务完成(成功或失败)时,如果创建任务时提供了 callbackUrl,系统会向该 URL 发送 POST 请求。
回调请求
Headers
Content-Type: application/json
X-Funcloud-Event: task.completed
X-Funcloud-Signature: {签名}Body
{
"event": "task.completed",
"taskId": "task_20260509150000_abc12345",
"status": "success",
"result": ["https://fc-gw-sh.oss-accelerate.aliyuncs.com/images/output_001.png"],
"errorMsg": "",
"timestamp": "2026-05-09T15:00:20+08:00",
"signature": "a1b2c3d4e5f6..."
}错误码
| code | 说明 |
|---|---|
| 0 | 成功 |
| 10002 | 参数缺失或格式错误 |
| 10005 | API Key 无效或缺失 |
| 30003 | 任务不存在 |
| 90003 | 服务器内部错误 |
最佳实践
1. 轮询策略
建议的轮询间隔:
- 前 30 秒:每 3 秒查询一次
- 30 秒后:每 5 秒查询一次
2. 使用回调
生产环境建议使用回调通知而非轮询。
3. 处理时间参考
- 文生图:通常 5 ~ 20 秒
- 图生图编辑:通常 5 ~ 20 秒