π OpenAI GPT Chat
An LLM inside your graph β just know where your API key goes
- image
- STRING
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.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| system_prompt | STRING | β | |
| user_prompt | STRING | β | |
| max_tokens | INT | 2001β10000 | β |
| temperature | FLOAT | 0.70.1β1 | β |
| model | COMBO | 11 options: gpt-4.5-preview, gpt-4o, chatgpt-4o-latest, gpt-4o-mini, o1, o1-mini, +5 | |
| imageopt | IMAGE | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | β |