nano-banana

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

nano-banana

nano-banana

AI image generation CLI. Default model: Gemini 3.1 Flash Image Preview (Nano Banana 2).
AI图像生成CLI。默认模型:Gemini 3.1 Flash Image Preview (Nano Banana 2)。

/init - First-Time Setup

/init - 首次设置

When the user says "init", "setup nano-banana", or "install nano-banana", run these commands to get the CLI tool on their machine. No sudo required.
Prerequisites: Bun must be installed. If not:
curl -fsSL https://bun.sh/install | bash
bash
undefined
当用户提到「init」、「设置nano-banana」或者「安装nano-banana」时,运行以下命令在用户设备上安装该CLI工具,无需sudo权限。
前置要求: Bun必须已安装。如果未安装,运行:
curl -fsSL https://bun.sh/install | bash
bash
undefined

1. Clone the repo

1. Clone the repo

2. Install dependencies

2. Install dependencies

cd ~/tools/nano-banana-2 && bun install
cd ~/tools/nano-banana-2 && bun install

3. Link globally (creates
nano-banana
command via Bun - no sudo)

3. Link globally (creates
nano-banana
command via Bun - no sudo)

cd ~/tools/nano-banana-2 && bun link
cd ~/tools/nano-banana-2 && bun link

4. Set up API key

4. Set up API key

mkdir -p ~/.nano-banana echo "GEMINI_API_KEY=<ask user for their key>" > ~/.nano-banana/.env

After init, the user can type `nano-banana "prompt"` from anywhere.

If `bun link` fails or the command is not found after linking, fall back to:
```bash
mkdir -p ~/.local/bin
ln -sf ~/tools/nano-banana-2/src/cli.ts ~/.local/bin/nano-banana
mkdir -p ~/.nano-banana echo "GEMINI_API_KEY=<ask user for their key>" > ~/.nano-banana/.env

初始化完成后,用户可以在任意位置输入 `nano-banana "prompt"` 执行命令。

如果`bun link`执行失败或者链接后找不到命令,使用以下备用方案:
```bash
mkdir -p ~/.local/bin
ln -sf ~/tools/nano-banana-2/src/cli.ts ~/.local/bin/nano-banana

Then ensure ~/.local/bin is on PATH:

Then ensure ~/.local/bin is on PATH:

echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc source ~/.zshrc

Get a Gemini API key at: https://aistudio.google.com/apikey
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc source ~/.zshrc

获取Gemini API Key的地址:https://aistudio.google.com/apikey

Quick Reference

快速参考

  • Command:
    nano-banana "prompt" [options]
  • Default: 1K resolution, Flash model, current directory
  • 命令:
    nano-banana "prompt" [options]
  • 默认配置:1K分辨率,Flash模型,输出到当前目录

Core Options

核心选项

OptionDefaultDescription
-o, --output
nano-gen-{timestamp}
Output filename (no extension)
-s, --size
1K
Image size:
512
,
1K
,
2K
, or
4K
-a, --aspect
model defaultAspect ratio:
1:1
,
16:9
,
9:16
,
4:3
,
3:4
, etc.
-m, --model
flash
Model:
flash
/
nb2
,
pro
/
nb-pro
, or any model ID
-d, --dir
current directoryOutput directory
-r, --ref
-Reference image (can use multiple times)
-t, --transparent
-Generate on green screen, remove background (FFmpeg)
--api-key
-Gemini API key (overrides env/file)
--costs
-Show cost summary
选项默认值描述
-o, --output
nano-gen-{timestamp}
输出文件名(无需后缀)
-s, --size
1K
图像尺寸:
512
1K
2K
4K
-a, --aspect
模型默认值宽高比:
1:1
16:9
9:16
4:3
3:4
-m, --model
flash
模型:
flash
/
nb2
pro
/
nb-pro
,或任意模型ID
-d, --dir
当前目录输出目录
-r, --ref
-参考图(可多次使用)
-t, --transparent
-基于绿幕生成,自动去除背景(依赖FFmpeg)
--api-key
-Gemini API Key(覆盖环境变量/配置文件设置)
--costs
-展示成本汇总

