nano-banana
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNano Banana - Gemini Image Generation
Nano Banana - Gemini图像生成
Generate and edit images from text prompts via Google's Gemini image generation API.
通过Google的Gemini图像生成API,从文本提示生成和编辑图片。
When to Use
适用场景
- User requests image generation, creation, or production from a text description
- Editing existing images with text instructions
- Style-transfer: generate new images that match the aesthetic of a reference
- Creating illustrations for presentations, articles, thumbnails, social posts
- Batch variations of the same concept
- 用户需要根据文本描述生成、创建或制作图片
- 使用文本指令编辑现有图片
- 风格迁移:生成与参考图美学风格匹配的新图片
- 为演示文稿、文章、缩略图、社交帖子创建插图
- 批量生成同一概念的变体图片
First-Time Setup
首次设置
bash
scripts/nano_banana.py initWizard checks dependencies (sops, age, magick), verifies the API key, and saves defaults to .
~/.config/nano-banana/config.yamlbash
scripts/nano_banana.py init设置向导会检查依赖项(sops、age、magick),验证API密钥,并将默认配置保存到。
~/.config/nano-banana/config.yamlQuick Start
快速开始
bash
undefinedbash
undefinedSimple generation
简单生成
scripts/nano_banana.py "a minimalist illustration of a rocket" ./rocket.png
scripts/nano_banana.py "a minimalist illustration of a rocket" ./rocket.png
With style preset
使用风格预设
scripts/nano_banana.py --preset editorial "interconnected nodes" ./nodes.png
scripts/nano_banana.py --preset editorial "interconnected nodes" ./nodes.png
YouTube thumbnail (auto-cropped to 1280x720)
YouTube缩略图(自动裁剪为1280x720)
scripts/nano_banana.py --preset grain --platform youtube "coffee on desk" ./thumb.png
scripts/nano_banana.py --preset grain --platform youtube "coffee on desk" ./thumb.png
Generate 4 variants + contact sheet
生成4个变体图片+联络图
scripts/nano_banana.py --preset wireframe "a crystal" ./crystal.png --n 4
scripts/nano_banana.py --preset wireframe "a crystal" ./crystal.png --n 4
Edit existing image
编辑现有图片
scripts/nano_banana.py --edit ./old.png "make the background deep teal" ./new.png
scripts/nano_banana.py --edit ./old.png "make the background deep teal" ./new.png
Style reference (match aesthetic of existing image)
风格参考(匹配现有图片的美学风格)
scripts/nano_banana.py --reference ./style.png "a new mountain landscape" ./mountain.png
scripts/nano_banana.py --reference ./style.png "a new mountain landscape" ./mountain.png
Re-roll last prompt
重新生成上一个提示
scripts/nano_banana.py again
scripts/nano_banana.py again
View history
查看历史记录
scripts/nano_banana.py history -n 10
undefinedscripts/nano_banana.py history -n 10
undefinedRequirements
依赖要求
- — auto-decrypted from
GEMINI_API_KEYvia SOPS + age. Fallback:secrets.enc.yamlexport GEMINI_API_KEY=... - ,
sops— for key decryptionage - (ImageMagick) — for platform fit + contact sheets
magick - with
python3pyyaml
- — 从
GEMINI_API_KEY通过SOPS + age自动解密。备选方案:secrets.enc.yamlexport GEMINI_API_KEY=... - 、
sops— 用于密钥解密age - (ImageMagick) — 用于平台适配尺寸+联络图生成
magick - 安装的
pyyaml环境python3
Models
模型
| Model | Alias | Nano Banana Name | Use When |
|---|---|---|---|
| | Nano Banana 2 | Best instruction following, fast |
| | Nano Banana Pro | Highest quality, text in images |
| | Nano Banana (original) | Legacy |
Use via or full ID.
--model flash|pro|flash-2.5| 模型 | 别名 | Nano Banana名称 | 适用场景 |
|---|---|---|---|
| | Nano Banana 2 | 指令理解能力最佳,速度快 |
| | Nano Banana Pro | 画质最高,支持图片中生成文字 |
| | Nano Banana(初代) | 旧版本兼容 |
通过或完整模型ID调用。
--model flash|pro|flash-2.5Style Presets
风格预设
bash
scripts/nano_banana.py list-presets
scripts/nano_banana.py --preset editorial "your subject" out.png| Preset | Style |
|---|---|
| Thin lines on black, muted palette, technical diagram feel |
| White/cyan lines on dark navy, engineering drawing |
| Japanese sumi-e ink wash, organic brushstrokes, monochrome |
| Flat colors, grain, terracotta + sage, zine aesthetic |
| 3D wireframe mesh, glowing edges on black |
| Star map dots connected by faint lines, celestial |
| Bold shapes, thick borders, hard shadows, flat colors |
| Film grain photo, high ISO, warm cinematic tones |
Defined in — edit to add your own.
presets.yamlbash
scripts/nano_banana.py list-presets
scripts/nano_banana.py --preset editorial "your subject" out.png| 预设 | 风格 |
|---|---|
| 黑色背景细线条,低饱和度配色,技术图表风格 |
| 深蓝色背景白/青色线条,工程图纸风格 |
| 日本水墨风格,有机笔触,单色 |
| 平涂色彩,颗粒感,赤陶色+鼠尾草绿,zine刊物美学 |
| 3D线框网格,黑色背景发光边缘 |
| 星图点与淡线连接,天体风格 |
| 大胆形状,粗边框,硬阴影,平涂色彩 |
| 胶片颗粒感照片,高ISO,暖色调电影质感 |
风格预设定义在中,可编辑添加自定义预设。
presets.yamlPlatform Presets
平台预设
bash
scripts/nano_banana.py list-platforms
scripts/nano_banana.py --platform youtube "your subject" out.pngGenerated image is automatically resized + center-cropped to target dimensions.
| Platform | Size |
|---|---|
| 1280×720 |
| 1080×1920 |
| 1920×1080 |
| 1200×630 |
| 1600×900 |
| 1080×1080 |
| 1080×1920 |
| 1000×1500 |
bash
scripts/nano_banana.py list-platforms
scripts/nano_banana.py --platform youtube "your subject" out.png生成的图片会自动调整尺寸并居中裁剪至目标尺寸。
| 平台 | 尺寸 |
|---|---|
| 1280×720 |
| 1080×1920 |
| 1920×1080 |
| 1200×630 |
| 1600×900 |
| 1080×1080 |
| 1080×1920 |
| 1000×1500 |
Features
功能特性
Variants + Contact Sheet
变体图片+联络图
--n Nbash
scripts/nano_banana.py --preset ink "mountain" ./mt.png --n 6--n Nbash
scripts/nano_banana.py --preset ink "mountain" ./mt.png --n 6Creates mt-01.png ... mt-06.png + mt-contact.png
生成mt-01.png ... mt-06.png + mt-contact.png
undefinedundefinedEdit Mode
编辑模式
Pass an existing image and the prompt becomes the edit instruction:
bash
scripts/nano_banana.py --edit ./thumb.png "remove the watermark, warmer colors" ./clean.png传入现有图片,提示文本将作为编辑指令:
bash
scripts/nano_banana.py --edit ./thumb.png "remove the watermark, warmer colors" ./clean.pngReference Images (Style Anchor)
参考图片(风格锚定)
Use one or more reference images to guide the aesthetic without editing them:
bash
scripts/nano_banana.py --reference ./episode1.png --reference ./episode2.png \
"episode 3: data drift" ./ep3.png使用一张或多张参考图片引导生成图片的美学风格,无需编辑参考图本身:
bash
scripts/nano_banana.py --reference ./episode1.png --reference ./episode2.png \
"episode 3: data drift" ./ep3.pngProjects + Metadata
项目分类+元数据
Organize outputs by project:
bash
scripts/nano_banana.py --project lab-04/meeting-02 --preset editorial "MCP loops" ./overlay.png按项目组织输出文件:
bash
scripts/nano_banana.py --project lab-04/meeting-02 --preset editorial "MCP loops" ./overlay.pngSaves to ~/nano-banana/outputs/lab-04/meeting-02/20260414-<subject>.png + .json sidecar
保存至~/nano-banana/outputs/lab-04/meeting-02/20260414-<subject>.png + 配套.json元数据文件
undefinedundefinedRe-roll + History
重新生成+历史记录
bash
scripts/nano_banana.py again # rerun last prompt
scripts/nano_banana.py history -n 20 # show last 20 generations
scripts/nano_banana.py history --project lab-04bash
scripts/nano_banana.py again # 重新运行上一个提示
scripts/nano_banana.py history -n 20 # 显示最近20次生成记录
scripts/nano_banana.py history --project lab-04Dry Run
试运行
Preview the composed prompt without calling the API:
bash
scripts/nano_banana.py --preset editorial --platform youtube "subject" --dry-run预览组合后的提示文本,不调用API:
bash
scripts/nano_banana.py --preset editorial --platform youtube "subject" --dry-runTransient Errors & Retry
临时错误与重试
The API occasionally returns or empty candidates. The script retries up to 4 times with exponential backoff (2s, 4s, 8s, 16s). Permanent errors (4xx, safety violations) fail fast without retry.
500/INTERNALAPI偶尔会返回错误或空结果。脚本会最多重试4次,采用指数退避策略(2秒、4秒、8秒、16秒)。永久错误(4xx、安全违规)会直接失败,不进行重试。
500/INTERNALPrompt Tips
提示词技巧
- Specify visual style: "photograph", "flat illustration", "watercolor", "3D render"
- Include composition: "centered", "white background", "wide shot"
- Name colors: "blue and white color scheme", "warm earth tones"
- For text rendering, use and quote exact text:
--model pro'with the text "Hello"'
See for full API documentation.
references/api_reference.md- 指定视觉风格:比如“photograph”(照片)、“flat illustration”(扁平插画)、“watercolor”(水彩)、“3D render”(3D渲染)
- 包含构图要求:“centered”(居中)、“white background”(白色背景)、“wide shot”(宽幅镜头)
- 明确颜色:“blue and white color scheme”(蓝白配色)、“warm earth tones”(暖大地色调)
- 如需生成文字,使用并精确引用文字:
--model pro'with the text "Hello"'
完整API文档请查看。
references/api_reference.mdFiles
文件说明
- — main CLI (Python)
scripts/nano_banana.py - — thin bash wrapper (back-compat)
scripts/generate_image.sh - — style presets
presets.yaml - — platform sizing presets
platforms.yaml - — encrypted API key (SOPS + age)
secrets.enc.yaml - — user defaults (from
~/.config/nano-banana/config.yaml)init - — generation log
~/.config/nano-banana/history.jsonl - — last run (for
~/.config/nano-banana/last.json)again
- — 主CLI工具(Python编写)
scripts/nano_banana.py - — 轻量bash包装器(向后兼容)
scripts/generate_image.sh - — 风格预设配置文件
presets.yaml - — 平台尺寸预设配置文件
platforms.yaml - — 加密的API密钥(SOPS + age)
secrets.enc.yaml - — 用户默认配置(来自
~/.config/nano-banana/config.yaml命令)init - — 生成记录日志
~/.config/nano-banana/history.jsonl - — 上一次运行记录(用于
~/.config/nano-banana/last.json命令)again