GPT Prompt Generator 💬
Let a GPT-2 model write your prompt, right inside the graph
- clip
- CONDITIONING
- STRING
GPT2PNode is a single-node replacement for CLIPTextEncode where the prompt isn't yours - a small GPT-2 model writes it. You type a seed phrase, the node runs a HuggingFace prompt-generator model to expand it into a full prompt, encodes the result with your checkpoint's CLIP, and hands you ready-to-sample conditioning. No API call, no key, nothing leaves your machine.
Think of it as the ComfyUI version of the old A1111 "MagicPrompt" script, or of what Fooocus quietly shipped as its default prompt rewriter. It's a 2022–2023 trick, and if that sounds like damning with faint praise, it mostly is - but it's a fun one, and it's genuinely useful for prompt roulette when you're out of ideas.
How it works
The mechanism is exactly three steps under the hood: take your seed text, run a GPT-2 checkpoint through the transformers library to continue that text into a longer prompt, then feed the result through the clip you wired in. The CONDITIONING output is what you get from CLIP encoding that generated text, so it plugs straight into a KSampler's positive input - the node is your text encoder, just one with writer's block therapy.
The second output, STRING, is the actual generated prompt text. This is the one beginners miss: wire it into a ShowText / PreviewText node or just look at it, because that's where you learn what the model actually wrote. Generated conditioning with no idea what it contains is a recipe for "why does every image look the same?"
The inputs that matter
- text - your seed phrase, a starting point the model continues from. "A photo of a cyberpunk city" beats "1girl, long hair" for the Stable Diffusion finetunes.
- model_repo - a dropdown of 14 HuggingFace prompt-generator repos, all the classics:
Gustavosta/MagicPrompt-Stable-Diffusion,microsoft/Promptist,daspartho/prompt-extend, theAUTOMATIC/promptgen-*family, the Ar4ikov 650k checkpoints, and a few more. MagicPrompt is the safest first pick; it's the smallest and least weird. - temperature - 0.1 to 2.0, default 1.0. Below ~0.5 the output collapses to near-deterministic boilerplate; above ~1.3 it starts babbling. 0.8–1.1 is the band that actually produces variety.
The honest take
These finetunes were trained to emit SD 1.5-era booru tag text, so they play nicely with the SD 1.5 / SDXL / Illustrious lineage - the "prompting behaviour tracks the text encoder, not the release date" rule from the modidex knowledge base cuts both ways, and a tag-spitter speaks CLIP fluently. But their output is heavy on masterpiece, best quality, highly detailed padding, and for a 2026 LLM-encoded model (Flux 2 Klein, Z-Image, Anima) a GPT-2 tag generator is the wrong tool entirely - those models want instruction-shaped prose, and the CLIP-vocabulary output a generator like this produces lands flat. Use it for ideation on SDXL-class checkpoints, not as a quality lever.
Install and gotchas
Two ways, standard for a custom node. From ComfyUI Manager, search ComfyUI-GPT2P and install. Or do it by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/1038lab/ComfyUI-GPT2P
Restart ComfyUI. The pack itself has no heavy deps, but the node needs the transformers stack to run GPT-2, and here's the real gotcha: the first time you run it, it downloads the selected model from HuggingFace - a few hundred megabytes, straight to your HF cache, no progress bar in the UI. The bigger 650k checkpoints can take a while on a slow connection and use a noticeable chunk of RAM. If the node looks frozen on first use, that's it, not a crash. And it needs internet, which is the one way this "runs entirely locally" claim bites: the code is local, the model fetch is not.
Other failure modes are boring: a mismatched clip (for SDXL you want the combined CLIP from the checkpoint loader, not a single-encoder one), and temperature too high producing prompt soup. Both are easy to spot and fix.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| clip | CLIP | — | |
| text | STRING | — | |
| model_repo | COMBO | 14 options: Gustavosta/MagicPrompt-Stable-Diffusion, daspartho/prompt-extend, succinctly/text2image-prompt-generator, microsoft/Promptist, AUTOMATIC/promptgen-lexart, AUTOMATIC/promptgen-majinai-safe, +8 | |
| temperature | FLOAT | 1.00.1–2 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| CONDITIONING | CONDITIONING | — |
| STRING | STRING | — |