177 lines
5.3 KiB
Plaintext
177 lines
5.3 KiB
Plaintext
===================================================================
|
|
GEMINI IMAGE GENERATION NODE - INSTALLATION GUIDE
|
|
===================================================================
|
|
|
|
This custom node allows you to generate images using Google's Gemini API
|
|
directly within ComfyUI, supporting resolutions up to 4K.
|
|
|
|
-------------------------------------------------------------------
|
|
QUICK START - COPY & PASTE THESE COMMANDS
|
|
-------------------------------------------------------------------
|
|
|
|
1. Navigate to your ComfyUI directory in terminal/command prompt
|
|
|
|
2. For Windows (PowerShell or CMD):
|
|
|
|
cd C:\Users\[YourUsername]\Documents\ComfyUI
|
|
.venv\Scripts\activate
|
|
pip install --upgrade google-genai
|
|
|
|
3. For Linux/Mac:
|
|
|
|
cd ~/ComfyUI
|
|
source venv/bin/activate
|
|
pip install --upgrade google-genai
|
|
|
|
4. Verify installation (optional):
|
|
|
|
pip show google-genai
|
|
|
|
5. Set API key as environment variable (recommended):
|
|
|
|
Windows (PowerShell):
|
|
$env:GOOGLE_API_KEY="YOUR_API_KEY_HERE"
|
|
|
|
Windows (CMD):
|
|
set GOOGLE_API_KEY=YOUR_API_KEY_HERE
|
|
|
|
Linux/Mac:
|
|
export GOOGLE_API_KEY="YOUR_API_KEY_HERE"
|
|
|
|
6. Restart ComfyUI
|
|
|
|
-------------------------------------------------------------------
|
|
REQUIREMENTS
|
|
-------------------------------------------------------------------
|
|
|
|
- ComfyUI installed and working
|
|
- Python 3.8 or higher
|
|
- Google AI Studio API key (free tier available)
|
|
- Internet connection
|
|
|
|
-------------------------------------------------------------------
|
|
INSTALLATION STEPS
|
|
-------------------------------------------------------------------
|
|
|
|
1. INSTALL THE NODE
|
|
|
|
Copy the "Google Gemini API" folder to your ComfyUI custom nodes directory:
|
|
|
|
Windows:
|
|
C:\Users\[YourUsername]\Documents\ComfyUI\custom_nodes\
|
|
|
|
Linux/Mac:
|
|
~/ComfyUI/custom_nodes/
|
|
|
|
2. INSTALL PYTHON DEPENDENCIES
|
|
|
|
Open a terminal/command prompt and navigate to your ComfyUI directory, then run:
|
|
|
|
Windows (PowerShell):
|
|
.\venv\Scripts\activate
|
|
pip install --upgrade google-genai
|
|
|
|
Linux/Mac:
|
|
source venv/bin/activate
|
|
pip install --upgrade google-genai
|
|
|
|
IMPORTANT: You need google-genai version 1.51.0 or higher for 4K support.
|
|
|
|
To verify the version:
|
|
pip show google-genai
|
|
|
|
3. GET YOUR GOOGLE API KEY
|
|
|
|
a) Go to: https://aistudio.google.com/app/apikey
|
|
b) Sign in with your Google account
|
|
c) Click "Create API Key"
|
|
d) Copy the generated key (starts with "AIza...")
|
|
|
|
BILLING NOTE: Image generation requires billing to be enabled.
|
|
- Free tier has ZERO quota for image generation
|
|
- You MUST enable billing at: https://console.cloud.google.com/billing
|
|
- Set up budget alerts to avoid unexpected charges
|
|
|
|
4. CONFIGURE THE NODE
|
|
|
|
Option A: In ComfyUI Node
|
|
- Paste your API key directly into the "api_key" field
|
|
|
|
Option B: Environment Variable (Recommended for security)
|
|
- Set GOOGLE_API_KEY environment variable
|
|
- The node will automatically use it if the field says "INSERT_API_KEY_HERE"
|
|
|
|
Windows (PowerShell):
|
|
$env:GOOGLE_API_KEY="YOUR_API_KEY_HERE"
|
|
|
|
Linux/Mac:
|
|
export GOOGLE_API_KEY="YOUR_API_KEY_HERE"
|
|
|
|
5. RESTART COMFYUI
|
|
|
|
After installing dependencies, restart ComfyUI completely.
|
|
|
|
-------------------------------------------------------------------
|
|
NODE FEATURES
|
|
-------------------------------------------------------------------
|
|
|
|
- Models:
|
|
* gemini-3-pro-image-preview (recommended, supports 4K)
|
|
* gemini-2.5-flash-image
|
|
|
|
- Resolutions:
|
|
* 1K: ~1024 pixels
|
|
* 2K: ~2048 pixels
|
|
* 4K: ~4096 pixels (e.g., 5504x3072 for 16:9)
|
|
|
|
- Aspect Ratios:
|
|
* 1:1, 16:9, 4:3, 3:4, 9:16, 2:3, 3:2, 4:5, 5:4, 21:9
|
|
|
|
-------------------------------------------------------------------
|
|
BUDGET PROTECTION
|
|
-------------------------------------------------------------------
|
|
|
|
To avoid unexpected charges, set up a budget alert:
|
|
|
|
1. Go to: https://console.cloud.google.com/billing
|
|
2. Select your billing account
|
|
3. Click "Budgets & alerts" (left menu)
|
|
4. Click "Create Budget"
|
|
5. Set monthly limit (e.g., $5 or $10)
|
|
6. Enable email alerts at 50%, 90%, 100%
|
|
|
|
Image generation costs vary by resolution. 4K images cost more than 1K.
|
|
|
|
-------------------------------------------------------------------
|
|
TROUBLESHOOTING
|
|
-------------------------------------------------------------------
|
|
|
|
ERROR: "RESOURCE_EXHAUSTED" or "429" error
|
|
SOLUTION: Enable billing for your Google Cloud project. Free tier has
|
|
zero quota for image generation.
|
|
|
|
ERROR: "GenerateContentResponse object has no attribute 'parts'"
|
|
SOLUTION: Outdated SDK. Run: pip install --upgrade google-genai
|
|
|
|
ERROR: "Image object has no attribute 'mode'"
|
|
SOLUTION: Update GeminiImageGen.py to latest version from this folder.
|
|
|
|
ERROR: "ImageConfig not found"
|
|
SOLUTION: Upgrade google-genai to 1.51.0+: pip install --upgrade google-genai
|
|
|
|
ERROR: Images always 1K regardless of setting
|
|
SOLUTION: Ensure google-genai is version 1.51.0 or higher.
|
|
|
|
-------------------------------------------------------------------
|
|
SUPPORT
|
|
-------------------------------------------------------------------
|
|
|
|
For issues with:
|
|
- This node: Check the GeminiImageGen.py file for updates
|
|
- Gemini API: https://ai.google.dev/gemini-api/docs/image-generation
|
|
- Billing: https://console.cloud.google.com/billing
|
|
|
|
===================================================================
|
|
Last Updated: 2025-11-20
|
|
===================================================================
|