Nodes/ComfyUI_AceNodes/πŸ… OpenAI GPT Chat
ComfyUI Node

πŸ… OpenAI GPT Chat

An LLM inside your graph β€” just know where your API key goes

By hay86Β·Created 2 years agoΒ·Updated about a year agoΒ· 96
πŸ… OpenAI GPT Chat
  • image
  • STRING
β—„system_promptβ–Ί
β—„user_promptβ–Ί
β—„max_tokens200β–Ί
β—„temperature0.7β–Ί
β—„modelβ–Ύβ–Ί

There's a whole family of "let an LLM help write the prompt" workflows out there, and most of them involve leaving ComfyUI to call some website. πŸ… OpenAI GPT Chat brings the call into the graph: give it a system prompt and a user prompt, it asks OpenAI's chat API, and the reply comes back as a STRING you can wire into your prompt encoders, a text saver, or anything else. It's genuinely handy for prompt iteration inside the tool you're already in. It also has two sharp edges - the API key handling and a chatty console - that you'll want to know about before you wire it in.

How it works

The required inputs are system_prompt and user_prompt (both multiline), plus max_tokens (default 200), temperature (default 0.7), and model - a fixed dropdown of eleven OpenAI models, defaulting to chatgpt-4o-latest. The optional image input is the fun one: connect an IMAGE and the node base64-encodes it as JPEG and appends it to the user message as an image attachment, so you get a multimodal captioning or image-analysis call without any extra machinery. The output is a single STRING with the model's reply.

The catch is authentication. The node reads your key from the OPENAI_API_KEY environment variable - there's no key field on the node, so it won't work until you've exported that variable in the environment ComfyUI runs in. And here's the sharp edge: the source code prints the key to the console when the node runs (GET OpenAI Key: …). On a local box that's a mild privacy leak; on a shared or logged machine, it's your key sitting in plaintext logs. Worth knowing.

Inputs and outputs

  • system_prompt, user_prompt - STRING, multiline.
  • max_tokens - INT, default 200, 1–10000.
  • temperature - FLOAT, default 0.7, 0.1–1.0.
  • model - enum of 11 models.
  • image - IMAGE, optional.
  • Output: STRING.

Where it fits

The pattern that makes this valuable is chaining: load a rough prompt, ask the model to rewrite it with a system prompt like "make this more vivid, keep under 40 words," and feed the result straight into a CLIP Text Encode. The optional image input turns it into an image-understanding node too. It's the pack's Swiss-army LLM node, and it composes nicely with πŸ… Text Save so you don't lose good generations.

Install

Part of hay86/ComfyUI_AceNodes:

cd ComfyUI/custom_nodes
git clone https://github.com/hay86/ComfyUI_AceNodes
cd ComfyUI_AceNodes
pip install -r requirements.txt
export OPENAI_API_KEY="sk-…"

Restart ComfyUI and find πŸ… OpenAI GPT Chat under Ace Nodes. Manager users search ComfyUI_AceNodes. The openai package is in the pack's requirements.txt.

Gotchas

The key issues, in order: (1) no key, no output - it throws with an unhelpful error until OPENAI_API_KEY is set; (2) the console prints your key, so use a scoped key and keep an eye on logs; (3) the model list is a hardcoded snapshot from when the pack was written - gpt-4.5-preview and o1-preview may be deprecated, so prefer current names like gpt-4o-mini or whatever your account has; (4) it costs real money per call, and max_tokens defaults to a trim 200, which is fine for short rewrites but too small for long outputs. For in-graph LLM work, it's the pack's most ambitious node - just wire it with your eyes open.

CategoryAce Nodes

Inputs (6)

NameTypeDefaultDescription
system_promptSTRINGβ€”
user_promptSTRINGβ€”
max_tokensINT2001–10000β€”
temperatureFLOAT0.70.1–1β€”
modelCOMBO11 options: gpt-4.5-preview, gpt-4o, chatgpt-4o-latest, gpt-4o-mini, o1, o1-mini, +5
imageoptIMAGEβ€”

Outputs (1)

NameTypeDescription
STRINGSTRINGβ€”