Nodes/Plush-for-ComfyUI/Custom API Key🧸
ComfyUI Node

Custom API Key🧸

Point Advanced Prompt Enhancer at your own env variable

By glibsonoran·Created 3 years ago·Updated about a year ago· 197
Custom API Key🧸
    • Custom_ApiKey
    • troubleshooting
    Environment_Variable-New Env. Variable
    New_Env_Variable

    Plush has built-in environment variables for the big named services (OpenAI, Groq, Anthropic, Gemini). But the moment you want to use some other remote service, an OpenRouter, an APIpie, a NanoGPT, or your own hosted endpoint, there's no predefined variable for it. Custom API Key fixes that. You make an environment variable with any name you want, put your key in it, and this node reads it and hands the key to Advanced Prompt Enhancer.

    Small node, narrow job, but it's the thing that unlocks the entire "connect to any service" story in Plush.

    How it works

    You create an environment variable on your OS, say OPENROUTER_KEY, and set its value to your API key. In the Custom API Key node you type that variable's name, and the node fetches the key at runtime and outputs it as a KEY object. You wire that into the Custom_ApiKey input on Advanced Prompt Enhancer (or on the Gemini Image / Imagen Image nodes, which also accept it). Now APE can authenticate to a service Plush was never preconfigured for.

    One real limitation, straight from the pack: this is restricted to services that require a URL (the ones whose AI_service names end in (URL)). It can't be used for ChatGPT, Anthropic, or Groq, because those authenticate through their own dedicated environment variables. So Custom API Key is specifically for the URL-based, bring-your-own-endpoint connections.

    The inputs

    • Environment_Variable: a dropdown of existing env-var names Plush knows about, plus the option to define a new one. To use your own, you pick "-New Env. Variable".
    • New_Env_Variable: type the exact name of the environment variable you created (the one holding your key). This is the field that matters.

    The output is Custom_ApiKey, a KEY, plus a troubleshooting text output. Route the key into the node you're authenticating.

    Why keys live in environment variables

    This isn't Plush being fussy. Storing API keys in environment variables instead of pasting them into a node or a saved JSON file is the recommended security pattern, and it matters more in ComfyUI than most places. Custom nodes run arbitrary Python with full access to your machine, and the ecosystem has already had a real supply-chain incident where a malicious node harvested credentials from users' installs. A key sitting in a workflow file is a key that travels every time you share that workflow. A key in an env var stays on your machine. Set a spending limit on any paid key too, so a leak can't run up a huge bill.

    Installing it

    Ships with Plush-for-ComfyUI. Install the pack through ComfyUI Manager (search "Plush", install Plush-for-ComfyUI, restart) or manually: cd ComfyUI/custom_nodes && git clone https://github.com/glibsonoran/Plush-for-ComfyUI.git, then pip install -r requirements.txt, restart.

    Common issues

    The single most common problem is the environment variable not being visible yet. After you create one, you generally have to reboot your machine (not just restart ComfyUI) before the process can see it. On Windows use setx NAME value and check with echo %NAME% in a fresh terminal; on Linux/macOS add an export line to your shell profile and re-source it. If the node reports no key, that's the first thing to check. Second: make sure you actually typed the variable name in the node, not the key value itself. And remember this node only works with the (URL) services, so if you're trying to use it with plain ChatGPT it won't do anything. The troubleshooting output will tell you which of these it is.

    CategoryPlush🧸/Prompt

    Inputs (2)

    NameTypeDefaultDescription
    Environment_VariableCOMBO-New Env. VariableChoose to enter a new Env. Variable below, or choose an existing one from the list
    New_Env_VariableSTRINGEnter the name of a new Environment Variable that contains your API Key.

    Outputs (2)

    NameTypeDescription
    Custom_ApiKeyKEY
    troubleshootingSTRING