Google
· 发布于 2026-02-28
Nano Banana 2 (Gemini 3.1 Flash Image Preview)
Gemini 3.1 Flash Image Preview (“Nano Banana 2”) is Google’s next-generation image generation and editing model, combining Pro-level visual quality with Flash-level speed and cost efficiency. It delivers stronger contextual understanding, high-fidelity image creation, and fast iterative editing for a wide range of creative and production workflows. Developers can customize output composition and aspect ratios through the image_config API parameter.
google/gemini-3.1-flash-image-preview 官方示例
输入
提示词
将画面中的男性替换为女性,该女性手持香蕉

输出

参数说明
由模型输入 Schema 解析| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
prompt必填 | string | — | 提示词 |
aspect_ratio | string | 1:1 | 宽高比 |
response_modalities | array | IMAGE | 响应模态 |
size | string | 1K | 图像大小 |
image必填 | string | — | 图片Url |
images必填 | array | — | 图片Url数组 |
接入示例
# 提交任务
curl https://router-integration.test.cogfoundry.ai/api/v1/tasks/generations \
-H "Authorization: Bearer $MODEL_CENTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "google/gemini-3.1-flash-image-preview",
"aspect_ratio": "16:9",
"image": "https://oss.shengsuanyun.com/example/modelinfo/283/input_0.jpg",
"prompt": "将画面中的男性替换为女性,该女性手持香蕉",
"response_modalities": [
"IMAGE"
],
"size": "1K"
}'
# 轮询结果(REQUEST_ID 来自上一步返回的 data.request_id)
curl https://router-integration.test.cogfoundry.ai/api/v1/tasks/generations/REQUEST_ID \
-H "Authorization: Bearer $MODEL_CENTER_API_KEY" import requests
BASE = "https://router-integration.test.cogfoundry.ai/api/v1"
KEY = "$MODEL_CENTER_API_KEY"
headers = {"Authorization": f"Bearer {KEY}", "Content-Type": "application/json"}
# 提交任务
resp = requests.post(f"{BASE}/tasks/generations", headers=headers, data='''{
"model": "google/gemini-3.1-flash-image-preview",
"aspect_ratio": "16:9",
"image": "https://oss.shengsuanyun.com/example/modelinfo/283/input_0.jpg",
"prompt": "将画面中的男性替换为女性,该女性手持香蕉",
"response_modalities": [
"IMAGE"
],
"size": "1K"
}''')
request_id = resp.json()["data"]["request_id"]
# 轮询结果
result = requests.get(f"{BASE}/tasks/generations/{request_id}", headers=headers)
print(result.json()) const BASE = "https://router-integration.test.cogfoundry.ai/api/v1";
const KEY = "$MODEL_CENTER_API_KEY";
const headers = { Authorization: "Bearer " + KEY, "Content-Type": "application/json" };
// 提交任务
const payload = {
"model": "google/gemini-3.1-flash-image-preview",
"aspect_ratio": "16:9",
"image": "https://oss.shengsuanyun.com/example/modelinfo/283/input_0.jpg",
"prompt": "将画面中的男性替换为女性,该女性手持香蕉",
"response_modalities": [
"IMAGE"
],
"size": "1K"
};
const resp = await fetch(BASE + "/tasks/generations", {
method: "POST",
headers,
body: JSON.stringify(payload),
});
const { data } = await resp.json();
// 轮询结果
const result = await fetch(BASE + "/tasks/generations/" + data.request_id, { headers });
console.log(await result.json()); 定价
USD · 实时汇率| 定价 | USD |
|---|---|
| 输入 | $0.50 |
| 输入图像 | $0.50 |
| 输出 | $3.00 |
| 输出图像 | $60.00 |
供应商
提供该模型的渠道| 供应商 | 起价 |
|---|---|
| Google Vertex | $0.50 |
| OpenRouter | $0.50 |