Models

支持的模型

AliasModelUse When
flash
,
nb2
Gemini 3.1 FlashDefault. Fast, cheap (~$0.067/1K image)
pro
,
nb-pro
Gemini 3 ProHighest quality needed (~$0.134/1K image)
别名对应模型使用场景
flash
,
nb2
Gemini 3.1 Flash默认选项,速度快、成本低(生成1K图像约$0.067/张)
pro
,
nb-pro
Gemini 3 Pro需要最高生成质量时使用(生成1K图像约$0.134/张)

Sizes

尺寸规格

SizeCost (Flash)Cost (Pro)
512
~$0.045Flash only
1K
~$0.067~$0.134
2K
~$0.101~$0.201
4K
~$0.151~$0.302
尺寸Flash模型成本Pro模型成本
512
约$0.045仅支持Flash模型
1K
约$0.067约$0.134
2K
约$0.101约$0.201
4K
约$0.151约$0.302

Aspect Ratios

支持的宽高比

Supported:
1:1
,
16:9
,
9:16
,
4:3
,
3:4
,
3:2
,
2:3
,
4:5
,
5:4
,
21:9
Use
-a
flag:
nano-banana "cinematic scene" -a 16:9
支持:
1:1
16:9
9:16
4:3
3:4
3:2
2:3
4:5
5:4
21:9
使用
-a
参数指定:
nano-banana "cinematic scene" -a 16:9

Key Workflows

核心工作流

Basic Generation

基础生成

bash
nano-banana "minimal dashboard UI with dark theme"
nano-banana "cinematic landscape" -s 2K -a 16:9
nano-banana "quick concept sketch" -s 512
bash
nano-banana "minimal dashboard UI with dark theme"
nano-banana "cinematic landscape" -s 2K -a 16:9
nano-banana "quick concept sketch" -s 512

Model Selection

模型选择

bash
undefined
bash
undefined

Default (Flash - fast, cheap)

默认(Flash - 速度快、成本低)

nano-banana "your prompt"
nano-banana "your prompt"

Pro (highest quality)

Pro(最高质量)

nano-banana "detailed portrait" --model pro -s 2K
undefined
nano-banana "detailed portrait" --model pro -s 2K
undefined

Reference Images (Style Transfer / Editing)

参考图(风格迁移/编辑)

bash
undefined
bash
undefined

Edit existing image

编辑现有图像

nano-banana "change the background to pure white" -r dark-ui.png -o light-ui
nano-banana "change the background to pure white" -r dark-ui.png -o light-ui

Style transfer - multiple references

风格迁移 - 多张参考图

nano-banana "combine these two styles" -r style1.png -r style2.png -o combined
undefined
nano-banana "combine these two styles" -r style1.png -r style2.png -o combined
undefined

Transparent Assets

透明素材生成

bash
nano-banana "robot mascot character" -t -o mascot
nano-banana "pixel art treasure chest" -t -o chest
The
-t
flag automatically prompts the AI to generate on a green screen, then uses FFmpeg
colorkey
+
despill
to key out the background and remove green spill from edge pixels. Pixel-perfect transparency with no manual prompting needed.
Requires:
brew install ffmpeg imagemagick
bash
nano-banana "robot mascot character" -t -o mascot
nano-banana "pixel art treasure chest" -t -o chest
-t
参数会自动要求AI在绿幕背景下生成图像,然后使用FFmpeg的
colorkey
+
despill
功能扣除背景,同时去除边缘像素的绿色溢色,无需手动调整提示词即可获得像素级精准的透明背景。
依赖要求:
brew install ffmpeg imagemagick

Exact Dimensions

精确尺寸控制

To get a specific output dimension:
  1. First
    -r
    flag: your reference/style image
  2. Last
    -r
    flag: blank image in target dimensions
  3. Include dimensions in prompt
