Nodes/ComfyUI-YogurtNodes/Grok Generate Text
ComfyUI Node

Grok Generate Text

An LLM in the graph for prompt-writing, captioning, and workflow logic

By yogurt7771·Created 2 years ago·Updated 9 days ago· 1
Grok Generate Text
  • history
  • text
  • history
  • payload
api_key
base_url
model_namegrok-4
system_prompt
prompt
temperature1.00
top_p0.00
max_tokens4096
frequency_penalty0.00
presence_penalty0.00
retry_count1
chat_template<-system-> {{system_instruction}} <-/system-> <-user-> {{prompt}} <-/user->
proxy_url
seed-1
timeout0
extra{}

Grok Generate Text is the pack's xAI text endpoint as a node: give it a prompt, get a STRING back. On its own that's "an LLM in a graph," which is already useful for auto-writing prompts from a few keywords, generating negative prompts, or rewriting captions. Wired into the wider workflow it becomes logic - the kind of "ask the model what to do next" plumbing people build LLM nodes for.

ComfyUI is catching up to the idea that a text model is just another node whose output feeds the graph, and Grok specifically is a solid pick because xAI's models are cheap, fast, and (famously) less filtered than most. The KB's closed-source roundup notes Grok's reputation for permissiveness, which matters if your workflow asks the model to describe or write about subjects other providers flag. For anything from "expand this one-line idea into a full prompt" to "write the alt-text for this batch," it slots in cleanly.

How it works

It's a chat-completions call to the xAI API, default model grok-4. The chat_template field wraps your system_prompt and prompt into the message format (default uses <-system-> / <-user-> markers), so when xAI changes formats you edit the template rather than the node. You get the standard sampling knobs - temperature, top_p, max_tokens, frequency_penalty, presence_penalty - plus a seed for reproducible replies and retry_count. The optional history input accepts a HISTORY object (build one with this pack's History Builder) for multi-turn conversations, and extra takes JSON for any new API fields. proxy_url supports http/https/socks proxies if you need one.

The inputs that matter

  • api_key - xAI key; blank falls back to XAI_API_KEY/GROK_API_KEY env vars or api_key.json with a "grok" entry.
  • prompt - your main instruction or question.
  • system_prompt - sets the model's role and style; this is where you tell it to be a "prompt engineer" or "concise captioner."
  • temperature / max_tokens - the two knobs that change behavior most.

Three outputs: text (the reply), history (for feeding back into the next call), and payload (the raw API response object, if you want to inspect it).

Installing it

It ships in ComfyUI-YogurtNodes. Install via ComfyUI Manager (search "ComfyUI-YogurtNodes") or:

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

Restart ComfyUI; it's under "Yogurt Nodes". You'll need an xAI API key from console.x.ai.

Where people get burned

The template is again the common failure: an outdated chat_template still works syntactically but can degrade quality silently, so if replies get weird, check it against xAI's docs before blaming the model. top_p defaults to 0, which is xAI's "use the API default" convention rather than a literal zero - don't read it as a bug. And remember every call costs API credits, so a node that fires on every batch item multiplies the bill; gate it where you can. Otherwise, treat this as a straightforward remote LLM and it behaves.

CategoryYogurtNodes/LLM

Inputs (17)

NameTypeDefaultDescription
api_keySTRINGAPI key for accessing xAI API
base_urlSTRINGBase URL for xAI API (leave blank for official API)
model_nameSTRINGgrok-4xAI text model name
system_promptSTRINGSystem-level prompt that affects the overall conversation style
promptSTRINGMain prompt content input by the user
temperatureFLOAT1.000–2Sampling temperature, higher values produce more random outputs
top_pFLOAT0.000–1Sampling probability threshold, controls output diversity
max_tokensINT40960–32768Maximum number of tokens in the generated text
frequency_penaltyFLOAT0.00-2–2Frequency penalty to reduce repetition
presence_penaltyFLOAT0.00-2–2Presence penalty to encourage new topics
retry_countINT11–10Number of retry attempts if the request fails
chat_templateSTRING<-system-> {{system_instruction}} <-/system-> <-user-> {{prompt}} <-/user->Content template for the generated text
proxy_urlSTRING代理URL,格式: protocol://user:pass@addr:port,支持http,https,socks5,socks5h
seedINT-1-1–2147483647Random seed for generation (-1 for random)
timeoutINT00–2147483647Timeout for the request in seconds, 0 means no timeout
historyoptHISTORY
extraoptSTRING{}Extra parameters for the request, in JSON format

Outputs (3)

NameTypeDescription
textSTRING
historyHISTORY
payload*