Image ModelsNano Banana
Nano Banana 文生图 API
获取 API Keynano-banana-text-to-image
创建任务
POST https://aigptimage.com/api/v1/jobs/createTask
Authorization: Bearer YOUR_API_KEY
Content-Type: application/jsonInput 参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
prompt | string | Yes | 图片生成描述,最多 20000 字符 |
image_size | string | No | 输出比例。可选:1:1, 9:16, 16:9, 3:4, 4:3, 3:2, 2:3, 5:4, 4:5, 21:9, auto。默认:1:1 |
aspect_ratio | string | No | image_size 的别名 |
output_format | string | No | png 或 jpeg。默认:png |
nsfw_checker | boolean | No | 是否启用底层安全检查。默认:true |
请求示例
{
"model": "nano-banana-text-to-image",
"input": {
"prompt": "A surreal painting of a giant banana floating in space, stars and galaxies in the background, vibrant colors, digital art",
"image_size": "1:1",
"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-text-to-image",
"state": "success",
"param": "{\"model\":\"nano-banana-text-to-image\",\"input\":{\"prompt\":\"A surreal painting of a giant banana floating in space, stars and galaxies in the background, vibrant colors, digital art\",\"image_size\":\"1:1\",\"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 | 服务器内部错误 |