Nodes/ERPK Collection/Grok API Client
ComfyUI Node

Grok API Client

Hand out an API client

By eRepublik-Labs·Created 11 months ago·Updated 20 days ago· 1
Grok API Client
    • client
    api_key

    Grok API Client is the boring, unskippable first step of the ERPK Grok section: it builds an xAI client and hands it to every downstream Grok node. On its own it does nothing you can see - no prompt, no output image, just a client connection you wire into Grok Text Generation, Grok Chat, Grok Image Generation, or Grok Image Edit.

    The important thing to know is that it's optional. Every Grok node in this pack will happily run without it, because they all fall through to the same key resolution: ComfyUI Settings first (right-click canvas > ERPK Settings), then the api_key widget on this client node, then grok/config.ini in the pack folder. If you've already put your xAI key in ERPK Settings, you can drag a Grok Image Generation node onto the canvas and use it with zero wiring. The client node is only there when you want to override the key per-workflow - useful if you have multiple xAI accounts, or someone else's workflow arrived with a hardcoded key you want to swap out.

    The one input

    The single input is api_key, an optional STRING. Leave it empty and it resolves from Settings or config.ini. Type a key and it wins. The tooltip spells out the priority order plainly: "If empty, checks ComfyUI Settings, then grok/config.ini."

    The single output is client, type GROK_API_CLIENT. Connect it to any Grok node's client input. The pack stores keys per-user and never writes them into saved workflows, which is a genuinely nice touch - your workflow JSON stays shareable.

    Install

    It's part of the ERPK Collection, so install is the whole pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/eRepublik-Labs/comfyui-nodes-erpk.git erpk
    cd erpk && pip install -r requirements.txt
    

    That pulls in xai-sdk>=1.14.0, which is the real dependency the Grok nodes need. Restart ComfyUI and you'll find it under ERPK/Grok. You can also install "ERPK Custom Nodes" from ComfyUI Manager.

    Troubleshooting

    The one error you'll actually hit is a ValueError at execute time: "Grok API key resolution failed." That's the node telling you it found no key anywhere - not in Settings, not in the widget, not in config.ini. Fix: paste a key into ERPK Settings (Settings > ERPK > API Keys in the ComfyUI settings UI), or drop it into the widget. xAI keys look like xai-... and you mint them at console.x.ai.

    One more thing: since this is a config node, nothing here is cached or billed. It doesn't call the API by itself; it just resolves credentials. If you're debugging a Grok workflow and you're not sure whether the key is the problem, watch for the [Grok] print lines in the ComfyUI console - the generation nodes log which model and prompt they're sending.

    CategoryERPK/Grok

    Inputs (1)

    NameTypeDefaultDescription
    api_keyoptSTRINGxAI API key. If empty, checks ComfyUI Settings, then grok/config.ini.

    Outputs (1)

    NameTypeDescription
    clientGROK_API_CLIENT