google-genai numpy torch Pillow torch
This is a Google Gemini API integration node for ComfyUI, supporting text generation and image generation functions. With this node, you can directly use Google’s Gemini 2.0 series models in your ComfyUI workflow.
Special Note: Regarding the error [ERROR]API call error: ‘NoneType’ object has no attribute ‘parts’, it means that the image or prompt you uploaded violates the “Generative AI Prohibited Use Policy”. Please test with general scene or product images first to ensure compliance.
2024.3.19: Updated to support multi-image processing.
custom_nodes directory:“`
cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI_Gemini_Expanded_API.git
“`
“`
cd ComfyUI_Gemini_Expanded_API
pip install -r requirements.txt
“`
First, you need to obtain a Google Gemini API key:
Configure Gemini API Key node to enter your API key.Use the Expanded Gemini Text/Image node for text generation:
config input.prompt.input_image input for image understanding.If you are in China or other regions requiring a proxy:
use_proxy to True.proxy_host (default is 127.0.0.1).proxy_port (default is 7890).api_key: Google Gemini API keyconfig: API key configurationprompt: Prompt textmodel: Select model (gemini-2.0-flash, gemini-2.0-flash-exp, gemini-2.0-pro)temperature: Generation temperature (0.0-1.0), controls the randomness and creativity of the output.top_p: Nucleus sampling parameter (0.0-1.0)top_k: Number of candidate tokens to consider (1-100). Higher values mean more diversity.max_output_tokens: Maximum output tokens (1-8192)include_images: Whether to include images in the response (True/False)input_image: Input image (for image understanding)use_proxy: Whether to use a proxy (True/False)proxy_host: Proxy host addressproxy_port: Proxy portText generation node output:
text: Generated textimage: If image generation is enabled, outputs the image.gemini-2.0-flash-exp).Thanks to Google for providing the Gemini API service.
Thanks to tatookan for creating the original custom node repository for me to expand upon.