Provides image generation and editing capabilities using Google's Gemini 2.5 Flash Image API, including text-to-image generation, image editing with natural language instructions, multi-image composition, and support for various aspect ratios
Gemini Flash Image 2.5 Tool (Nano Banana)
A tool for generating and editing images using Google's Gemini 2.5 Flash Image API (affectionately known as "Nano Banana").
Includes both a Python CLI tool and a Model Context Protocol (MCP) server for integration with AI assistants like Claude Code.
Features
Text-to-Image Generation: Create images from text prompts
Image Editing: Modify existing images with natural language instructions
Multi-Image Composition: Combine multiple images into one
Flexible Aspect Ratios: Support for 10 different aspect ratios
Character Consistency: Maintain character appearance across multiple generations
MCP Server: Integrate with Claude Code and other MCP clients
Command-Line Interface: Easy-to-use CLI for quick operations
Python API: Use as a library in your own projects
Installation
Option 1: MCP Server (Recommended for AI Assistants)
Simplest Install (using npx)
For Claude Code MCP configuration, you can reference the package directly via GitHub:
Add to your MCP settings (~/.config/claude/claude_desktop_config.json
):
Then restart Claude Code! The generate_image
tool will be available instantly.
Local Install
The installer will:
Install Node.js dependencies
Create a
.env
file from templateRun validation tests
Show you the MCP configuration to add to Claude Code
Manual Install
Clone or download this repository
Install Node.js dependencies:
Get your API key from Google AI Studio
Create a
.env
file in the project directory:
Configure your MCP client (e.g., Claude Code):
For macOS/Linux - Add to ~/.config/claude/claude_desktop_config.json
:
For Windows - Add to %APPDATA%\Claude\claude_desktop_config.json
:
Restart Claude Code or your MCP client
Installing on Another Computer
Easiest way - Just use npx! On any computer with Node.js:
Add to Claude Code MCP settings:
No cloning needed! npx
will fetch and run it automatically.
Alternative: Local installation
Option 2: Python CLI Tool
Clone or download this repository
Install Python dependencies:
Get your API key from Google AI Studio
Create a
.env
file in the project directory:
Usage
MCP Server
Once configured, the generate_image
tool will be available in your MCP client:
Parameters:
prompt
(required): Text description of the image to generate or edits to makeoutput_path
(required): Path where the image will be saved (must end in .png)input_images
(optional): Array of paths to input images for editing/compositionaspect_ratio
(optional): One of: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9image_only
(optional): Set to true for image-only output without text
Example usage in Claude Code:
The MCP server will handle the API call and save the image automatically.
Command Line
Basic text-to-image generation:
Edit an existing image:
Compose multiple images:
Specify aspect ratio:
Image-only output (no text response):
Save full API response:
Python API
Available Aspect Ratios
1:1
- Square (default)2:3
- Portrait3:2
- Landscape3:4
- Portrait4:3
- Landscape4:5
- Portrait5:4
- Landscape9:16
- Vertical (social media)16:9
- Widescreen21:9
- Cinematic
Supported Image Formats
Input: JPG, JPEG, PNG, WebP, GIF Output: PNG
Pricing
As of 2025, Gemini 2.5 Flash Image is priced at:
$30.00 per 1 million output tokens
Each image = 1290 output tokens
Cost per image: ~$0.039
Use Cases
E-commerce: Product photography and variations
Content Creation: Social media graphics, blog images
Marketing: Ad creatives, promotional materials
Storytelling: Consistent character illustrations
Photo Editing: Background removal, color correction, object removal
Design: Logo variations, mockups, concept art
Command-Line Arguments
Error Handling
The tool includes comprehensive error handling for:
Missing API keys
Invalid image paths
Unsupported image formats
Invalid aspect ratios
API request failures
Network errors
Notes
All generated images include a SynthID watermark (added by Google)
The model benefits from Gemini's world knowledge for enhanced generation
Character consistency works best with clear, descriptive prompts
For best results, be specific in your prompts
Documentation
For more information about Gemini 2.5 Flash Image:
License
This tool is provided as-is for use with the Gemini API. See Google's terms of service for API usage restrictions.
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Tools
Enables text-to-image generation, image editing, and multi-image composition using Google's Gemini 2.5 Flash Image API. Supports flexible aspect ratios and character consistency across generations.