nano-banana接口

POST https://{base_url}/v1/api/generate

请求参数

Path 参数

参数名 类型 必需 描述
base_url string 必需

Header 参数

参数名 类型 必需 描述
Authorization string 可选 示例: Bearer sk-xxxxxxxxxxx

Body 参数 application/json 必填

参数名 类型 必需 描述
model string 必需 模型名称
支持以下模型:
  • nano-banana
  • nano-banana-fast
  • nano-banana-2
  • nano-banana-2-cl
  • nano-banana-2-4k-cl
  • nano-banana-pro
  • nano-banana-pro-vt
  • nano-banana-pro-cl
  • nano-banana-pro-vip
  • nano-banana-pro-4k-vip
prompt string 必需 提示词
images array[string] 可选 参考图,支持base64与url链接
aspectRatio string 可选 比例
图像比例支持的参数:
  • auto
  • 1:1
  • 16:9
  • 9:16
  • 4:3
  • 3:4
  • 3:2
  • 2:3
  • 5:4
  • 4:5
  • 21:9
nano-banana-2系列额外支持比例:
  • 1:4
  • 4:1
  • 1:8
  • 8:1
imageSize string 可选 分辨率,1K、2K、4K
replyType string 可选 回复类型
支持参数:
  • json(返回json)
  • stream(返回stream)
  • async(异步轮询)

示例

JSON
"model": "nano-banana-2",
"prompt": "生成一张边牧与古牧正在抖音直播间直播带货截图",
"images": [],
"aspectRatio": "1:1",
"imageSize": "1K",
"replyType": "json" }

请求示例代码

cURL cURL-Windows Httpie wget PowerShell
curl --location 'https://v1/api/generate' \
--header 'Authorization: Bearer sk-xxxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data '{
 "model": "nano-banana-2",
 "prompt": "生成一张边牧与古牧正在抖音直播间直播带货截图",
 "images": [],
 "aspectRatio": "1:1",
 "imageSize":"1K",
 "replyType": "json"
}'

返回响应

200 成功
200 异步生成返回结果
400 报错

application/json

Body application/json

参数名 类型 必需 描述
id string 必需 任务id
status string 必需 状态
任务状态:
  • running (进行中)
  • violation (违规)
  • succeeded (生成成功)
  • failed (任务失败)
progress integer 可选 进度,0~100
results array [object] 可选
url string 可选 图片/视频链接
error string 可选 报错信息

示例

{
    "id": "14-5f3cf761-a4bb-486a-8016-77f490998f80",
    "status": "succeeded",
    "results": [
        {
            "url": "https://file1.aitohumanize.com/file/fcdd2d07449d438d9d69d450f5626976.png"
        }
    ]
}

gpt-image-2接口

POST https://{base_url}/v1/api/generate

请求参数

Path 参数

参数名 类型 必需 描述
base_url string 必需

Header 参数

参数名 类型 必需 描述
Authorization string 可选 示例: Bearer sk-xxxxxxxxxxx

Body 参数 application/json 必填

参数名 类型 必需 描述
model string 必需 模型名称
支持以下模型:
  • gpt-image-2
  • gpt-image-2-vip
prompt string 必需 提示词
images array[string] 可选 参考图,支持base64与url链接
aspectRatio string 可选 比例

分辨率参数说明

gpt-image-2:支持比例(如 "16:9")或1K像素值(如 "1024x1024")

gpt-image-2-vip:支持1-4K像素值(如 "1024x1024"、"2048x2048"),不支持比例

自定义像素值约束(仅限 vip 模型)

最大边长必须小于或等于3840px

两条边都必须是16的倍数

长边与短边之比不得超过 3:1

总像素数必须至少为 655,360且不得超过 8,294,400

