nano-banana

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Nano Banana Image Generation & Editing

Nano Banana图像生成与编辑

Generate new images or edit existing ones using Google's Gemini image API.
Default model: Nano Banana 2 (
gemini-3.1-flash-image-preview
) — cheaper, faster, more features. Legacy model: Nano Banana Pro (
gemini-3-pro-image-preview
) — available via
--model nano-banana-pro
, deprecated 9 March 2026.
使用Google的Gemini图像API生成新图像或编辑现有图像。
默认模型: Nano Banana 2(
gemini-3.1-flash-image-preview
)——成本更低、速度更快、功能更多。 旧版模型: Nano Banana Pro(
gemini-3-pro-image-preview
)——可通过
--model nano-banana-pro
参数使用,将于2026年3月9日停止支持。

Usage

使用说明

Run the script using absolute path (do NOT cd to skill directory first):
Generate new image:
bash
uv run ~/.claude/skills/nano-banana/scripts/generate_image.py --prompt "your image description" --filename "output.png" [--resolution 0.5K|1K|2K|4K] [--aspect-ratio 16:9] [--thinking high] [--api-key KEY]
Edit existing image:
bash
uv run ~/.claude/skills/nano-banana/scripts/generate_image.py --prompt "editing instructions" --filename "output.png" --input-image "path/to/input.png" [--resolution 0.5K|1K|2K|4K] [--api-key KEY]
Multi-reference generation (up to 14 images):
bash
uv run ~/.claude/skills/nano-banana/scripts/generate_image.py --prompt "combine these styles" --filename "output.png" --input-image "ref1.png" --input-image "ref2.png"
Important: Always run from the user's current working directory so images are saved where the user is working, not in the skill directory.
使用绝对路径运行脚本(请勿先cd到技能目录):
生成新图像:
bash
uv run ~/.claude/skills/nano-banana/scripts/generate_image.py --prompt "your image description" --filename "output.png" [--resolution 0.5K|1K|2K|4K] [--aspect-ratio 16:9] [--thinking high] [--api-key KEY]
编辑现有图像:
bash
uv run ~/.claude/skills/nano-banana/scripts/generate_image.py --prompt "editing instructions" --filename "output.png" --input-image "path/to/input.png" [--resolution 0.5K|1K|2K|4K] [--api-key KEY]
多参考图生成(最多14张图像):
bash
uv run ~/.claude/skills/nano-banana/scripts/generate_image.py --prompt "combine these styles" --filename "output.png" --input-image "ref1.png" --input-image "ref2.png"
重要提示: 请始终在用户当前工作目录下运行脚本,这样图像会保存在用户正在操作的目录下,而非技能目录中。

Model Selection

模型选择

Flag valueModel IDNotes
nano-banana-2
(default)
gemini-3.1-flash-image-preview
Cheaper, faster, 0.5K support, aspect ratio, thinking, 14 ref images
nano-banana-pro
gemini-3-pro-image-preview
Deprecated 9 March 2026
参数值模型ID备注
nano-banana-2
(默认)
gemini-3.1-flash-image-preview
成本更低、速度更快,支持0.5K分辨率、宽高比设置、思考级别调整、最多14张参考图
nano-banana-pro
gemini-3-pro-image-preview
2026年3月9日停止支持

Resolution Options

分辨率选项

Uppercase K required:
  • 0.5K — ~512px (cheapest, Nano Banana 2 only)
  • 1K (default) — ~1024px
  • 2K — ~2048px
  • 4K — ~4096px
Map user requests:
  • "thumbnail", "small", "cheap", "low resolution" →
    0.5K
  • No mention / "1080", "1080p", "1K" →
    1K
  • "2K", "2048", "medium resolution" →
    2K
  • "high resolution", "high-res", "hi-res", "4K", "ultra" →
    4K
When editing, resolution auto-detects from input image size if not specified.
必须使用大写的K:
  • 0.5K — ~512px(成本最低,仅Nano Banana 2支持)
  • 1K (默认) — ~1024px
  • 2K — ~2048px
  • 4K — ~4096px
用户请求映射规则:
  • “缩略图”、“小尺寸”、“低成本”、“低分辨率” →
    0.5K
  • 未说明/“1080”、“1080p”、“1K” →
    1K
  • “2K”、“2048”、“中等分辨率” →
    2K
  • “高分辨率”、“high-res”、“hi-res”、“4K”、“超清” →
    4K
编辑图像时如果未指定分辨率,会自动根据输入图像的尺寸检测分辨率。

Aspect Ratio

宽高比

