AI GPT ImageAI GPT Image
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/json

Input 参数

字段类型必填说明
promptstringYes图片生成描述,最多 20000 字符
image_sizestringNo输出比例。可选:1:1, 9:16, 16:9, 3:4, 4:3, 3:2, 2:3, 5:4, 4:5, 21:9, auto。默认:1:1
aspect_ratiostringNoimage_size 的别名
output_formatstringNopngjpeg。默认:png
nsfw_checkerbooleanNo是否启用底层安全检查。默认: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.statesuccess 时,把 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服务器内部错误