Image ModelsNano Banana
Nano Banana 2 文生图 API
获取 API Keynano-banana-2-text-to-image
创建任务
POST https://aigptimage.com/api/v1/jobs/createTask
Authorization: Bearer YOUR_API_KEY
Content-Type: application/jsonInput 参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
prompt | string | Yes | 图片生成描述,最多 20000 字符 |
aspect_ratio | string | No | 可选:auto, 1:1, 1:4, 1:8, 2:3, 3:2, 3:4, 4:1, 4:3, 4:5, 5:4, 8:1, 9:16, 16:9, 21:9。默认:auto |
resolution | string | No | 1K、2K 或 4K。默认:1K |
output_format | string | No | png 或 jpg。默认:png |
请求示例
{
"model": "nano-banana-2-text-to-image",
"input": {
"prompt": "A clean product photo of a futuristic yellow camera on a white desk",
"aspect_ratio": "auto",
"resolution": "1K",
"output_format": "png"
}
}创建响应
{
"code": 200,
"msg": "success",
"data": {
"taskId": "task_xxxxxxxxxxxxx"
}
}保存 data.taskId,后续用它查询任务结果。
查询任务
GET https://aigptimage.com/api/v1/jobs/recordInfo?taskId=task_xxxxxxxxxxxxx
Authorization: Bearer YOUR_API_KEY当 data.state 为 success 时,把 data.resultJson 当作 JSON 字符串解析,然后读取 resultUrls。
{
"code": 200,
"msg": "success",
"data": {
"taskId": "task_xxxxxxxxxxxxx",
"model": "nano-banana-2-text-to-image",
"state": "success",
"param": "{\"model\":\"nano-banana-2-text-to-image\",\"input\":{\"prompt\":\"A clean product photo of a futuristic yellow camera on a white desk\",\"aspect_ratio\":\"auto\",\"resolution\":\"1K\",\"output_format\":\"png\"}}",
"resultJson": "{\"resultUrls\":[\"https://cdn.example.com/result.png\"]}",
"failCode": null,
"failMsg": null,
"costTime": 12000,
"completeTime": 1757584176490,
"createTime": 1757584164490
}
}错误码
| Status Code | 说明 |
|---|---|
400 | 请求参数无效 |
401 | 认证失败或 API Key 无效 |
402 | 积分余额不足 |
404 | 任务不存在 |
409 | 活跃任务数量超限或请求冲突 |
422 | 参数校验失败 |
429 | 请求频率超限 |
500 | 服务器内部错误 |