14 supported ratios (Nano Banana 2 only). Omit to let the API decide.
Map user requests:
  • "landscape", "wide" →
    16:9
  • "portrait", "phone", "story", "reel" →
    9:16
  • "square" →
    1:1
  • "cinematic", "ultrawide" →
    21:9
  • "photo portrait" →
    3:4
    or
    2:3
支持14种宽高比(仅Nano Banana 2支持),不指定的话将由API自动决定。
用户请求映射规则:
  • “横版”、“宽屏” →
    16:9
  • “竖版”、“手机端”、“故事”、“短视频” →
    9:16
  • “正方形” →
    1:1
  • “电影感”、“超宽屏” →
    21:9
  • “人像照片” →
    3:4
    2:3

Thinking

思考级别

Controls reasoning effort for complex prompts (Nano Banana 2 only). Omit for fastest/cheapest.
  • --thinking minimal
    — slightly better quality, low latency impact
  • --thinking high
    — best for complex composition, text rendering, detailed scenes
Note: thinking tokens are billed regardless of level.
控制处理复杂提示词的推理投入(仅Nano Banana 2支持),不指定的话将采用最快/最低成本的模式。
  • --thinking minimal
    — 画质小幅提升,延迟影响小
  • --thinking high
    — 最适合复杂构图、文字渲染、细节丰富的场景
注意:无论选择哪个级别,思考token都会正常计费。

Reference Images

参考图像

Up to 14 input images via repeated
--input-image
flags. Use cases:
  • Style transfer — provide style reference + subject
  • Character consistency — provide character reference images
  • Object reference — provide object images to include
  • Image editing — provide single image + editing instructions in prompt
Resolution auto-detects from the first input image when
--resolution
not specified.
通过重复传入
--input-image
参数最多可添加14张输入图像,适用场景:
  • 风格迁移——提供风格参考图+主体图
  • 人物一致性——提供人物参考图像
  • 物体参考——提供要包含的物体图像
  • 图像编辑——提供单张图像+提示词中的编辑指令
未指定
--resolution
时,会自动根据第一张输入图像检测分辨率。

API Key

API Key

Checked in order:
  1. --api-key
    argument
  2. GEMINI_API_KEY
    environment variable
按以下顺序读取:
  1. --api-key
    参数
  2. GEMINI_API_KEY
    环境变量

Filename Generation

文件名生成规则

Pattern:
yyyy-mm-dd-hh-mm-ss-name.png
  • Timestamp: current date/time, 24-hour format
  • Name: descriptive lowercase with hyphens (1-5 words)
  • Unclear context: use random identifier (e.g.,
    x9k2
    )
Examples:
  • "A serene Japanese garden" →
    2026-03-01-14-23-05-japanese-garden.png
  • Unclear →
    2026-03-01-17-12-48-x9k2.png
