Nodes/ComfyUI Gemini Expanded API/Configure Gemini API Key
ComfyUI Node

Configure Gemini API Key

The node that hands your key to Gemini — without calling it

By silveroxides·Created about a year ago·Updated 15 days ago· 5
Configure Gemini API Key
    • config
    api_key
    api_versionv1alpha
    use_vertexai_envfalse
    vertexai_expressfalse
    vertexai_project
    vertexai_location
    google_application_credentials

    First, the slightly surprising part: this node never calls Google. Despite the name, it doesn't make a single API request. What it does is bundle your credentials and connection preferences into a little config object and hand that to the Expanded Gemini Text/Image node (SSL_GeminiTextPrompt), which is the one that actually talks to the Gemini API. Think of it as the identity card that the text node has to see before it's allowed to leave the house.

    You'll find it under API/Gemini in the node menu, and in any real workflow it sits right before the text node, feeding the config input. Its one output, config (type GEMINI_CONFIG), carries everything downstream.

    The inputs worth understanding:

    • api_key - your Google Gemini API key from AI Studio. The straightforward path. If you're worried about the key living in the saved workflow, pair this with the pack's GetKeyAPI node and feed its output in here.
    • api_version - which API surface to hit. The tooltip is the ground truth here: v1alpha, v1beta, and v2beta are Gemini API specific, v1beta1 is Vertex AI specific, and both can use v1. Default is v1alpha, which has been the right call for the newest model features.
    • use_vertexai_env - flips to the Enterprise/Vertex AI path and bypasses the rest of the config, reading everything from environment variables instead.
    • vertexai_express - Enterprise express mode, which uses an API key rather than full service-account auth. Requires the key and doesn't need project/location.
    • vertexai_project / vertexai_location - optional fallbacks used when the environment variables aren't set.

    The Enterprise (formerly Vertex AI) path is the fiddly one. You enable the API in the Google Cloud console, then set these before launching ComfyUI:

    export GOOGLE_GENAI_USE_ENTERPRISE=true   # legacy name GOOGLE_GENAI_USE_VERTEXAI still works
    export GOOGLE_CLOUD_PROJECT=your-project-id
    export GOOGLE_CLOUD_LOCATION=global
    

    Set use_vertexai_env to true and the node skips everything else. This is for people who need Google Cloud's enterprise controls, budget tracking, or regional compliance - for a hobbyist screwing around with image prompts, the free-tier AI Studio key is one less hour of your life spent in the console.

    Where people get burned: the API key is just a string in a widget, so it gets saved into the workflow .json in plain text. Export that workflow to share with a friend and you've handed them a working key on a billing account - this is a genuinely common leak pattern, and the pack's GetKeyAPI node exists specifically to route around it. Also, if you toggle use_vertexai_env without actually having the environment variables set, the text node downstream will come back with a "Missing environment variable" error rather than a cryptic one, which is at least honest.

    Install is standard for the pack:

    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
    

    Restart ComfyUI afterwards, or use ComfyUI Manager and search for "ComfyUI Gemini Expanded API". The real dependency is google-genai (plus numpy/torch/Pillow, which your ComfyUI already has), and there are no model downloads - this pack is a thin client for Google's hosted models, which is exactly what makes it a three-line install and also exactly why you need a network connection and a key.

    CategoryAPI/Gemini

    Inputs (7)

    NameTypeDefaultDescription
    api_keySTRING
    api_versionCOMBOv1alphaSelect API version to use. v1alpha, v1beta and v2beta are Gemini API specific while v1beta1 is Vertex AI specific. Both can use v1
    use_vertexai_envBOOLEANfalseUses Gemini Enterprise Agent Platform (formerly Vertex AI) with GOOGLE_GENAI_USE_ENTERPRISE or the legacy GOOGLE_GENAI_USE_VERTEXAI environment variable.
    vertexai_expressBOOLEANfalse
    vertexai_projectoptSTRING
    vertexai_locationoptSTRING
    google_application_credentialsoptSTRINGOptional absolute path to an application default credentials JSON file for Vertex AI.

    Outputs (1)

    NameTypeDescription
    configGEMINI_CONFIG