NanoBanana 图像生成
Gemini 图像生成模型系列,通过 API 生成高质量图像。
NanoBanana 是 Gemini 图像生成模型系列,可通过 API Key 直接使用,无需 VPN 或 Google 账号。
可用模型
| 模型 | ID | 特点 |
|---|---|---|
| NanoBananaPro | gemini-3-pro-image-preview | 最高质量,支持高分辨率,适合商业用途 |
| NanoBanana2 | gemini-3.1-flash-image-preview | 速度更快,性价比高,适合快速预览 |
支持的规格
宽高比
支持 10 种宽高比:1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 21:9, 5:4, 4:5
分辨率
| 级别 | 说明 |
|---|---|
| 1K | 快速预览 |
| 2K | 推荐日常使用 |
| 4K | 超高清 |
API 请求示例
Python
import requests
import base64
url = "https://ai.nebulatrip.com/v1/models/gemini-3-pro-image-preview:generateContent"
headers = {
"Content-Type": "application/json",
"x-goog-api-key": "your-api-key"
}
payload = {
"contents": [{
"parts": [{"text": "一只可爱的猫咪在阳光下玩耍"}]
}],
"generationConfig": {
"responseModalities": ["IMAGE"],
"imageConfig": {
"aspectRatio": "1:1",
"image_size": "2K"
}
}
}
response = requests.post(url, headers=headers, json=payload)
Node.js
const response = await fetch(
"https://ai.nebulatrip.com/v1/models/gemini-3-pro-image-preview:generateContent",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"x-goog-api-key": "your-api-key"
},
body: JSON.stringify({
contents: [{
parts: [{ text: "一只可爱的猫咪在阳光下玩耍" }]
}],
generationConfig: {
responseModalities: ["IMAGE"],
imageConfig: {
aspectRatio: "1:1",
image_size: "2K"
}
}
})
}
);
图生图编辑
NanoBananaPro 支持图生图编辑,上传图片并提供编辑指令:
# 将图片转为 Base64
with open("input.jpg", "rb") as f:
image_base64 = base64.standard_b64encode(f.read()).decode("utf-8")
payload = {
"contents": [{
"parts": [
{"text": "把背景换成海滩"},
{"inline_data": {"mime_type": "image/jpeg", "data": image_base64}}
]
}],
"generationConfig": {
"responseModalities": ["IMAGE"]
}
}
超时建议
| 分辨率 | 建议超时时间 |
|---|---|
| 1K | 6 分钟 |
| 2K | 10 分钟 |
| 4K | 20 分钟 |
Note
4K 分辨率的 Base64 编码图片可能超过 10MB。