Grok Chat
A real multi-turn conversation inside your graph
- client
- chat_session
- response
- chat_session
Grok Chat is what you reach for when one text-generation call isn't enough and you want an actual back-and-forth with Grok - a conversation that remembers what was said before, threaded through your workflow node by node. Unlike Grok Text Generation (a one-shot completion), this node carries message history forward, so you can build a prompt-refinement loop, a multi-step task chain, or an iterative editor where each pass builds on the last.
The mechanism is neat and it's all in the chat_session output. Every time the node runs it appends your new message to the conversation history, sends the whole thing to xAI, and returns the assistant's reply plus the updated history. Wire that chat_session output into the next Grok Chat node's chat_session input and the conversation continues. Leave it disconnected and a fresh conversation starts. That threading is the whole trick - the history lives in the wires, not in some hidden global state.
The inputs
prompt- your message in the conversationchat_session- previous history from another Grok Chat; leave disconnected to start newreset_conversation- boolean; when true, discards history and starts overmodel- defaults togrok-4.5(the combo includes the grok text models)temperature- 0 to 2, default 0.7max_tokens- default 4096, up to 16384client- optional Grok API Client, falls through to ERPK Settings
The two that matter for beginners are reset_conversation (tick it when a run keeps picking up stale context you want gone) and chat_session (leave it alone to start fresh). Outputs are response (STRING, wire into Preview Anything or a text node) and chat_session (the GROK_CHAT_SESSION value, wire into the next Grok Chat).
Install
Standard ERPK Collection install:
cd ComfyUI/custom_nodes
git clone https://github.com/eRepublik-Labs/comfyui-nodes-erpk.git erpk
cd erpk && pip install -r requirements.txt
Needs xai-sdk>=1.14.0 and an xAI key in ERPK Settings. Or install "ERPK Custom Nodes" from ComfyUI Manager and restart. It lives under ERPK/Grok.
Troubleshooting
The gotcha people hit is the queue-vs-conversation mismatch. ComfyUI re-runs a node every time the queue executes, so if you queue the same graph twice, the conversation threads a second time - old messages plus a fresh copy of your prompt. That's usually not what you want. Use reset_conversation (or leave chat_session unwired) when you want a clean run, and be deliberate about wiring the session chain only where you actually want continuity.
Also note the model default: this is a chat model, grok-4.5, not the image model. If you drop a Grok Image prompt in here expecting an image, you'll get text back. The empty-prompt guard will also throw "Prompt cannot be empty" if you execute without typing anything - that one's self-explanatory.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | Your message in the conversation. | |
| clientopt | GROK_API_CLIENT | Grok API client from Grok API Client node. If not connected, resolves from ComfyUI Settings or environment. | |
| modelopt | COMBO | grok-4.5 | Grok model to use for chat. |
| chat_sessionopt | GROK_CHAT_SESSION | Previous chat session output from another Grok Chat node. Leave disconnected to start a new conversation. | |
| reset_conversationopt | BOOLEAN | false | Discard existing history and start a new conversation. |
| temperatureopt | FLOAT | 0.700–2 | Creativity level. |
| max_tokensopt | INT | 4096256–16384 | Maximum number of tokens in the response. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| response | STRING | — |
| chat_session | GROK_CHAT_SESSION | — |