Gemini 图像
用异步任务调用 Gemini 图像模型,包含各模型的比例和清晰度。
下表模型是媒体模型。创建任务用
POST /v1/router/task/create,查询用GET /v1/router/tasks/{task_id}。nano-banana-pro与nano-banana-2有各自的文档和模型 ID。
调用前用 GET /v1/models 确认当前 API Key 能看到对应模型 ID。
模型
标准牌价单位是 USD / 1M tokens,三列依次为输入、文本与思考输出、图像输出。账号实扣还会乘上平台结算和价格系数。表中的比例、清晰度和牌价以 GET /v1/models 的返回与价格页为准。
| 模型 ID | 比例 | 清晰度 | 标准牌价 |
|---|---|---|---|
gemini-3-pro-image | 1:1 2:3 3:2 3:4 4:3 4:5 5:4 9:16 16:9 21:9 | 1K 2K | $2 / $12 / $120 |
gemini-3.1-flash-image | 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 | 1K 2K | $0.50 / $3 / $60 |
gemini-3.1-flash-lite-image | 1:1 2:3 3:2 3:4 4:3 4:5 5:4 9:16 16:9 21:9 | 1K | $0.25 / $1.50 / $30 |
gemini-nano-banana-2.1 | 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 | 1K 2K 4K | $1.50 / $7.50 / $30 |
清晰度大小写不敏感,1k 会按该模型配置中的 1K 提交。比例和清晰度必须落在上表里,否则创建请求直接返回 HTTP 400,不会建任务。
任务流程
- 图生图先准备公网 HTTPS 图片。本地文件、Base64 或 Data URL 先通过 U-Token 通用币 文件上传 转成公开
fileUrl。 - 把
task、model和input发到POST /v1/router/task/create。响应立即返回tsk_*格式的task_id。这些模型不预扣余额。 - 每 3~5 秒调用
GET /v1/router/tasks/{task_id},直到进入终态。这些模型的任务提交后不能取消。API Key 只能查询同一买家的任务。 - 状态
2时读取results[].urls和cost,并尽快下载。结果 URL 会过期。
| 状态 | 含义 |
|---|---|
0 | 排队中 |
1 | 处理中 |
2 | 已完成。results[].urls 是图片,cost 是积分 |
3 | 失败,不扣费 |
失败响应是中性的 Provider error (request id: aitk-...),不包含上游原文。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
task | string | 是 | 文生图 Txt2Img,图生图 Img2Img |
model | string | 是 | 上表中的模型 ID |
input.prompt | string | 是 | 非空提示词 |
input.aspect_ratio | string | 是 | 该模型支持的比例,必须完全匹配 |
input.resolution | string | 是 | 该模型支持的清晰度 |
input.images | string[] | 图生图是 | 1–14 个公网 HTTPS 图片 URL。http:// 地址会返回 HTTP 400 |
input.output_format | string | 否 | 省略或 png。jpg 会返回 HTTP 400 |
mode | string | 否 | 不要传。非空值会返回 HTTP 400 |
callback_url | string | 否 | 可选的公网 HTTPS 回调地址。见媒体任务回调。 |
计费
成功任务按三段用量计费:输入 token 用输入价,文本和思考 token 用文本输出价,图像 token 用图像输出价。用量拆不开时,整段输出按图像输出价计。官方金额按 $1 = 100 积分 换算,再应用平台结算、代理报价和账号系数。
查询结果里的 cost 是这次调用的积分。公开响应不返回 token 明细。失败不扣费。
请求示例
# 文生图
curl https://u-token.ai/v1/router/task/create \
-H "Authorization: Bearer sk-你的KEY" -H "content-type: application/json" \
-d '{"task":"Txt2Img","model":"gemini-3.1-flash-image",
"input":{"prompt":"a small cat","aspect_ratio":"1:1","resolution":"1K"}}'# 图生图
curl https://u-token.ai/v1/router/task/create \
-H "Authorization: Bearer sk-你的KEY" -H "content-type: application/json" \
-d '{"task":"Img2Img","model":"gemini-3-pro-image",
"input":{"prompt":"给猫戴一顶红帽子","aspect_ratio":"1:1","resolution":"1K",
"images":["https://example.com/cat.png"]}}'响应
创建成功:
{
"code": 200,
"message": "success",
"task_id": "tsk_mabc1234_0123456789abcdef01234567"
}生成并结算完成后:
{
"task_id": "tsk_mabc1234_0123456789abcdef01234567",
"status": 2,
"results": [{ "urls": ["https://assets.example.com/gemini-image-1.png"] }],
"cost": 6.72
}失败时 status 为 3,没有 cost,message 形如 Provider error (request id: aitk-...)。
