图片生成 API:GPT Image 2、Nano Banana、Grok Imagine
客户对接统一使用主站 Bearer 鉴权异步接口:提交任务、轮询状态、鉴权下载结果。站内页面内部接口不作为客户接入文档使用。
基础信息
| 项目 | 值 |
|---|---|
| 主站 | https://www.zexitongxue.com |
| 异步提交 | POST /v1/images/generations/async |
| 任务查询 | GET /v1/images/tasks/{task_id} |
| 结果下载 | GET /v1/images/tasks/{task_id}/content?index=0 |
| 鉴权 | Authorization: Bearer YOUR_API_KEY |
| 推荐格式 | Content-Type: application/json |
客户只使用本页列出的
/v1/images/* 对外接口;站内页面登录态接口不适合作为售前或第三方 API 文档。有效生图模型
| 展示/用途 | 实际模型名 | 参考图上限 | 客户调用入口 |
|---|---|---|---|
| GPT Image 2 | gpt-image-2 | 14 | POST /v1/images/generations/async |
| Nano Banana Pro | gemini-3-pro-image-preview | 4 | POST /v1/images/generations/async |
| Nano Banana 2 | gemini-3.1-flash-image-preview | 4 | POST /v1/images/generations/async |
| Grok Imagine Image | grok-imagine-image | 1 | POST /v1/images/generations/async |
| Grok Imagine Image Pro | grok-imagine-image-pro | 1 | POST /v1/images/generations/async |
| Grok Imagine Image Lite | grok-imagine-image-lite | 0 | POST /v1/images/generations/async |
| Grok Imagine Image Edit | grok-imagine-image-edit | 3 | POST /v1/images/generations/async |
模型别名
| 客户传入别名 | 实际模型名 |
|---|---|
dall-e | gpt-image-2 |
dall-e-2 | gpt-image-2 |
dall-e-3 | grok-imagine-image-pro |
nano-banana | gemini-3.1-flash-image-preview |
nano-banana2 | gemini-3.1-flash-image-preview |
nano-banana-2 | gemini-3.1-flash-image-preview |
nano-banana-pro | gemini-3-pro-image-preview |
grok-imagine-image-quality | grok-imagine-image-pro |
客户异步流程
- 调用
POST /v1/images/generations/async提交任务。 - 保存返回的
task_id。 - 调用
GET /v1/images/tasks/{task_id}轮询状态。 - 任务成功后读取
result_url或data.data[0].url。 - 下载结果时继续携带
Authorization: Bearer YOUR_API_KEY。
请求示例
GPT Image 2 文生图
curl -X POST 'https://www.zexitongxue.com/v1/images/generations/async' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
--data-raw '{
"model": "gpt-image-2",
"prompt": "A clean modern product poster for a single banana, premium studio lighting, white background.",
"size": "1024x1024",
"quality": "auto",
"n": 1
}'Nano Banana Pro 4K
curl -X POST 'https://www.zexitongxue.com/v1/images/generations/async' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
--data-raw '{
"model": "gemini-3-pro-image-preview",
"prompt": "A cinematic banana product poster, dramatic lighting, sharp details.",
"size": "16:9",
"quality": "2K",
"n": 1,
"extra_body": {
"google": {
"image_config": {
"aspect_ratio": "16:9",
"image_size": "4K"
}
}
}
}'Grok Imagine Pro 文生图
curl -X POST 'https://www.zexitongxue.com/v1/images/generations/async' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
--data-raw '{
"model": "grok-imagine-image-pro",
"prompt": "A cinematic banana product poster, dramatic lighting, sharp details.",
"size": "16:9",
"n": 1
}'图生图 / 参考图
curl -X POST 'https://www.zexitongxue.com/v1/images/generations/async' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
--data-raw '{
"model": "gemini-3.1-flash-image-preview",
"prompt": "Keep the composition, make it watercolor style.",
"size": "16:9",
"quality": "2K",
"n": 1,
"image_url": "https://example.com/input.jpg"
}'响应、查询与取图
提交成功响应
{
"id": "aiimg_xxx",
"task_id": "aiimg_xxx",
"status": "queued",
"progress": 1,
"data": []
}查询任务
curl 'https://www.zexitongxue.com/v1/images/tasks/{task_id}' \
-H 'Authorization: Bearer YOUR_API_KEY'任务成功响应
{
"code": "success",
"message": "",
"data": {
"task_id": "aiimg_xxx",
"status": "SUCCESS",
"progress": "100%",
"result_url": "https://www.zexitongxue.com/v1/images/tasks/aiimg_xxx/content?index=0",
"data": {
"data": [
{
"url": "https://www.zexitongxue.com/v1/images/tasks/aiimg_xxx/content?index=0"
}
]
}
}
}下载结果
curl 'https://www.zexitongxue.com/v1/images/tasks/{task_id}/content?index=0' \
-H 'Authorization: Bearer YOUR_API_KEY' \
--output result.png尺寸、质量与注意事项
| 模型 | 尺寸/比例 | 质量 |
|---|---|---|
gpt-image-2 | 1024x1024、1536x1024、1024x1536、2048x1152、3840x2160、2160x3840、auto | low / medium / high / auto |
gemini-3-pro-image-preview / gemini-3.1-flash-image-preview | 1:1、16:9、9:16、4:3、3:4、3:2、2:3、5:4、4:5、21:9 | 1K / 2K / 4K |
grok-imagine-image* | 建议传比例字符串,如 1:1、16:9、9:16 | 按模型默认质量处理 |
结果地址默认不是公开免鉴权链接;成功结果默认保留约 2 小时,请在结果可用后及时拉取或转存。
文档来源
本页根据本地 Nano Banana Gemini原生与异步接口说明.md 更新,面向客户只保留 /v1/images/generations/async 对外异步接口。