Nodes/ComfyUI-Flux2proReplicate/Flux Replicate Auth (File)
ComfyUI Node

Flux Replicate Auth (File)

The two-line node that keeps your Replicate key out of your workflows

By mamorett·Created 9 months ago·Updated 9 months ago· 1
Flux Replicate Auth (File)
    • api_key

    This is the least exciting node in the pack, and you'll still want it. Flux Replicate Auth (File) does exactly one thing: it reads your Replicate API token from a text file and hands it to the Flux 2 Pro Generator. No inputs. One output. That's the whole job.

    Boring is the point. If you've ever pasted an API key into a workflow and then uploaded that workflow to a gallery, shared it on Discord, or committed it to a git repo, you know why a file-backed auth node exists: workflow JSON gets saved to the cloud, passed around, and dumped anywhere. A leaked Replicate token quietly burns your balance one generation at a time. This node keeps the key out of the graph entirely.

    How it works

    When the node runs, it looks for a file called replicate_api_key.txt in the pack's own folder - the same directory the custom node lives in - reads it, strips any surrounding whitespace, and returns the contents as a STRING. It's about ten lines of code. It also logs a masked confirmation, just the first four characters of the key, so you can see a key loaded without it ever appearing in full in your console.

    Inputs and outputs

    There's nothing on the input side - the node's entire job is to produce one output, api_key (STRING). Wire that into the api_key input on Flux2ProGenerator, and you're set.

    Setting it up

    The generator article has the full install, so here's the short version:

    cd ComfyUI/custom_nodes
    git clone https://github.com/mamorett/ComfyUI-Flux2proReplicate
    cd ComfyUI-Flux2proReplicate
    pip install -r requirements.txt
    

    Then get a token from replicate.com/account/api-tokens and drop it in a file - just the key, no quotes:

    echo "r8_YourReplicateToken" > replicate_api_key.txt
    

    Restart ComfyUI and the node appears under the FluxReplicate category. (The same install works via ComfyUI Manager if you search the pack title.)

    Gotchas

    • The path is specific. The file must be replicate_api_key.txt inside the ComfyUI-Flux2proReplicate folder - not your ComfyUI root, not a workflow directory. Get the path wrong and the node raises FileNotFoundError.
    • An empty file means ValueError. The node checks for that too, so a stray blank file doesn't silently send an empty key.
    • It's plaintext on disk. This is convenience, not a credential vault. The key sits unencrypted in a file inside your custom_nodes folder, which is the same trust model as most ComfyUI key handling - just don't zip up and share your entire custom_nodes directory.
    • Fresh clones don't include it. The file is gitignored, so if you reinstall the pack from scratch you'll need to recreate it. Updating in place leaves it alone.

    That's the entire node. Attach it once at the top of your workflow and forget it - it's the boring friend the Flux 2 Pro Generator needs.

    CategoryFluxReplicate

    Inputs (0)

    No inputs

    Outputs (1)

    NameTypeDescription
    api_keySTRING