nano banana 2
by @gybin02
Generate/edit images with Nano Banana 2 (Gemini 3.1 Flash Image). Use for image create/modify requests incl. edits. Supports text-to-image + image-to-image;...
clawhub install nano-banana-2-proš About This Skill
name: nano-banana-2 description: Generate/edit images with Nano Banana 2 (Gemini 3.1 Flash Image). Use for image create/modify requests incl. edits. Supports text-to-image + image-to-image; 512/1K/2K/4K; 14 aspect ratios; up to 14 input images; thinking levels; use --input-image.
Nano Banana 2 Image Generation & Editing
Generate new images or edit existing ones using Google's Nano Banana 2 API (Gemini 3.1 Flash Image Preview).
Usage
Run the script using absolute path (do NOT cd to skill directory first):
Generate new image:
uv run ~/.codex/skills/nano-banana-pro/scripts/generate_image.py --prompt "your image description" --filename "output.png" [--model MODEL] [--resolution 512|1K|2K|4K] [--aspect-ratio RATIO] [--thinking-level minimal|high] [--image-only] [--api-key KEY]
Edit existing image:
uv run ~/.codex/skills/nano-banana-pro/scripts/generate_image.py --prompt "editing instructions" --filename "output.png" --input-image "path/to/input.png" [--model MODEL] [--resolution 512|1K|2K|4K] [--aspect-ratio RATIO] [--api-key KEY]
Multiple input images (up to 14):
uv run ~/.codex/skills/nano-banana-pro/scripts/generate_image.py --prompt "combine these elements" --filename "output.png" --input-image "img1.png" "img2.png" "img3.png" [--model MODEL] [--resolution 2K] [--api-key KEY]
Important: Always run from the user's current working directory so images are saved where the user is working, not in the skill directory.
Default Workflow (draft ā iterate ā final)
Goal: fast iteration without burning time on 4K until the prompt is correct.
uv run ~/.codex/skills/nano-banana-pro/scripts/generate_image.py --prompt "" --filename "yyyy-mm-dd-hh-mm-ss-draft.png" --resolution 1K
--input-image for every iteration until you're happy.
uv run ~/.codex/skills/nano-banana-pro/scripts/generate_image.py --prompt "" --filename "yyyy-mm-dd-hh-mm-ss-final.png" --resolution 4K Model Selection
Use --model to specify the Gemini model. Default: gemini-3.1-flash-image-preview.
Available models:
| Model ID | å«å | å辨ē | 宽é«ęÆ | å¤å¾č¾å
„ | Thinking | Google Search Grounding | ē¹ē¹ |
|---|---|---|---|---|---|---|---|
| gemini-3.1-flash-image-preview | Nano Banana 2 | 512 / 1K / 2K / 4K | 14 ē§ļ¼å« 1:4, 4:1, 1:8, 8:1ļ¼ | ęå¤ 14 å¼ ļ¼10 ē©ä½ + 4 č§č²ļ¼ | minimal / high | Web Search + Image Search | éåŗ¦/蓨é/ęę¬ę佳平蔔ļ¼é»č®¤ęØč |
| gemini-3-pro-image-preview | Nano Banana Pro | 1K / 2K / 4K | 10 ē§ | ęå¤ 11 å¼ ļ¼6 ē©ä½ + 5 č§č²ļ¼ | é»č®¤å¼åÆļ¼äøåÆå
³éļ¼ | Web Search | äøäøē“ ęå¶ä½ļ¼é«ēŗ§ęØēļ¼é«äæēęåęø²ę |
| gemini-2.5-flash-image | Nano Banana | ä»
1Kļ¼1024pxļ¼ | 9 ē§ | ęå¤ 3 å¼ | äøęÆę | äøęÆę | ęåæ«ę便å®ļ¼éåé«å¹¶åä½å»¶čæåŗęÆ |
Map user requests:
gemini-3.1-flash-image-previewgemini-3-pro-image-previewgemini-2.5-flash-imageResolution Options
Gemini 3.1 Flash Image supports four resolutions (uppercase K required, except 512):
Map user requests to API parameters:
1K5121K2K4KAspect Ratio Options
14 aspect ratios supported. Use --aspect-ratio to set:
Map user requests:
1:13:4 or 9:164:3 or 16:916:9 or 21:99:1621:91:4 or 1:84:1 or 8:1If no --aspect-ratio is specified, the model defaults to matching the input image's ratio, or 1:1 for text-to-image.
Thinking Level
Control the model's reasoning depth with --thinking-level:
Use high for complex scenes, detailed compositions, or when quality matters more than speed. The model always uses some thinking internally; minimal just reduces it.
Multiple Input Images
Nano Banana 2 supports up to 14 reference images in a single request:
Use cases:
Example:
uv run ~/.codex/skills/nano-banana-pro/scripts/generate_image.py \
--prompt "An office group photo of these people, they are making funny faces" \
--input-image person1.png person2.png person3.png person4.png \
--filename "2026-03-24-10-00-00-group-photo.png" \
--resolution 2K --aspect-ratio 5:4
Image-Only Mode
Use --image-only to suppress text in the response and return only the generated image. Useful when you don't need the model's text commentary.
uv run ~/.codex/skills/nano-banana-pro/scripts/generate_image.py --prompt "a sunset" --filename "sunset.png" --image-only
API Key
The script checks for API key in this order:
1. --api-key argument (use if user provided key in chat)
2. GEMINI_API_KEY environment variable
If neither is available, the script exits with an error message.
Preflight + Common Failures (fast fixes)
command -v uv (must exist)
- test -n "$GEMINI_API_KEY" (or pass --api-key)
- If editing: test -f "path/to/input.png"Error: No API key provided. ā set GEMINI_API_KEY or pass --api-key
- Error loading input image: ā wrong path / unreadable file; verify --input-image points to a real image
- Maximum 14 input images supported. ā reduce the number of input images
- "quota/permission/403" style API errors ā wrong key, no access, or quota exceeded; try a different key/accountFilename Generation
Generate filenames with the pattern: yyyy-mm-dd-hh-mm-ss-name.png
Format: {timestamp}-{descriptive-name}.png
yyyy-mm-dd-hh-mm-ss (24-hour format)x9k2, a7b3)Examples:
2025-11-23-14-23-05-japanese-garden.png2025-11-23-15-30-12-sunset-mountains.png2025-11-23-16-45-33-robot.png2025-11-23-17-12-48-x9k2.pngImage Editing
When the user wants to modify an existing image:
1. Check if they provide an image path or reference an image in the current directory
2. Use --input-image parameter with the path to the image
3. The prompt should contain editing instructions (e.g., "make the sky more dramatic", "remove the person", "change to cartoon style")
4. Common editing tasks: add/remove elements, change style, adjust colors, blur background, inpainting, style transfer, sketch-to-photo, etc.
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 watercolor painting")
Preserve user's creative intent in both cases.
Prompt Templates (high hit-rate)
Use templates when the user is vague or when edits must be precise.