Call LLM API
Call LLM API Is a Grok Node, and Your Key Lives in an Env Var
- response
What it actually is
An LLM in a ComfyUI graph is always doing one of three jobs: rewriting your rough idea into a structured prompt, captioning an image, or just generating text inside the workflow. All three are routine now. What varies is where the model runs, and this node is squarely on the API side.
The name undersells it, though. Call LLM API is a Grok node. The model_name dropdown is an enum with exactly one entry - grok-4.3 - the code builds an OpenAI client pointed at https://api.x.ai/v1, and it authenticates with an XAI_API_KEY environment variable. No key field on the node, no provider menu, no base URL to edit. If you were hoping for a generic "paste any OpenAI-compatible key here" wrapper, keep looking.
Reach for it when you want one round trip: prompt in, text out, wire the string into a CLIP Text Encode. "Turn girl on a horse, moody into a properly structured video prompt." "Expand this idea into comma-separated booru tags." That's the job. The honest framing from the KB applies: the API path is worth it when you want frontier-chat quality and don't care that a hosted model filters, costs per call, and ships your prompt - and your reference image, if you pass one - to a server you don't control.
How it works
It's the OpenAI Python SDK aimed at xAI's endpoint, calling the Responses API with reasoning={"effort": ...}, store=False and max_output_tokens=..., then returning response.output_text. The store=False is the node asking the provider not to retain the exchange, a courtesy most wrappers skip. If you set either image field, the input becomes a two-part content array - text plus image - so the same node does vision; when both fields are filled, image_base64 wins.
The inputs that matter
- prompt - your instruction. Be bossy: "Output only the prompt. No preamble, no explanation." Nothing here strips chat scaffolding, so if you ask for a description you'll get "Here is a refined prompt:" glued to the front of your conditioning.
- max_tokens - defaults to 2048, ranges to 131072 in steps of 128. For rewriting a prompt, 512 is already generous.
- reasoning_effort -
none,low,medium,high. Leave it onnone. Prompt rewriting wants a model that follows a format and stops; a reasoner burns tokens deliberating and is more likely to leak its scratch-work into your text. - image_base64 (optional) - the well-trodden path. The same pack ships Image to PNG Data URI, which outputs a ready
data:image/png;base64,...string, so you can wiredata_uristraight in and caption images from inside the graph. image_url also works, passed through as a plain URL string.
One output: response, a STRING. Into CLIP Text Encode, into a save-text node, or into another LLM node if you're chaining two steps.
Install
ComfyUI Manager, search Sagado Nodes - that's the pack title. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/5agado/ComfyUI-Sagado-Nodes
cd ComfyUI-Sagado-Nodes
pip install -r requirements.txt openai
Note the extra openai on that line. It is not in the pack's requirements.txt (which lists torch, pillow, numpy and ollama), and the import happens inside the node's function - so ComfyUI starts up perfectly happy and the node dies the first time you run it with ModuleNotFoundError: No module named 'openai'. The pack's README is basically a stub, so read the dependencies yourself.
Then set the key in the environment of the ComfyUI process, before you launch it:
export XAI_API_KEY=xai-your-key-here # Windows: setx XAI_API_KEY "..." then reopen the shell
python main.py
Where people get burned
No key → hard stop at run time. You get ValueError: XAI_API_KEY environment variable is not set. Setting it after ComfyUI is running does nothing; the process read its environment at launch. On a service or Docker setup, put it in the unit file / compose env, not your shell.
Wrong Python environment. pip install openai into your system Python while ComfyUI runs from a venv is the classic, and it looks exactly like the module was never installed.
Every API error kills the queue. The node prints the exception and re-raises, so a rate limit, a bad key or a content refusal ends the whole run rather than skipping the node. Budget for that if you're batching.
Good hygiene, for once. Because the key lives in the environment and not in a widget, sharing the workflow JSON doesn't leak your credentials. That's better than the packs that write your key into a config file, and rarer than it should be.
If you'd rather not use an API at all
The same pack ships the local route - Call Ollama, Get Llm Response, and llama.cpp model loaders, which is why ollama is in requirements.txt. For prompt enhancement and captioning, a local 8B is usually the better tool anyway: uncensored, offline, and free per call. Use this node when you specifically want Grok on the other end.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| model_name | COMBO | grok-4.3 | 1 options: grok-4.3 |
| prompt | STRING | — | |
| reasoning_effort | COMBO | none | 4 options: none, low, medium, high |
| max_tokens | INT | 2048-1–131072 | — |
| image_urlopt | STRING | — | |
| image_base64opt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| response | STRING | — |