ComfyUI Node

Grok Chat

A real multi-turn conversation inside your graph

By eRepublik-Labs·Created 11 months ago·Updated 21 days ago· 1
Grok Chat
  • client
  • chat_session
  • response
  • chat_session
prompt
modelgrok-4.5
reset_conversationfalse
temperature0.70
max_tokens4096

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 conversation
  • chat_session - previous history from another Grok Chat; leave disconnected to start new
  • reset_conversation - boolean; when true, discards history and starts over
  • model - defaults to grok-4.5 (the combo includes the grok text models)
  • temperature - 0 to 2, default 0.7
  • max_tokens - default 4096, up to 16384
  • client - 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.

CategoryERPK/Grok

Inputs (7)

NameTypeDefaultDescription
promptSTRINGYour message in the conversation.
clientoptGROK_API_CLIENTGrok API client from Grok API Client node. If not connected, resolves from ComfyUI Settings or environment.
modeloptCOMBOgrok-4.5Grok model to use for chat.
chat_sessionoptGROK_CHAT_SESSIONPrevious chat session output from another Grok Chat node. Leave disconnected to start a new conversation.
reset_conversationoptBOOLEANfalseDiscard existing history and start a new conversation.
temperatureoptFLOAT0.700–2Creativity level.
max_tokensoptINT4096256–16384Maximum number of tokens in the response.

Outputs (2)

NameTypeDescription
responseSTRING
chat_sessionGROK_CHAT_SESSION