[!NOTE]
Nano Banana 2 (gemini-3.1-flash-image-preview) is now the default model (v1.0.11+)!You can still use the Pro model by setting the
NANOBANANA_MODELenvironment variable togemini-3-pro-image-preview.
A professional Gemini CLI extension for generating and manipulating images using the Nano Banana models.
NANOBANANA_API_KEY environment variable with your Gemini API key.
Get one from Google AI Studio.For authentication setup, see the official Gemini CLI documentation.
index.ts: MCP server using @modelcontextprotocol/sdk for professional protocol handlingimageGenerator.ts: Handles all Gemini API interactions and response processingfileHandler.ts: Manages file I/O, smart filename generation, and file searchingtypes.ts: Shared TypeScript interfaces for type safetyThe following Nano Banana models are supported:
gemini-3.1-flash-image-preview (Nano Banana 2 - default)gemini-3-pro-image-preview (Nano Banana Pro)gemini-2.5-flash-image (Nano Banana v1)The gemini-3.1-flash-image-preview model is the default. To use a different model, set the NANOBANANA_MODEL environment variable:
# Example: Use Nano Banana Pro
export NANOBANANA_MODEL=gemini-3-pro-image-preview
# Example: Use Nano Banana v1
export NANOBANANA_MODEL=gemini-2.5-flash-image
Install the extension using the gemini extensions install command:
gemini extensions install https://github.com/gemini-cli-extensions/nanobanana
Restart the Gemini CLI. The following commands will be available:
/generate - Single or multiple image generation with style/variation options/edit - Image editing/restore - Image restoration/icon - Generate app icons, favicons, and UI elements in multiple sizes/pattern - Generate seamless patterns and textures for backgrounds/story - Generate sequential images that tell a visual story or process/diagram - Generate technical diagrams, flowcharts, and architectural mockups/nanobanana - Natural language interfaceThe extension provides multiple command options for different use cases:
Generate Images:
# Single image
/generate "a watercolor painting of a fox in a snowy forest"
# Multiple variations with preview
/generate "sunset over mountains" --count=3 --preview
# Style variations
/generate "mountain landscape" --styles="watercolor,oil-painting" --count=4
# Specific variations with auto-preview
/generate "coffee shop interior" --variations="lighting,mood" --preview
Edit Images:
/edit my_photo.png "add sunglasses to the person"
/edit portrait.jpg "change background to a beach scene" --preview
Restore Images:
/restore old_family_photo.jpg "remove scratches and improve clarity"
/restore damaged_photo.png "enhance colors and fix tears" --preview
Generate Icons:
# App icon in multiple sizes
/icon "coffee cup logo" --sizes="64,128,256" --type="app-icon" --preview
# Favicon set
/icon "company logo" --type="favicon" --sizes="16,32,64"
# UI elements
/icon "settings gear icon" --type="ui-element" --style="minimal"
Create Patterns:
# Seamless pattern
/pattern "geometric triangles" --type="seamless" --style="geometric" --preview
# Background texture
/pattern "wood grain texture" --type="texture" --colors="mono"
# Wallpaper pattern
/pattern "floral design" --type="wallpaper" --density="sparse"
Generate Stories:
# Visual story sequence
/story "a seed growing into a tree" --steps=4 --type="process" --preview
# Step-by-step tutorial
/story "how to make coffee" --steps=6 --type="tutorial"
# Timeline visualization
/story "evolution of smartphones" --steps=5 --type="timeline"
Create Diagrams:
# System flowchart
/diagram "user login process" --type="flowchart" --style="professional" --preview
# Architecture diagram
/diagram "microservices architecture" --type="architecture" --complexity="detailed"
# Database schema
/diagram "e-commerce database design" --type="database" --layout="hierarchical"
Open-ended prompts:
/nanobanana create a logo for my tech startup
/nanobanana I need 5 different versions of a cat illustration in various art styles
/nanobanana fix the lighting in sunset.jpg and make it more vibrant
The /generate command supports advanced options for creating multiple variations with different styles and parameters.
--count=N - Number of variations (1-8, default: 1)
--styles="style1,style2" - Comma-separated artistic styles
--variations="var1,var2" - Specific variation types
--format=grid|separate - Output format (default: separate)
--seed=123 - Seed for reproducible variations
--preview - Automatically open generated images in default viewer
photorealistic - Photographic quality imageswatercolor - Watercolor painting styleoil-painting - Oil painting techniquesketch - Hand-drawn sketch stylepixel-art - Retro pixel art styleanime - Anime/manga art stylevintage - Vintage/retro aestheticmodern - Contemporary/modern styleabstract - Abstract art styleminimalist - Clean, minimal designlighting - Different lighting conditions (dramatic, soft)angle - Various viewing angles (above, close-up)color-palette - Different color schemes (warm, cool)composition - Different layouts (centered, rule-of-thirds)mood - Various emotional tones (cheerful, dramatic)season - Different seasons (spring, winter)time-of-day - Different times (sunrise, sunset)Style Variations:
/generate "mountain landscape" --styles="watercolor,oil-painting,sketch,photorealistic"
# Creates the same mountain scene in 4 different artistic styles
Multiple Variations:
/generate "cozy coffee shop" --variations="lighting,mood" --count=4
# Generates: dramatic lighting, soft lighting, cheerful mood, dramatic mood versions
Combined Options:
/generate "friendly robot character" --styles="anime,minimalist" --variations="color-palette"
# Creates anime and minimalist versions with different color palettes
Simple Multiple Generation:
/generate "tech startup logo" --count=6
# Generates 6 different interpretations of the same prompt
The /icon command specializes in creating app icons, favicons, and UI elements with proper sizing and formatting.
--sizes="16,32,64" - Array of icon sizes in pixels (common: 16, 32, 64, 128, 256, 512, 1024)
--type="app-icon|favicon|ui-element" - Icon type (default: app-icon)
--style="flat|skeuomorphic|minimal|modern" - Visual style (default: modern)
--format="png|jpeg" - Output format (default: png)
--background="transparent|white|black|color" - Background type (default: transparent)
--corners="rounded|sharp" - Corner style for app icons (default: rounded)
# Complete app icon set
/icon "productivity app with checklist" --sizes="64,128,256,512" --corners="rounded"
# Website favicon package
/icon "mountain logo" --type="favicon" --sizes="16,32,64" --format="png"
# UI element set
/icon "notification bell" --type="ui-element" --style="flat" --background="transparent"
The /pattern command creates seamless patterns and textures perfect for backgrounds and design elements.
--size="256x256" - Pattern tile size (common: 128x128, 256x256, 512x512)
--type="seamless|texture|wallpaper" - Pattern type (default: seamless)
--style="geometric|organic|abstract|floral|tech" - Pattern style (default: abstract)
--density="sparse|medium|dense" - Element density (default: medium)
--colors="mono|duotone|colorful" - Color scheme (default: colorful)
--repeat="tile|mirror" - Tiling method for seamless patterns (default: tile)
# Website background pattern
/pattern "subtle geometric hexagons" --type="seamless" --colors="duotone" --density="sparse"
# Material texture
/pattern "brushed metal surface" --type="texture" --style="tech" --colors="mono"
# Decorative wallpaper
/pattern "art deco design" --type="wallpaper" --style="geometric" --size="512x512"
The /story command generates sequential images that tell a visual story or demonstrate a step-by-step process.
--steps=N - Number of sequential images (2-8, default: 4)
--type="story|process|tutorial|timeline" - Sequence type (default: story)
--style="consistent|evolving" - Visual consistency across frames (default: consistent)
--layout="separate|grid|comic" - Output layout (default: separate)
--transition="smooth|dramatic|fade" - Transition style between steps (default: smooth)
--format="storyboard|individual" - Output format (default: individual)
# Product development process
/story "idea to launched product" --steps=5 --type="process" --style="consistent"
# Educational tutorial
/story "git workflow tutorial" --steps=6 --type="tutorial" --layout="comic"
# Brand evolution timeline
/story "company logo evolution" --steps=4 --type="timeline" --transition="smooth"
The /diagram command generates professional technical diagrams, flowcharts, and architectural mockups from simple text descriptions.
--type="flowchart|architecture|network|database|wireframe|mindmap|sequence" - Diagram type (default: flowchart)
--style="professional|clean|hand-drawn|technical" - Visual style (default: professional)
--layout="horizontal|vertical|hierarchical|circular" - Layout orientation (default: hierarchical)
--complexity="simple|detailed|comprehensive" - Level of detail (default: detailed)
--colors="mono|accent|categorical" - Color scheme (default: accent)
--annotations="minimal|detailed" - Label and annotation level (default: detailed)
# Development workflow
/diagram "CI/CD pipeline with testing stages" --type="flowchart" --complexity="detailed"
# System design
/diagram "chat application architecture" --type="architecture" --style="technical"
# API documentation
/diagram "REST API authentication flow" --type="sequence" --layout="vertical"
# Database design
/diagram "social media database schema" --type="database" --annotations="detailed"
Images are saved with user-friendly names based on your prompts:
"sunset over mountains" β sunset_over_mountains.png"abstract art piece" β abstract_art_piece.pngIf a file already exists, a counter is automatically added:
sunset_over_mountains.pngsunset_over_mountains_1.pngsunset_over_mountains_2.pngFor editing/restoration, the extension searches for input images in:
./images/ subdirectory./input/ subdirectory./nanobanana-output/ subdirectory~/Downloads/~/Desktop/Generated images are saved to ./nanobanana-output/ which is created automatically.
# Build the MCP server
npm run build
# Install MCP server dependencies
npm run install-deps
# Development mode with file watching
npm run dev
# Build MCP server directly
cd mcp-server && npm run build
# Start server standalone (for testing)
cd mcp-server && npm start
# Development mode with TypeScript watching
cd mcp-server && npm run dev
The extension uses the official Model Context Protocol (MCP) SDK for robust client-server communication:
@modelcontextprotocol/sdkgenerate_image, edit_image, restore_imagegemini-3.1-flash-image-preview@google/genai"Command not recognized": Ensure extension is in ~/.gemini/extensions/nanobanana-extension/ and Gemini CLI is restarted
"No API key found": Set NANOBANANA_API_KEY environment variable:
export NANOBANANA_API_KEY="your-api-key-here"
"Build failed": Ensure Node.js 18+ is installed and run:
npm run install-deps && npm run build
"Image not found": Check that input files are in one of the searched directories (see File Search Locations above)
The MCP server includes detailed debug logging that appears in the Gemini CLI console to help diagnose issues.
npm run build to ensure compilationTypeScript
51.3%
JavaScript
48.7%
[!NOTE]
Nano Banana 2 (gemini-3.1-flash-image-preview) is now the default model (v1.0.11+)!You can still use the Pro model by setting the
NANOBANANA_MODELenvironment variable togemini-3-pro-image-preview.
A professional Gemini CLI extension for generating and manipulating images using the Nano Banana models.
NANOBANANA_API_KEY environment variable with your Gemini API key.
Get one from Google AI Studio.For authentication setup, see the official Gemini CLI documentation.
index.ts: MCP server using @modelcontextprotocol/sdk for professional protocol handlingimageGenerator.ts: Handles all Gemini API interactions and response processingfileHandler.ts: Manages file I/O, smart filename generation, and file searchingtypes.ts: Shared TypeScript interfaces for type safetyThe following Nano Banana models are supported:
gemini-3.1-flash-image-preview (Nano Banana 2 - default)gemini-3-pro-image-preview (Nano Banana Pro)gemini-2.5-flash-image (Nano Banana v1)The gemini-3.1-flash-image-preview model is the default. To use a different model, set the NANOBANANA_MODEL environment variable:
# Example: Use Nano Banana Pro
export NANOBANANA_MODEL=gemini-3-pro-image-preview
# Example: Use Nano Banana v1
export NANOBANANA_MODEL=gemini-2.5-flash-image
Install the extension using the gemini extensions install command:
gemini extensions install https://github.com/gemini-cli-extensions/nanobanana
Restart the Gemini CLI. The following commands will be available:
/generate - Single or multiple image generation with style/variation options/edit - Image editing/restore - Image restoration/icon - Generate app icons, favicons, and UI elements in multiple sizes/pattern - Generate seamless patterns and textures for backgrounds/story - Generate sequential images that tell a visual story or process/diagram - Generate technical diagrams, flowcharts, and architectural mockups/nanobanana - Natural language interfaceThe extension provides multiple command options for different use cases:
Generate Images:
# Single image
/generate "a watercolor painting of a fox in a snowy forest"
# Multiple variations with preview
/generate "sunset over mountains" --count=3 --preview
# Style variations
/generate "mountain landscape" --styles="watercolor,oil-painting" --count=4
# Specific variations with auto-preview
/generate "coffee shop interior" --variations="lighting,mood" --preview
Edit Images:
/edit my_photo.png "add sunglasses to the person"
/edit portrait.jpg "change background to a beach scene" --preview
Restore Images:
/restore old_family_photo.jpg "remove scratches and improve clarity"
/restore damaged_photo.png "enhance colors and fix tears" --preview
Generate Icons:
# App icon in multiple sizes
/icon "coffee cup logo" --sizes="64,128,256" --type="app-icon" --preview
# Favicon set
/icon "company logo" --type="favicon" --sizes="16,32,64"
# UI elements
/icon "settings gear icon" --type="ui-element" --style="minimal"
Create Patterns:
# Seamless pattern
/pattern "geometric triangles" --type="seamless" --style="geometric" --preview
# Background texture
/pattern "wood grain texture" --type="texture" --colors="mono"
# Wallpaper pattern
/pattern "floral design" --type="wallpaper" --density="sparse"
Generate Stories:
# Visual story sequence
/story "a seed growing into a tree" --steps=4 --type="process" --preview
# Step-by-step tutorial
/story "how to make coffee" --steps=6 --type="tutorial"
# Timeline visualization
/story "evolution of smartphones" --steps=5 --type="timeline"
Create Diagrams:
# System flowchart
/diagram "user login process" --type="flowchart" --style="professional" --preview
# Architecture diagram
/diagram "microservices architecture" --type="architecture" --complexity="detailed"
# Database schema
/diagram "e-commerce database design" --type="database" --layout="hierarchical"
Open-ended prompts:
/nanobanana create a logo for my tech startup
/nanobanana I need 5 different versions of a cat illustration in various art styles
/nanobanana fix the lighting in sunset.jpg and make it more vibrant
The /generate command supports advanced options for creating multiple variations with different styles and parameters.
--count=N - Number of variations (1-8, default: 1)
--styles="style1,style2" - Comma-separated artistic styles
--variations="var1,var2" - Specific variation types
--format=grid|separate - Output format (default: separate)
--seed=123 - Seed for reproducible variations
--preview - Automatically open generated images in default viewer
photorealistic - Photographic quality imageswatercolor - Watercolor painting styleoil-painting - Oil painting techniquesketch - Hand-drawn sketch stylepixel-art - Retro pixel art styleanime - Anime/manga art stylevintage - Vintage/retro aestheticmodern - Contemporary/modern styleabstract - Abstract art styleminimalist - Clean, minimal designlighting - Different lighting conditions (dramatic, soft)angle - Various viewing angles (above, close-up)color-palette - Different color schemes (warm, cool)composition - Different layouts (centered, rule-of-thirds)mood - Various emotional tones (cheerful, dramatic)season - Different seasons (spring, winter)time-of-day - Different times (sunrise, sunset)Style Variations:
/generate "mountain landscape" --styles="watercolor,oil-painting,sketch,photorealistic"
# Creates the same mountain scene in 4 different artistic styles
Multiple Variations:
/generate "cozy coffee shop" --variations="lighting,mood" --count=4
# Generates: dramatic lighting, soft lighting, cheerful mood, dramatic mood versions
Combined Options:
/generate "friendly robot character" --styles="anime,minimalist" --variations="color-palette"
# Creates anime and minimalist versions with different color palettes
Simple Multiple Generation:
/generate "tech startup logo" --count=6
# Generates 6 different interpretations of the same prompt
The /icon command specializes in creating app icons, favicons, and UI elements with proper sizing and formatting.
--sizes="16,32,64" - Array of icon sizes in pixels (common: 16, 32, 64, 128, 256, 512, 1024)
--type="app-icon|favicon|ui-element" - Icon type (default: app-icon)
--style="flat|skeuomorphic|minimal|modern" - Visual style (default: modern)
--format="png|jpeg" - Output format (default: png)
--background="transparent|white|black|color" - Background type (default: transparent)
--corners="rounded|sharp" - Corner style for app icons (default: rounded)
# Complete app icon set
/icon "productivity app with checklist" --sizes="64,128,256,512" --corners="rounded"
# Website favicon package
/icon "mountain logo" --type="favicon" --sizes="16,32,64" --format="png"
# UI element set
/icon "notification bell" --type="ui-element" --style="flat" --background="transparent"
The /pattern command creates seamless patterns and textures perfect for backgrounds and design elements.
--size="256x256" - Pattern tile size (common: 128x128, 256x256, 512x512)
--type="seamless|texture|wallpaper" - Pattern type (default: seamless)
--style="geometric|organic|abstract|floral|tech" - Pattern style (default: abstract)
--density="sparse|medium|dense" - Element density (default: medium)
--colors="mono|duotone|colorful" - Color scheme (default: colorful)
--repeat="tile|mirror" - Tiling method for seamless patterns (default: tile)
# Website background pattern
/pattern "subtle geometric hexagons" --type="seamless" --colors="duotone" --density="sparse"
# Material texture
/pattern "brushed metal surface" --type="texture" --style="tech" --colors="mono"
# Decorative wallpaper
/pattern "art deco design" --type="wallpaper" --style="geometric" --size="512x512"
The /story command generates sequential images that tell a visual story or demonstrate a step-by-step process.
--steps=N - Number of sequential images (2-8, default: 4)
--type="story|process|tutorial|timeline" - Sequence type (default: story)
--style="consistent|evolving" - Visual consistency across frames (default: consistent)
--layout="separate|grid|comic" - Output layout (default: separate)
--transition="smooth|dramatic|fade" - Transition style between steps (default: smooth)
--format="storyboard|individual" - Output format (default: individual)
# Product development process
/story "idea to launched product" --steps=5 --type="process" --style="consistent"
# Educational tutorial
/story "git workflow tutorial" --steps=6 --type="tutorial" --layout="comic"
# Brand evolution timeline
/story "company logo evolution" --steps=4 --type="timeline" --transition="smooth"
The /diagram command generates professional technical diagrams, flowcharts, and architectural mockups from simple text descriptions.
--type="flowchart|architecture|network|database|wireframe|mindmap|sequence" - Diagram type (default: flowchart)
--style="professional|clean|hand-drawn|technical" - Visual style (default: professional)
--layout="horizontal|vertical|hierarchical|circular" - Layout orientation (default: hierarchical)
--complexity="simple|detailed|comprehensive" - Level of detail (default: detailed)
--colors="mono|accent|categorical" - Color scheme (default: accent)
--annotations="minimal|detailed" - Label and annotation level (default: detailed)
# Development workflow
/diagram "CI/CD pipeline with testing stages" --type="flowchart" --complexity="detailed"
# System design
/diagram "chat application architecture" --type="architecture" --style="technical"
# API documentation
/diagram "REST API authentication flow" --type="sequence" --layout="vertical"
# Database design
/diagram "social media database schema" --type="database" --annotations="detailed"
Images are saved with user-friendly names based on your prompts:
"sunset over mountains" β sunset_over_mountains.png"abstract art piece" β abstract_art_piece.pngIf a file already exists, a counter is automatically added:
sunset_over_mountains.pngsunset_over_mountains_1.pngsunset_over_mountains_2.pngFor editing/restoration, the extension searches for input images in:
./images/ subdirectory./input/ subdirectory./nanobanana-output/ subdirectory~/Downloads/~/Desktop/Generated images are saved to ./nanobanana-output/ which is created automatically.
# Build the MCP server
npm run build
# Install MCP server dependencies
npm run install-deps
# Development mode with file watching
npm run dev
# Build MCP server directly
cd mcp-server && npm run build
# Start server standalone (for testing)
cd mcp-server && npm start
# Development mode with TypeScript watching
cd mcp-server && npm run dev
The extension uses the official Model Context Protocol (MCP) SDK for robust client-server communication:
@modelcontextprotocol/sdkgenerate_image, edit_image, restore_imagegemini-3.1-flash-image-preview@google/genai"Command not recognized": Ensure extension is in ~/.gemini/extensions/nanobanana-extension/ and Gemini CLI is restarted
"No API key found": Set NANOBANANA_API_KEY environment variable:
export NANOBANANA_API_KEY="your-api-key-here"
"Build failed": Ensure Node.js 18+ is installed and run:
npm run install-deps && npm run build
"Image not found": Check that input files are in one of the searched directories (see File Search Locations above)
The MCP server includes detailed debug logging that appears in the Gemini CLI console to help diagnose issues.
npm run build to ensure compilationTypeScript
51.3%
JavaScript
48.7%