ComfyUI Extension: Comfy Nano Banana
Run ComfyUI workflows without the setup
No installs, no CUDA version roulette, no GPU sitting idle on your bill. Bring a workflow and run it in the browser.
Google Gemini API integration for ComfyUI - Generate images and text using Google's latest AI models. Provides nodes for Gemini API interactions and batch image processing.
Looking for a different extension?
Custom Nodes (0)
README
Comfy Nano Banana
Google Gemini API integration for ComfyUI focused on Gemini image generation and editing models, plus a dynamic batch images utility node.
Features
- π¨ Image Generation - Create and edit images with Gemini's current Nano Banana image models
- π Text Responses - Capture any text returned alongside generated images
- πΌοΈ Multimodal Support - Use images as input context for image generation and editing
- π Concurrent Batch Processing - Generate 1-4 images concurrently with progress tracking
- π Dynamic Batch Images - Combine multiple images into a single batch with automatic resizing
- π Secure API Key Handling - Password field masking with smart export behavior
- β‘ Smart Model Detection - Automatically uses the right generation method based on model
- π Nano Banana Pro + Nano Banana 2 - Supports the latest Gemini 3 image generation tiers
Demo
Watch the Comfy Nano Banana custom node in action:
Installation
Via ComfyUI Manager (Recommended)
- Install ComfyUI
- Install ComfyUI-Manager
- Search for "Nano Banana" in ComfyUI-Manager and install
- Restart ComfyUI
Manual Installation
cd ComfyUI/custom_nodes
git clone https://github.com/darkamenosa/comfy_nanobanana.git
cd comfy_nanobanana
pip install -r requirements.txt
Setup
- Get a Gemini API key from Google AI Studio
- Set your API key:
- Option 1: Set environment variable
GEMINI_API_KEY - Option 2: Enter directly in the node's API key field
- Option 1: Set environment variable
Security & API Key Handling
π Smart Export Behavior
This node implements intelligent API key handling for different export scenarios:
Regular Workflow Export (Save Workflow)
- API keys are automatically removed when saving workflows
- Safe for sharing workflows publicly without exposing sensitive credentials
- Recipients must enter their own API key or use environment variables
- Prevents accidental API key exposure when sharing on forums, GitHub, etc.
API Format Export (Save as API - Developer Mode)
- API keys are preserved in the exported JSON
- Designed for developers deploying workflows programmatically
- Convenient for production deployments and automation
- β οΈ Developer Warning: Only share API format exports with trusted parties or systems
Best Practices
- Use environment variable
GEMINI_API_KEYfor production deployments - Always review exported files before sharing publicly
- For public workflow sharing, use regular "Save Workflow" option
- For private/automated use, API format export maintains convenience
Usage
The extension adds two nodes to ComfyUI:
1. Nano Banana Gemini Node
Located under the "Nano Banana" category, this node interfaces with Google's Gemini API.
Inputs
- prompt (required): Text prompt for generation
- model: Gemini image model to use (default:
Nano Banana) - batch_size: Number of images to generate concurrently (1-4)
- seed: For reproducible outputs (0-2147483647)
- system_prompt (optional): Instructions to guide the model's behavior
- images (optional): Input images for context
- api_key (optional): Override environment variable
- aspect_ratio (optional): Image output ratio for image models (
auto,1:1,16:9, etc.) - image_size (optional): Output resolution for Gemini 3 image models (
auto,512px,1K,2K,4K)
Outputs
- images: Generated or edited image batch
- text: Text response from the model
Supported Models
Nano Banana(gemini-2.5-flash-image)Nano Banana Pro(gemini-3-pro-image-preview)Nano Banana 2(gemini-3.1-flash-image-preview)
Existing workflows that still store raw Gemini model IDs continue to work. The legacy gemini-2.5-flash-image-preview value is also accepted as an alias for Nano Banana.
2. Batch Images Node
Located under the "image" category, this utility node dynamically combines multiple images into a single batch.
Features
- Dynamic Inputs: Automatically adds/removes image inputs as you connect/disconnect
- Auto-resize: Mismatched images are automatically resized to match the first image's dimensions
- Clean Interface: Unused inputs are automatically removed
- Flexible: Connect any number of images from different sources
How to Use
- Add "Batch Images" node from the image category
- Connect your first image - the node automatically creates a new input
- Connect additional images - each connection creates a new input slot
- Disconnecting removes the unused input automatically
- All images are resized to match the first image's dimensions and combined into a batch
Examples
Image Generation
- Add "Nano Banana Gemini" node
- Enter a prompt like "A cat wearing a wizard hat"
- Connect output to Preview Image node
Batch Image Generation
- Add "Nano Banana Gemini" node
- Set batch_size to 4
- Enter your prompt
- Get 4 variations generated concurrently with progress tracking
Image-to-Image
- Load an image
- Connect to "images" input of Gemini node
- Add prompt describing desired changes
- Model will use the image as context
Combining Multiple Images
- Add "Batch Images" node
- Connect images from different sources
- The node automatically creates new inputs as you connect
- All images are resized and combined into a single batch
- Use the batch for further processing or saving
Development
Project Structure
comfy_nanobanana/
βββ src/comfy_nanobanana/
β βββ __init__.py
β βββ nodes.py # ComfyUI node implementations
β βββ gemini_api.py # Gemini API client with async support
βββ web/
β βββ index.js # Extension entry point
β βββ node/
β βββ batch_images_dynamic.js # Dynamic input handling for Batch Images
β βββ gemini_api_key_mask.js # API key masking and secure export handling
βββ requirements.txt
βββ pyproject.toml
Dev Setup
cd comfy_nanobanana
pip install -e .[dev]
pre-commit install
Developer Notes
API Key Security Implementation
The node implements a dual-mode export system:
- UI Masking: API keys are visually masked in the interface (showing only first 4 and last 2 characters)
- Workflow Export: Automatically strips API keys for safe sharing
- API Export: Preserves API keys for programmatic use (requires Developer Mode)
This design balances security with developer convenience, ensuring users don't accidentally expose credentials while maintaining ease of deployment for production systems.
Troubleshooting
Common Issues
"No API key provided"
- Ensure
GEMINI_API_KEYis set or enter key in node
"Seed must be between 0 and 2147483647"
- Gemini API requires 32-bit integer seeds
Unexpected empty image output
- Verify you selected one of the supported Gemini image models
- If the API returns no image payload, the node falls back to a placeholder image to avoid crashing the workflow
Contributing
Pull requests welcome! Please:
- Follow existing code style
- Add tests for new features
- Update documentation
License
MIT License - see LICENSE file
Credits
Created with ComfyUI Extension Template
Run ComfyUI workflows without the setup
No installs, no CUDA version roulette, no GPU sitting idle on your bill. Bring a workflow and run it in the browser.
