Nodes/ComfyUI-YogurtNodes/OpenAI Generate Text
ComfyUI Node

OpenAI Generate Text

An LLM Call, Wired Straight Into Your Workflow Logic

By yogurt7771·Created 2 years ago·Updated 4 days ago· 1
OpenAI Generate Text
  • history
  • text
  • history
  • payload
api_key
base_url
model_namegpt-5.1
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
timeout0
extra{}

A lot of the interesting ComfyUI workflows these days aren't really about generation - they're about an LLM deciding something, then the graph acting on it. YogurtOpenAIGenerateText is the node that makes that decision: a full OpenAI chat call whose output lands as a STRING you can branch on, feed into a prompt, or log.

The controls you'll actually touch:

  • api_key - inline, or blank to fall back to the pack's api_key.json or OPENAI_API_KEY.
  • model_name - defaults to gpt-5.1.
  • system_prompt and prompt - the system framing and the user message. Multiline, so real prompting fits.
  • temperature and top_p - sampling heat and diversity. top_p defaults to 0, which means "not enforced" here.
  • max_tokens - output ceiling (default 4096).
  • frequency_penalty / presence_penalty - dials for repetition and topic drift, both -2 to 2.
  • retry_count, timeout, proxy_url - resilience.
  • chat_template - the default template wraps {{system_instruction}} and {{prompt}} in <-system-> / <-user-> markers, and you can restructure it freely.

Optional inputs: history (feed the previous turn's HISTORY output for a multi-turn conversation) and extra (raw JSON added to the request body). Outputs: text (the reply), history (chain it back in for the next call), and payload - the raw response object, for when you need more than the text.

How you'd use it

The classic loop: ask the model to analyze a prompt or an image caption and output a yes/no or a structured answer, then wire text into a switch or conditional. The history output makes real back-and-forth possible - a discussion with the model that spans multiple node calls instead of a single shot. And the base_url flexibility is quietly the best feature: point it at Azure or any OpenAI-compatible endpoint (LocalAI, Ollama, a self-hosted proxy) and this node becomes your universal LLM connector.

Install and keys

Ships in ComfyUI-YogurtNodes, the pack's LLM family (OpenAI, OpenRouter, Gemini, Grok, Qwen, Vertex AI - same client pattern throughout). ComfyUI Manager → search ComfyUI-YogurtNodes → install, or:

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

Restart ComfyUI, look under "Yogurt Nodes/LLM". Requires the openai Python package; no models to download.

Key gotcha: this node does one call per run - it's not a chat session unless you wire history back around. And watch max_tokens vs the model's real output length; a truncation at 4096 tokens can silently chop an answer the downstream node was expecting whole.

CategoryYogurtNodes/LLM

Inputs (16)

NameTypeDefaultDescription
api_keySTRINGAPI key for accessing OpenAI API
base_urlSTRINGBase URL for OpenAI API (leave blank for official API)
model_nameSTRINGgpt-5.1OpenAI 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
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*