Nodes/comfyui-nano-banana/Google API Key
ComfyUI Node

Google API Key

The boring node that un-bricks Nano Banana

By fwlemos·Created 6 months ago·Updated 6 months ago· 0
Google API Key
    • api_key
    api_key

    Every node in the comfyui-nano-banana pack (fwlemos/NBP-Comfyui) calls Google's Nano Banana image models over the API. No weights, no GPU - just a key. The Google API Key node is that key, packaged as a one-input, one-output box you can wire around your graph.

    Do you even need it?

    Mostly, no. The pack's Generate and Chat nodes each take an api_key input directly, and the extension will happily read your key from an environment variable or a text file. This node exists for the edge cases: when you want to switch keys per-workflow, keep the key out of the graph entirely, or route one shared key to several nodes so you change it in a single place.

    There's a real-world reason to care about keeping it out of the graph: ComfyUI culture is built on sharing workflow JSONs, and a pasted key rides along with every copy. A node that resolves the key at runtime is a lot safer than a hardcoded string in a file you're about to post.

    How it works

    The node has exactly one input, api_key (STRING, leave empty by default), and one output, also api_key (STRING). All it does is resolve a key through the pack's three-tier priority and hand you the winner:

    1. Environment variable - GOOGLE_API_KEY or GEMINI_API_KEY
    2. A google_api_key.txt file sitting inside the extension directory
    3. Whatever you type into the node

    Wire the output into the api_key input on any Nano Banana generation or chat node and you're set.

    Here's the gotcha nobody tells you: the environment variable beats the node input. The README frames the node input as an "override," but in the actual code the order is env var → config file → node input. If you have GOOGLE_API_KEY set globally and type a different key into the node, your typed key quietly loses. To make per-workflow keys work, you need the env var and the config file both clear, and then whatever you type in the node wins.

    Installing it

    Same story as the rest of the pack - install it once, get all three nodes. Via ComfyUI Manager, search for the pack title "comfyui-nano-banana" (or "Nano Banana") and hit install. Or by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/fwlemos/NBP-Comfyui.git
    pip install -r NBP-Comfyui/requirements.txt
    

    Then restart ComfyUI. Dependencies are light - google-genai, requests, Pillow - and there are zero model files to download. This is a cloud-API pack; the only "heavy" thing is the key itself.

    When things go wrong

    The most common failure is the "No Google API key found" error, and the pack's own message lists all three places to fix it: the env var, the config file, or the node. A 401 means the key itself is bad. And if a key is already resolving from your environment, leaving the node input empty is the correct move - the node will still output the resolved key, which is exactly what you want if you're using it as a routing point.

    It's a tiny node. But it's the difference between a workflow that works for the person you share it with and one that leaks your API key to everyone who loads it.

    CategoryGoogle AI/Image Generation

    Inputs (1)

    NameTypeDefaultDescription
    api_keySTRINGGoogle API key. Leave empty to use GOOGLE_API_KEY env var or google_api_key.txt config file.

    Outputs (1)

    NameTypeDescription
    api_keySTRING