Nodes/AI4ArtsEd Nodes/AI4ArtsEd OpenRouter Key
ComfyUI Node

AI4ArtsEd OpenRouter Key

Your API key, but not pasted into a workflow you'll share

By joeriben·Created about a year ago·Updated 7 months ago· 1
AI4ArtsEd OpenRouter Key
    • STRING

    The AI4ArtsEd pack leans on hosted LLMs via OpenRouter, and that means you need an API key somewhere. This node is the pack's answer to the obvious question: where, without ending up with sk-or-... pasted into a workflow JSON that you'll inevitably drag onto GitHub or into a shared PNG?

    The name undersells it slightly. It's a key loader, not a key generator - it does nothing but read a local file and hand the contents to whatever node you wire it into. There's no API call, no network traffic, no magic. It exists so the other nodes in this pack (ai4artsed_clean_prompt_randomizer, ai4artsed_prompt_interception, ai4artsed_image_analysis, and friends) can get credentials without you typing them into every node's api_key field.

    How it works

    The node reads a file called openrouter.key sitting in the same folder as the pack's Python files (ComfyUI/custom_nodes/ai4artsed_comfyui_nodes/). The first non-empty line is treated as the key, and the node refuses to load anything that doesn't start with sk-or-, which is a nice guard against pasting the wrong thing.

    The pack ships a template called key-template.template in the repo. Copy it, rename it to openrouter.key, and put your key on the first line. Two details worth knowing:

    • The file can hold a second line with the API URL (the template pre-fills https://openrouter.ai/api/v1/chat/completions). The other LLM nodes in this pack read both lines - key first, URL second.
    • The repo's .gitignore covers *.key, so if you keep this pack as a git checkout, the file stays out of version control. Check your own .gitignore if you're vendoring the pack some other way.

    It outputs a single STRING. Wire it into any api_key input on the pack's LLM nodes.

    Installing it

    This node ships with the rest of the pack, so install the pack, not the node:

    cd ComfyUI/custom_nodes
    git clone https://github.com/joeriben/ai4artsed_comfyui_nodes
    # restart ComfyUI
    

    ComfyUI Manager also finds it if you search "AI4ArtsEd". Then drop your key in custom_nodes/ai4artsed_comfyui_nodes/openrouter.key.

    Common issues

    "Missing 'openrouter.key' in node directory." That's the whole failure mode. You ran the node without creating the file. It fails loudly rather than silently, which is honestly the right behavior for a credential loader.

    The node isn't strictly necessary. Every LLM node in the pack can take the key directly in its api_key field, and if you set it there, it overrides the file. If you're the only person using your machine and never share workflows, you can skip this node entirely. Use it when you will share - keeping the key out of the workflow JSON is the entire point. The README's note about a OPENROUTER_KEY environment variable is stale; the shipped code only reads the file.

    One caveat: this is an academic, experimental pack (from the AI4ArtsEd research project). The node works, but don't expect it to do more than the 20 lines it contains.

    CategoryAI4ArtsEd

    Inputs (0)

    No inputs

    Outputs (1)

    NameTypeDescription
    STRINGSTRING