OpenAI GPT π§
An LLM chat completion as a node, with role support
- STRING
Sometimes the smartest thing you can add to a workflow isn't another diffusion model - it's a language model that rewrites, summarizes, or generates the text you feed into everything else. This node drops a GPT chat completion into your graph and returns the reply as a STRING you can wire straight into a CLIP Text Encode node or a String Function. If you want an LLM in the loop writing your prompts, this is the switch.
How it works
It's a wrapper around OpenAI's chat completions API. You get a system_prompt (defaults to "You are a helpful assistant."), a model dropdown with the full GPT catalog, a seed for (best-effort) reproducibility, and max_tokens. The neat part is the three optional message slots: a, b, and c are text inputs, each with its own a_role/b_role/c_role dropdown (user, assistant, or system). Wire a to a prompt fragment with role user, b to context with role system, and you can build a real multi-turn conversation without a string-concat pileup.
The model list is a snapshot from when this pack was written - gpt-4o, gpt-4-turbo, gpt-4-vision-preview, gpt-4, gpt-3.5-turbo and their dated variants. It defaults to gpt-4-0613, which is a 2023 model. Two practical consequences: any model ID OpenAI has since retired or renamed will throw a 404-ish error until you pick a current one from the list, and the list itself won't grow with new models until the pack updates. If you need a model that isn't listed, you're out of luck here - this is a fixed dropdown, not a free-text field.
Inputs and outputs
system_prompt,model,seed,max_tokens- the core.a/a_role,b/b_role,c/c_role- up to three messages, each with a role.- Output: a single STRING with the model's reply.
It retries up to three times on transient API errors, which is a nice touch for flaky network runs, but a bad key raises immediately.
Where you'd use it
Prompt generation is the headline: ask GPT to write a prompt for "a cyberpunk street scene at night, cinematic" and feed the STRING into your text encoder. It also composes with the pack's other OpenAI nodes - GPT can caption an image (or feed the GPT4V node), DALL-E 3 can illustrate what it writes, and the Translate node can clean up non-English output. That's literally the loop this pack's author built their dialogue game around.
Installing it
It's part of ComfyUI-NegiTools - ComfyUI Manager (search "ComfyUI-NegiTools") or:
cd ComfyUI/custom_nodes
git clone https://github.com/natto-maki/ComfyUI-NegiTools
pip install -r ComfyUI-NegiTools/requirements.txt
then restart with OPENAI_API_KEY set in your environment before launching ComfyUI. Without the key, every call fails at authentication.
The honest take
This node is dated in the model list but sound in concept. The pattern - an LLM generating or rewriting the text that drives diffusion - has only gotten more common since this pack shipped. If you're comfortable with the API cost and don't mind picking a current model from the frozen dropdown, it works fine. If you'd rather keep everything local, an Ollama-compatible node gets you the same wiring without the key or the per-token bill - but that's a different install, and this one is already here.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| model | COMBO | gpt-4-0613 | 20 options: gpt-4o, gpt-4o-2024-05-13, gpt-4-turbo, gpt-4-turbo-2024-04-09, gpt-4-turbo-preview, gpt-4-0125-preview, +14 |
| seed | INT | 00β18446744073709550000 | β |
| max_tokens | INT | 51216β4096 | β |
| system_prompt | STRING | You are a helpful assistant. | β |
| a_roleopt | COMBO | user | 3 options: user, assistant, system |
| aopt | STRING | β | |
| b_roleopt | COMBO | assistant | 3 options: user, assistant, system |
| bopt | STRING | β | |
| c_roleopt | COMBO | user | 3 options: user, assistant, system |
| copt | STRING | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | β |