AI GPT ImageAI GPT Image
Image ModelsNano Banana

Nano Banana 2 图生图 API

获取 API Keynano-banana-2-image-to-image

创建任务

POST https://aigptimage.com/api/v1/jobs/createTask
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Input 参数

字段类型必填说明
promptstringYes图片转换指令,最多 20000 字符
image_inputstring[]Yes公开可访问的 HTTPS 输入图片 URL,最多 14 张
aspect_ratiostringNo可选: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
resolutionstringNo1K2K4K。默认:1K
output_formatstringNopngjpg。默认:png

输入图片要求

  • 使用公开可访问的 https:// 图片 URL。
  • 支持格式:JPEG/JPG、PNG、WEBP。
  • 每张图片最大 30MB。
  • 不要传本地文件路径、二进制上传、原始 base64 字符串或内嵌 data:image/...;base64,... URL。

请求示例

{
  "model": "nano-banana-2-image-to-image",
  "input": {
    "prompt": "Translate all visible text in this image to Hindi while preserving the layout",
    "image_input": ["https://cdn.example.com/input.png"],
    "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.statesuccess 时,把 data.resultJson 当作 JSON 字符串解析,然后读取 resultUrls

{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "task_xxxxxxxxxxxxx",
    "model": "nano-banana-2-image-to-image",
    "state": "success",
    "param": "{\"model\":\"nano-banana-2-image-to-image\",\"input\":{\"prompt\":\"Translate all visible text in this image to Hindi while preserving the layout\",\"image_input\":[\"https://cdn.example.com/input.png\"],\"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服务器内部错误