main
ComfyUI Gemini API
中文 | English
A custom node for ComfyUI to integrate Google Gemini API.
Installation
Method 1: Manual Installation
-
Clone this repository into your ComfyUI's
custom_nodesdirectory:cd ComfyUI/custom_nodes git clone https://github.com/CY-CHENYUE/ComfyUI-Gemini-API -
Install required dependencies:
If you're using ComfyUI portable version:
..\..\..\python_embeded\python.exe -m pip install -r requirements.txtIf you're using your own Python environment:
path\to\your\python.exe -m pip install -r requirements.txt
Method 2: Install via ComfyUI Manager
- Install and open ComfyUI Manager in ComfyUI
- Search for "Gemini API"
- Click the install button
Restart ComfyUI after installation
Node Description
Gemini 2.0 image
A node that generates images using the Gemini API.
Input Parameters:
- prompt (required): Text prompt describing the image you want to generate
- api_key (required): Your Google Gemini API key (automatically saved after first setup)
- model: Model selection
- width: Width of the generated image (512-2048 pixels)
- height: Height of the generated image (512-2048 pixels)
- aspect_ratio: Choose image orientation (Free, Landscape, Portrait, Square)
- temperature: Parameter controlling generation diversity (0.0-2.0)
- seed (optional): Random seed for reproducible results
- images (optional): Reference image input, supports multiple images
Outputs:
- image: Generated image that can be connected to other ComfyUI nodes
- API Respond: Text information containing processing logs and API response
Use Cases:
- Creating unique concept art
- Generating images from text descriptions
- Creating style-consistent new images using one or multiple reference images
- Image editing based on existing images
Multi-Image Feature:
- The node now supports inputting multiple reference images simultaneously
- Multiple images will be sent together to the Gemini API as style reference
- The system automatically adjusts the prompt to inform the model about multiple reference images
- This feature is ideal for mixing multiple styles or providing more reference information
Getting API Key
- Visit Google AI Studio
- Create an account or sign in
- Create a new API key in the "API Keys" section
- Copy the API key and paste it into the node's api_key parameter (only needed for first use, will be saved automatically)
Temperature Parameter Guide
- Temperature range: 0.0 to 2.0
- Lower temperature (near 0): More deterministic, predictable results
- Higher temperature (near 2): More diverse, creative results
- Default value 1.0: Balances determinism and creativity
Important Notes
- API may have usage limits or costs, please refer to Google's official documentation
- Image generation quality and speed depend on Google's server status and your network connection
- Reference image feature will send your images to Google services, please be aware of privacy implications
- API key needs to be entered only once, it will be stored in gemini_api_key.txt in the node directory
- About Image Orientation: Gemini API generates images based on the selected orientation (landscape, portrait, or square), though the model may not always perfectly follow these instructions
Contact Me
- X (Twitter): @cychenyue
- TikTok: @cychenyue
- YouTube: @CY-CHENYUE
- BiliBili: @CY-CHENYUE
- Xiaohongshu: @CY-CHENYUE
Languages
Python
100%

