ComfyUI Node

Provider: xAI

XAI — the direct line to Grok, no router in the middle

By yogurt7771·Created 2 years ago·Updated 6 days ago· 3
Provider: xAI
    • provider
    ◄api_key►
    ◄proxy_url►
    ◄timeout0►

    You only need this node if you have an xAI account. If you don't, close the tab - several Grok models are reachable through the pack's OpenRouter provider instead, and that's usually the easier path. Provider: xAI exists for the case where you'd rather talk to api.x.ai yourself: no router markup, one vendor's rate limits, and access to the Grok Imagine versions that aren't exposed anywhere else.

    In this pack it's the default provider for Grok Chat and Grok Imagine, so if you're using either of those without wiring a provider in, this is what the call is doing behind your back - with the key pulled from api_key.json or the environment. Plugging the provider in explicitly is how you change which key, which proxy, or how long you'll wait.

    What it does

    Like every provider node here, it makes no request itself. When it executes it outputs a single provider value (YOGURT_LLM_PROVIDER) carrying its connection settings; the model node you wire it into does the actual HTTP. Route resolution happens at the model node: it looks for a route matching this provider's kind, and if the selected model version has none, you get an error listing the ones that do. No mystery 404s from a mismatched pair.

    The inputs that matter

    • api_key - empty means "use the "xai" key from api_key.json, then the XAI_API_KEY environment variable". The pack also accepts "grok" as the JSON key and GROK_API_KEY as the variable, which is handy because half the internet documents it the other way round.
    • proxy_url - a proxy such as http://127.0.0.1:7890 or socks5://127.0.0.1:1080. Not optional decoration in a lot of places: xAI's endpoint isn't reachable everywhere, and this field is the pack's answer to that.
    • timeout - request timeout in seconds, 0 for no limit. Grok Imagine jobs take tens of seconds, so 0 is the sane default.

    That's the whole node. Three fields.

    The thing that trips people up

    There's no base_url field here - unlike the Topaz and Ark provider nodes, which both expose one. So if you want to point xAI at a relay or a different regional endpoint, you can't do it from the canvas. You do it through api_key.json (the "xai_base_url" key) or the XAI_BASE_URL environment variable, both of which the pack's connection layer reads before falling back to https://api.x.ai/v1. Worth knowing before you spend twenty minutes hunting for a widget that was never drawn.

    Installing

    Same as the rest of the pack - ComfyUI Manager, search the pack title, or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/yogurt7771/ComfyUI-YogurtNodes.git
    cd ComfyUI-YogurtNodes && pip install -r requirements.txt
    

    Restart, then find the node in YogurtNodes/LLM/Providers. Display names in this pack get a " (Yogurt Nodes)" suffix at runtime, so the browser entry reads "Provider: xAI (Yogurt Nodes)". The key file:

    # custom_nodes/ComfyUI-YogurtNodes/yogurt_nodes/llm/api_key.json
    { "xai": "xai-..." }
    

    Node field first, then that file, then the environment variable.

    Where people get burned

    The obvious one: the pack's error message when no key is found names every source it tried, in order, so read it twice before posting. The less obvious one is moderation. xAI's own endpoint applies xAI's filters, and a node can't bypass a filter that lives at the model - that's true of every API-wrapper node in this ecosystem, and it's the single biggest reason people still prefer a local model for anything spicy. The Grok Imagine version you pick matters too: some of the newer ones are reachable through OpenRouter as well, and the ones that aren't are exactly the reason to hold a direct key.

    Last thing, and it's the whole category's problem rather than this node's: you're paying per call, and every retry is another call. Set retry_count on the model node deliberately rather than reflexively.

    CategoryYogurtNodes/LLM/Providers

    Inputs (3)

    NameTypeDefaultDescription
    api_keySTRINGLeave empty to use 'xai' from api_key.json, then the XAI_API_KEY environment variable.
    proxy_urlSTRINGProxy URL, e.g. http://127.0.0.1:7890 or socks5://127.0.0.1:1080.
    timeoutINT00–3600Request timeout in seconds; 0 means no limit.

    Outputs (1)

    NameTypeDescription
    providerYOGURT_LLM_PROVIDER—