通过媒体任务接口接入 nano-banana2。 包含请求示例、参数、鉴权和结果处理。
/v1/tasksMODELnano-banana2代码示例与响应
/v1/taskscurl "https://newrouters.com/v1/tasks" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $API_KEY" \
--data '{
"model": "nano-banana2",
"input": {
"resolution": "1k",
"aspect_ratio": "auto",
"output_format": "jpeg",
"prompt": "A small red house in a quiet garden",
"images": []
}
}'const apiBaseUrl = "https://newrouters.com";
const apiKey = process.env.API_KEY;
if (!apiKey) throw new Error("Set API_KEY in your server environment");
const response = await fetch(apiBaseUrl + "/v1/tasks", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer " + apiKey
},
body: JSON.stringify({
"model": "nano-banana2",
"input": {
"resolution": "1k",
"aspect_ratio": "auto",
"output_format": "jpeg",
"prompt": "A small red house in a quiet garden",
"images": []
}
})
});
const result = await response.json();
if (!response.ok) throw new Error(JSON.stringify(result));
console.log(result);import json
import os
from urllib.request import Request, urlopen
api_base_url = "https://newrouters.com"
api_key = os.environ["API_KEY"]
body = json.loads("{\"model\":\"nano-banana2\",\"input\":{\"resolution\":\"1k\",\"aspect_ratio\":\"auto\",\"output_format\":\"jpeg\",\"prompt\":\"A small red house in a quiet garden\",\"images\":[]}}")
request = Request(
api_base_url + "/v1/tasks",
data=json.dumps(body).encode("utf-8"),
headers={
"Content-Type": "application/json",
"Authorization": "Bearer " + api_key
},
method="POST",
)
with urlopen(request) as response:
print(json.load(response))平台地址已填入,运行前设置 API_KEY 环境变量。示例不会自动发起请求。
202任务已受理
{
"id": "TASK_ID",
"status": "pending",
"model": "nano-banana2",
"result": null,
"error": null
}200成功结果
{
"id": "TASK_ID",
"status": "succeeded",
"model": "nano-banana2",
"result": {
"assets": [
"https://example.com/output.png"
]
},
"error": null
}- 创建任务01
POST /v1/tasks提交 model + input,保存返回的任务 id。
202 · pending - 轮询状态02
GET /v1/tasks/{id}pending / processing 时等待并继续查询。
等待 → 再查询 - 读取终态03
result.assets[] / error按任务终态读取对应结果。
succeeded→ assetsfailed→ error
示例输出
在模型页查看与试用 ↗以下结果均通过本平台 API 实际生成,费用为任务回执中的实扣金额。

提示词与参数
Cinematic product photograph of a sculptural white and graphite running shoe levitating above a wet black asphalt street at night, fine rain falling, cyan and magenta neon reflections rippling in puddles, shallow depth of field, crisp material detail on the knit upper and translucent sole, centered with generous negative space on both sides. Photorealistic, anamorphic film look. No text, no logos.
aspect_ratio: 16:9 · resolution: 2k · output_format: jpeg
提示词与参数
Combine the references: the woman from the first image (same face, silver bob, scar above left eyebrow, burnt-orange jacket) is wearing the graphite over-ear headphones from the second image around her neck. Editorial studio portrait against a seamless warm grey backdrop, soft key light, three-quarter view, confident expression. Photorealistic.
aspect_ratio: 4:5 · resolution: 2k · output_format: jpeg
提示词与参数
Overhead food photograph of a steaming bowl of hand-pulled beef noodles with clear broth, sliced braised beef, bright green scallions, cilantro and a swirl of red chili oil, on a dark slate table with chopsticks, a small dish of pickled radish and scattered Sichuan peppercorns. Natural window light, appetizing, highly detailed.
aspect_ratio: 4:5 · resolution: 2k · output_format: jpegAPI 模型 ID 为 nano-banana2。本文说明平台的实际契约,调用前请核对实时目录中的可用性。
平台地址在构建时填入,运行前设置 API_KEY 为服务端密钥。
curl "https://newrouters.com/v1/tasks" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $API_KEY" \ --data '{ "model": "nano-banana2", "input": { "resolution": "1k", "aspect_ratio": "auto", "output_format": "jpeg", "prompt": "A small red house in a quiet garden", "images": [] }}'创建响应表示任务已受理,不是最终结果。用返回的 ID 替换 TASK_ID,轮询至 succeeded 或 failed。
curl "https://newrouters.com/v1/tasks/TASK_ID" \ -H "Authorization: Bearer $API_KEY"成功查看 result,失败查看 error。上游结果未知时保留原任务 ID,不盲目重复提交付费生成。
| 字段 | 类型 | 要求 | 默认值 | 限制 |
|---|---|---|---|---|
images | array | 可选 | [] | — |
prompt | string | 必填 | — | 最大长度 100000 |
resolution | enum | 可选 | "1k" | 1k, 2k, 4k |
aspect_ratio | enum | 可选 | "auto" | auto, 1:1, 3:2, 2:3, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9, 1:4, 1:8, 4:1, 8:1 |
output_format | enum | 可选 | "jpeg" | png, jpeg, webp |
官方来源与模型身份
Section titled “官方来源与模型身份”核对日期: 2026-09-27 · 平台模型: nano-banana2 · 官方对应: gemini-3.1-flash-image
接入时核对当前可用性、契约和账号价格。排错时保留请求 ID 与消费凭据。 完整 API 参考
任务工作流与预算
Section titled “任务工作流与预算”查看任务教程,再按批量预算核对规格、尝试次数与最终费用。示例不承诺生成速度或质量,先用获批的小样本验收。