Nodes/ComfyUI-JNK-Tiny-Nodes/Get Gemini Keys JNK
ComfyUI Node

Get Gemini Keys JNK

Keep your API keys out of the workflow file

By AljnkΒ·Created about a year agoΒ·Updated 12 months agoΒ· 3
Get Gemini Keys JNK
    • key_1
    • key_2
    • key_3
    • key_4
    • key_5
    β—„file_pathβ–Ί

    The single best reason to use this node is the thing it stops you from doing: pasting a Gemini API key directly into Ask Google Gemini. Do that and the key rides along in your workflow JSON and into the metadata of every saved image - which is fine until you share that workflow or post that PNG, at which point you've handed someone your key. Get Gemini Keys exists to make that mistake unnecessary. It reads API keys from a plain text file, one per line, and hands them out as up to five separate string outputs you can wire into your Gemini nodes.

    It also quietly enables the pack's real intended setup: key rotation. The free Gemini tier rate-limits you hard (roughly 15 requests per minute on flash-class models), and one key will hit that ceiling in a busy batch. Load five keys, have Get Gemini Models define per-model RPM budgets, and rotate between keys to multiply your throughput without paying anything.

    Inputs and outputs

    • file_path - absolute path to a .txt file with your keys, one per line.

    Outputs: key_1 through key_5 (all STRING). If your file has fewer than five lines, the unused outputs are empty strings. The order is just line order, top to bottom.

    How it works

    Under the hood it's barely more than open(file_path).readlines() - it reads up to the first five lines, strips whitespace, and returns them. That's it. No encryption, no validation, no checking that a key is even real. The security benefit is positional: the keys live in a file outside the graph, so they never get serialized into your workflow.

    Installing it

    Pack install: search JNK in ComfyUI Manager, or

    cd ComfyUI/custom_nodes/
    git clone https://github.com/Aljnk/ComfyUI-JNK-Tiny-Nodes.git
    

    No extra dependencies for this node - just make sure google-genai is installed for the Ask Google Gemini node you'll be feeding.

    Where people get burned

    The failure mode is silent. If the file path is wrong or the file is missing, the node doesn't error - it catches the exception, logs a line to the console, and returns five empty strings. Your Ask Google Gemini node then runs with an empty key and fails with a confusing API error. So the debugging path is: empty strings from this node β†’ check the path and the console. Also, note the filename field wants a raw filesystem path - it does not look in ComfyUI's input folder, so C:\Users\you\keys.txt or /home/you/keys.txt, not keys.txt. Keep keys in a file, keep that file out of your workflow, and rotate - that's the whole job, and it does it.

    CategoryπŸ”§ JNK

    Inputs (1)

    NameTypeDefaultDescription
    file_pathSTRINGβ€”

    Outputs (5)

    NameTypeDescription
    key_1STRINGβ€”
    key_2STRINGβ€”
    key_3STRINGβ€”
    key_4STRINGβ€”
    key_5STRINGβ€”