命名模式:
yyyy-mm-dd-hh-mm-ss-name.png
  • 时间戳:当前日期时间,24小时制
  • 名称:描述性小写字母+连字符(1-5个单词)
  • 上下文不明确时:使用随机标识符(例如
    x9k2
示例:
  • “静谧的日式花园” →
    2026-03-01-14-23-05-japanese-garden.png
  • 上下文不明确 →
    2026-03-01-17-12-48-x9k2.png

Image Editing

图像编辑

  1. Check if user provides an image path or references an image in the current directory
  2. Use
    --input-image
    with the path
  3. Pass editing instructions in
    --prompt
  4. Common tasks: add/remove elements, change style, adjust colours, blur background
  1. 检查用户是否提供了图像路径,或者引用了当前目录下的图像
  2. --input-image
    参数中传入路径
  3. --prompt
    参数中传入编辑指令
  4. 常见任务:添加/移除元素、更改风格、调整颜色、模糊背景

Prompt Handling

提示词处理

For generation: Pass user's image description as-is to
--prompt
. Only rework if clearly insufficient.
For editing: Pass editing instructions in
--prompt
(e.g., "add a rainbow in the sky", "make it look like a watercolour painting")
Preserve user's creative intent in both cases.
生成场景: 将用户的图像描述原样传入
--prompt
参数,仅在描述明显不完整时才进行调整。
编辑场景: 将编辑指令传入
--prompt
参数(例如“在天空中添加一道彩虹”、“改成水彩画风格”)
两种场景都要保留用户的创作意图。

Output

输出

  • Saves PNG to current directory (or specified path if filename includes directory)
  • Script outputs the full path to the generated image
  • Do not read the image back — just inform the user of the saved path
  • 将PNG文件保存到当前目录(如果文件名包含路径则保存到指定路径)
  • 脚本会输出生成图像的完整路径
  • 请勿回读图像——只需告知用户保存路径即可

Pricing (Paid Tier Only)

定价(仅付费层级)

No free tier for image generation.
图像生成无免费额度。

Nano Banana 2 (
gemini-3.1-flash-image-preview
) — default

Nano Banana 2(
gemini-3.1-flash-image-preview
)——默认

ResolutionStandardBatch
0.5K (512px)$0.045$0.022
1K$0.067$0.034
2K$0.101$0.050
4K$0.151$0.076
Google Search grounding: 5,000 prompts/month free, then $14/1,000 queries.
分辨率标准价批量价
0.5K (512px)$0.045$0.022
1K$0.067$0.034
2K$0.101$0.050
4K$0.151$0.076
谷歌搜索 grounding:每月前5000次提示免费,超出后按14美元/1000次查询计费。

Nano Banana Pro (
gemini-3-pro-image-preview
) — deprecated 9 Mar 2026

Nano Banana Pro(
gemini-3-pro-image-preview
)——2026年3月9日停止支持

ComponentStandardBatch
Input (per image)$0.0011$0.0006
Output 1K/2K$0.134$0.067
Output 4K$0.24$0.12
计费项标准价批量价
输入(每张图像)$0.0011$0.0006
输出 1K/2K$0.134$0.067
输出 4K$0.24$0.12

Examples

示例

Generate with aspect ratio:
bash
uv run ~/.claude/skills/nano-banana/scripts/generate_image.py --prompt "Cinematic landscape at golden hour" --filename "2026-03-01-10-00-00-landscape.png" --resolution 2K --aspect-ratio 21:9
Generate with thinking for complex prompt:
bash
uv run ~/.claude/skills/nano-banana/scripts/generate_image.py --prompt "A detailed infographic about climate change with text labels" --filename "2026-03-01-10-05-00-infographic.png" --thinking high --resolution 4K
Multi-reference style transfer:
bash
uv run ~/.claude/skills/nano-banana/scripts/generate_image.py --prompt "A portrait in this artistic style" --filename "2026-03-01-10-10-00-styled-portrait.png" --input-image "style-ref.png" --input-image "subject.png"
Budget thumbnail:
bash
uv run ~/.claude/skills/nano-banana/scripts/generate_image.py --prompt "Simple icon of a house" --filename "2026-03-01-10-15-00-house-icon.png" --resolution 0.5K
Edit existing image:
bash
uv run ~/.claude/skills/nano-banana/scripts/generate_image.py --prompt "make the sky more dramatic with storm clouds" --filename "2026-03-01-14-25-30-dramatic-sky.png" --input-image "original-photo.jpg" --resolution 2K
Use legacy model:
bash
uv run ~/.claude/skills/nano-banana/scripts/generate_image.py --prompt "A serene Japanese garden" --filename "2026-03-01-14-23-05-japanese-garden.png" --model nano-banana-pro --resolution 4K
指定宽高比生成:
bash
uv run ~/.claude/skills/nano-banana/scripts/generate_image.py --prompt "Cinematic landscape at golden hour" --filename "2026-03-01-10-00-00-landscape.png" --resolution 2K --aspect-ratio 21:9
复杂提示词指定思考级别生成:
bash
uv run ~/.claude/skills/nano-banana/scripts/generate_image.py --prompt "A detailed infographic about climate change with text labels" --filename "2026-03-01-10-05-00-infographic.png" --thinking high --resolution 4K
多参考图风格迁移:
bash
uv run ~/.claude/skills/nano-banana/scripts/generate_image.py --prompt "A portrait in this artistic style" --filename "2026-03-01-10-10-00-styled-portrait.png" --input-image "style-ref.png" --input-image "subject.png"
低成本缩略图生成:
bash
uv run ~/.claude/skills/nano-banana/scripts/generate_image.py --prompt "Simple icon of a house" --filename "2026-03-01-10-15-00-house-icon.png" --resolution 0.5K
编辑现有图像:
bash
uv run ~/.claude/skills/nano-banana/scripts/generate_image.py --prompt "make the sky more dramatic with storm clouds" --filename "2026-03-01-14-25-30-dramatic-sky.png" --input-image "original-photo.jpg" --resolution 2K
使用旧版模型:
bash
uv run ~/.claude/skills/nano-banana/scripts/generate_image.py --prompt "A serene Japanese garden" --filename "2026-03-01-14-23-05-japanese-garden.png" --model nano-banana-pro --resolution 4K