bash
nano-banana "pixel art character in style of first image, 256x256" -r style.png -r blank-256x256.png -o sprite
如需生成指定尺寸的图像:
  1. 第一个
    -r
    参数:传入你的参考/风格图
  2. 最后一个
    -r
    参数:传入目标尺寸的空白图像
  3. 在提示词中说明所需尺寸
bash
nano-banana "pixel art character in style of first image, 256x256" -r style.png -r blank-256x256.png -o sprite

Reference Order Matters

参考图顺序规则

  • First reference: primary style/content source
  • Additional references: secondary influences
  • Last reference: controls output dimensions (if using blank image trick)
  • 第一张参考图:主要风格/内容来源
  • 额外参考图:次要风格影响
  • 最后一张参考图:如果使用空白图技巧,会控制输出图像的尺寸

Cost Tracking

成本追踪

Every generation is logged to
~/.nano-banana/costs.json
. View summary:
bash
nano-banana --costs
每次生成记录都会写入
~/.nano-banana/costs.json
,查看成本汇总:
bash
nano-banana --costs

Use Cases

使用场景

  • Landing page assets - product mockups, UI previews
  • Image editing - transform existing images with prompts
  • Style transfer - combine multiple reference images
  • Marketing materials - hero images, feature illustrations
  • UI iterations - quickly generate variations of designs
  • Transparent assets - icons, logos, mascots with no background
  • Game assets - sprites, backgrounds, characters
  • Video production - visual elements for video compositions
  • 落地页素材 - 产品原型、UI预览图
  • 图像编辑 - 通过提示词修改现有图像
  • 风格迁移 - 融合多张参考图的风格
  • 营销物料 - 头图、功能插画
  • UI迭代 - 快速生成多种设计变体
  • 透明素材 - 无背景的图标、Logo、吉祥物
  • 游戏素材 - 精灵图、背景、角色
  • 视频制作 - 视频合成用的视觉元素

Prompt Examples

提示词示例

bash
undefined
bash
undefined

UI mockups

UI原型

nano-banana "clean SaaS dashboard with analytics charts, white background"
nano-banana "clean SaaS dashboard with analytics charts, white background"

Widescreen cinematic

宽屏电影质感

nano-banana "cyberpunk cityscape at sunset" -a 16:9 -s 2K
nano-banana "cyberpunk cityscape at sunset" -a 16:9 -s 2K

Product shots with Pro quality

Pro级质量产品图

nano-banana "premium software product hero image" --model pro
nano-banana "premium software product hero image" --model pro

Quick low-res concept

快速低清概念图

nano-banana "rough sketch of a robot" -s 512
nano-banana "rough sketch of a robot" -s 512

Dark mode UI

暗色模式UI

nano-banana "Premium SaaS chat interface, dark mode, minimal, Linear-style aesthetic"
nano-banana "Premium SaaS chat interface, dark mode, minimal, Linear-style aesthetic"

Game assets with transparency (green screen auto-prompted)

带透明背景的游戏素材(自动触发绿幕生成逻辑)

nano-banana "pixel art treasure chest" -t -o chest
nano-banana "pixel art treasure chest" -t -o chest

Portrait aspect ratio

竖屏比例

nano-banana "mobile app onboarding screen" -a 9:16
undefined
nano-banana "mobile app onboarding screen" -a 9:16
undefined

API Key Setup

API Key设置规则

The CLI resolves the Gemini API key in this order:
  1. --api-key
    flag
  2. GEMINI_API_KEY
    environment variable
  3. .env
    file in current directory
  4. .env
    file next to the CLI script
  5. ~/.nano-banana/.env
CLI会按以下优先级读取Gemini API Key:
  1. --api-key
    参数传入的值
  2. GEMINI_API_KEY
    环境变量
  3. 当前目录下的
    .env
    文件
  4. CLI脚本同级目录下的
    .env
    文件
  5. ~/.nano-banana/.env
    文件