gpt-image-2-vip比例参考(1K、2K、4K):
  • auto
  • 1:1:1024x1024、2048x2048、2880x2880
  • 16:9:1280x720、2048x1152、3840x2160
  • 9:16:720x1280、1152x2048、2160x3840
  • 4:3:1152x864、2304x1728、3264x2448
  • 3:4:864x1152、1728x2304、2448x3264
  • 3:2:1536x1024、2048x1360、3504x2336
  • 2:3:1024x1536、1360x2048、2336x3504
  • 5:4:1120x896、2240x1792、3200x2560
  • 4:5:896x1120、1792x2240、2560x3200
  • 21:9:1456x624、2912x1248、3840x1648
  • 9:21:624x1456、1248x2912、1648x3840
  • 1:3:688x2048、1280x3840
  • 3:1:2048x688、3840x1280
  • 2:1:1536x768、3072x1536、3840x1920
  • 1:2:768x1536、1536x3072、1920x3840
gpt-image-2比例参考:
  • auto
  • 1:1:1024x1024
  • 16:9:1672x941
  • 9:16:941x1672
  • 4:3:1443x1090
  • 3:4:1090x1443
  • 3:2:1536x1024
  • 2:3:1024x1536
  • 5:4:1408x1120
  • 4:5:1120x1408
  • 21:9:1920x832
  • 9:21:832x1920
  • 1:2:896x1792
  • 2:1:1792x896
replyType string 可选 回复类型
支持参数:
  • json(返回json)
  • stream(返回stream)
  • async(异步轮询)

示例

JSON
"model": "gpt-image-2",
"prompt": "生成一张边牧与古牧正在抖音直播间直播带货截图",
"images": [],
"aspectRatio": "1024x1024",
"replyType": "json" }

请求示例代码

cURL cURL-Windows Httpie wget PowerShell
curl --location 'https://v1/api/generate' \
--header 'Authorization: Bearer sk-xxxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data '{
 "model": "gpt-image-2",
 "prompt": "生成一张边牧与古牧正在抖音直播间直播带货截图",
 "images": [],
 "aspectRatio": "1024x1024",
 "replyType": "json"
}'

返回响应

200 成功
200 异步生成返回结果
400 报错

application/json

Body application/json

参数名 类型 必需 描述
id string 必需 任务id
status string 必需 状态
任务状态:
  • running (进行中)
  • violation (违规)
  • succeeded (生成成功)
  • failed (任务失败)
progress integer 可选 进度,0~100
results array [object] 可选
url string 可选 图片/视频链接
error string 可选 报错信息

示例

{
    "id": "14-5f3cf761-a4bb-486a-8016-77f490998f80",
    "status": "succeeded",
    "results": [
        {
            "url": "https://file1.aitohumanize.com/file/fcdd2d07449d438d9d69d450f5626976.png"
        }
    ]
}

异步生成结果查询接口

GET https://{base_url}/v1/api/result

请求参数

Path 参数

参数名 类型 必需 描述
base_url string 必需

Query 参数

参数名 类型 必需 描述
id string 可选 示例: 1-6634fd9a-3086-4d92-9436-69e86fd23bf8

Header 参数

参数名 类型 必需 描述
Authorization string 可选 示例: Bearer sk-xxxxxxxxxxx

请求示例代码

cURL cURL-Windows Httpie wget PowerShell
curl --location 'https://v1/api/result?id=1-6634fd9a-3086-4d92-9436-69e86fd23bf8' \
--header 'Authorization: Bearer sk-xxxxxxxxxxx'

返回响应

200 成功
400 报错

application/json

Body application/json

参数名 类型 必需 描述
id string 必需 任务id
status string 必需 状态
任务状态:
  • running (进行中)
  • violation (违规)
  • succeeded (生成成功)
  • failed (任务失败)
progress integer 可选 进度,0~100
results array [object] 可选
url string 可选 图片/视频链接
error string 可选 报错信息

示例

{
    "id": "14-5f3cf761-a4bb-486a-8016-77f490998f80",
    "status": "succeeded",
    "results": [
        {
            "url": "https://file1.aitohumanize.com/file/fcdd2d07449d438d9d69d450f5626976.png"
        }
    ]
}