nanobanana
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNano Banana
Nano Banana
A single Python entrypoint for Gemini-native Nano Banana image generation and editing, with model aliases, strict option validation, batch runs, and custom endpoint support.
一款基于Gemini原生的Nano Banana图像生成与编辑工具的Python统一入口,支持模型别名、严格参数验证、批量运行以及自定义端点功能。
Workflow
工作流程
- Open references/config.md to choose environment variables and override order.
- Open references/models-and-api.md to pick the right Nano Banana tier and check model-specific constraints.
- Prefer (
gemini-3.1-flash-image-preview) unless you need either the fastest low-cost default (nanobanana-2) or the highest-fidelity reasoning model (nanobanana).nanobanana-pro - Run for one request or
scripts/nanobanana.py generatefor repeated variants.scripts/nanobanana.py batch - Add first when the main risk is the payload shape, endpoint, or model-specific option support.
--dry-run - Pass or
--base-urlwhen you need a custom Gemini-compatible gateway.GEMINI_BASE_URL - Add on
--save-response <path>when you need the raw JSON body for debugging.generate
- 打开references/config.md选择环境变量及优先级覆盖规则。
- 打开references/models-and-api.md选择合适的Nano Banana版本,并查看模型特定约束。
- 除非你需要最快低成本的默认版本()或最高保真度的推理模型(
nanobanana),否则优先选择nanobanana-pro(对应gemini-3.1-flash-image-preview)。nanobanana-2 - 运行执行单次请求,或运行
scripts/nanobanana.py generate生成多个变体。scripts/nanobanana.py batch - 当主要风险在于请求负载格式、端点或模型特定参数支持时,先添加参数进行预演。
--dry-run - 当需要使用自定义Gemini兼容网关时,传入参数或设置
--base-url环境变量。GEMINI_BASE_URL - 在命令中添加
generate参数,可保存原始JSON响应体用于调试。--save-response <path>
Commands
命令示例
Single text-to-image request:
powershell
python .\skills\nanobanana\scripts\nanobanana.py generate `
--prompt "A retro-futurist product hero illustration for a developer tool" `
--output .\out\hero.png `
--model nanobanana-2 `
--ratio 16:9 `
--size 2KEdit an existing image with two local references:
powershell
python .\skills\nanobanana\scripts\nanobanana.py generate `
--prompt "Turn these references into a clean launch poster with legible title text" `
--input-image .\refs\subject.png `
--input-image .\refs\background.png `
--output .\out\poster.png `
--model nanobanana-pro `
--ratio 4:5 `
--size 2KUse a custom Gemini-compatible gateway:
powershell
python .\skills\nanobanana\scripts\nanobanana.py generate `
--prompt "A bold mascot sticker pack" `
--output .\out\stickers.png `
--base-url http://your-gateway.example.com/v1beta `
--auth-mode bearerBatch-generate five variants:
powershell
python .\skills\nanobanana\scripts\nanobanana.py batch `
--prompt "Minimal app icon for a PDF workflow product" `
--count 5 `
--dir .\out\icons `
--prefix icon `
--model nanobanana `
--ratio 1:1Inspect the final request without sending it:
powershell
python .\skills\nanobanana\scripts\nanobanana.py generate `
--prompt "An editorial illustration of AI agents at work" `
--model nanobanana-2 `
--output .\out\agents.png `
--dry-run单文本生成图像请求:
powershell
python .\skills\nanobanana\scripts\nanobanana.py generate `
--prompt "A retro-futurist product hero illustration for a developer tool" `
--output .\out\hero.png `
--model nanobanana-2 `
--ratio 16:9 `
--size 2K使用两张本地参考图编辑现有图像:
powershell
python .\skills\nanobanana\scripts\nanobanana.py generate `
--prompt "Turn these references into a clean launch poster with legible title text" `
--input-image .\refs\subject.png `
--input-image .\refs\background.png `
--output .\out\poster.png `
--model nanobanana-pro `
--ratio 4:5 `
--size 2K使用自定义Gemini兼容网关:
powershell
python .\skills\nanobanana\scripts\nanobanana.py generate `
--prompt "A bold mascot sticker pack" `
--output .\out\stickers.png `
--base-url http://your-gateway.example.com/v1beta `
--auth-mode bearer批量生成5个变体:
powershell
python .\skills\nanobanana\scripts\nanobanana.py batch `
--prompt "Minimal app icon for a PDF workflow product" `
--count 5 `
--dir .\out\icons `
--prefix icon `
--model nanobanana `
--ratio 1:1预演请求(不实际发送):
powershell
python .\skills\nanobanana\scripts\nanobanana.py generate `
--prompt "An editorial illustration of AI agents at work" `
--model nanobanana-2 `
--output .\out\agents.png `
--dry-runRules
规则说明
- accepts the aliases
--model,nanobanana, andnanobanana-2, or an exact Gemini model ID.nanobanana-pro - resolves to
nanobanana,gemini-2.5-flash-imageresolves tonanobanana-2, andgemini-3.1-flash-image-previewresolves tonanobanana-pro.gemini-3-pro-image-preview - is only valid on Gemini 3 image models;
image_sizerejectsnanobanana.--size - resolution is only valid on
512.nanobanana-2 - Process environment variables override ; CLI flags override both.
.env - Never print secrets.
- accepts repeated
generatepaths for image editing or multi-reference generation.--input-image - should point to the Gemini API root such as
--base-url, not directly tohttps://generativelanguage.googleapis.com/v1beta./models/... - uses
--auth-mode autofor the official Google endpoint and sends bothx-goog-api-keyandAuthorization: Bearerfor custom endpoints to maximize gateway compatibility.x-goog-api-key
- 参数接受别名
--model、nanobanana、nanobanana-2,或精确的Gemini模型ID。nanobanana-pro - 对应
nanobanana,gemini-2.5-flash-image对应nanobanana-2,gemini-3.1-flash-image-preview对应nanobanana-pro。gemini-3-pro-image-preview - 仅在Gemini 3图像模型上有效;
image_size版本不支持nanobanana参数。--size - 512分辨率仅在版本上有效。
nanobanana-2 - 环境变量会覆盖文件配置;CLI参数会同时覆盖环境变量和
.env配置。.env - 绝不打印敏感信息。
- 命令接受重复的
generate路径,用于图像编辑或多参考图生成。--input-image - 应指向Gemini API根路径,例如
--base-url,而非直接指向https://generativelanguage.googleapis.com/v1beta。/models/... - 在官方Google端点使用
--auth-mode auto,在自定义端点同时发送x-goog-api-key和Authorization: Bearer,以最大化网关兼容性。x-goog-api-key
Resources
资源链接
- Script: scripts/nanobanana.py
- Config reference: references/config.md
- Models and API reference: references/models-and-api.md
- 脚本:scripts/nanobanana.py
- 配置参考:references/config.md
- 模型与API参考:references/models-and-api.md