Nodes/ComfyUI OpenAI Prompter/OpenAI Prompt Generator
ComfyUI Node

OpenAI Prompt Generator

Outsource your prompts to GPT — the OpenAI Prompt Generator node

By nisimjoseph·Created 2 years ago·Updated 10 months ago· 4
OpenAI Prompt Generator
    • generated_prompt
    model
    prompt_contextGenerate a detailed prompt for an image generation AI
    additional_instructionsgive it without any prefix, or things like "here the prompt for:". just give the image prompt
    max_tokens512
    temperature0.7
    seed0

    Writer's block is a real bottleneck when you batch images. You stare at the empty prompt box, type "a cat," and get a cat-shaped smudge. This node is the lazy fix: it calls OpenAI's GPT API from inside your workflow, gets a detailed prompt back, and hands the string straight to your text encoder. One click, no copy-pasting from ChatGPT in a browser tab, and - the part people actually like - you can rerun it with a new seed for prompt variation as easily as rerunning your sampler.

    It's one node from a tiny pack (ComfyUI OpenAI Prompter), and it does exactly one thing. That's fine; most of the ecosystem's prompt-enhancer packs are the same shape.

    How it works

    Nothing is generated locally. On load, the node lists your OpenAI account's models, keeps every ID containing "gpt," and populates a dropdown. Your key has to be in the OPENAI_API_KEY environment variable before ComfyUI starts; otherwise the dropdown's only entry is literally Error: OpenAI API key not configured.

    When you run it, the node sends a chat completion to OpenAI with a fixed system prompt ("You are a creative assistant that generates detailed, descriptive prompts…") plus your prompt_context and additional_instructions as the user message. It passes your seed for reproducibility, sets temperature, and picks the right max-tokens parameter depending on whether the model is a gpt-5/o-series (those take max_completion_tokens and only support temperature 1). Then it returns the model's reply as one string.

    The inputs that matter

    Most are self-explanatory; these three do the real work:

    • prompt_context - what you want the prompt to be about. Defaults to "Generate a detailed prompt for an image generation AI," which is useless for anything specific, so replace it.
    • additional_instructions - your constraints. The default is actually good: "give it without any prefix… just give the image prompt." Keep it, or GPT will wrap everything in "Here's your prompt:" fluff.
    • model - the GPT dropdown. Only IDs containing "gpt" appear, so don't hunt for o1 here.

    Then max_tokens (256–4096), temperature (0–2), and seed for rerolls.

    The single generated_prompt output is a STRING. Wire it into the text input of a CLIP Text Encode node (or whatever your checkpoint uses) and you're done.

    Installing it

    Easiest path is ComfyUI Manager - search "OpenAI Prompter" and install. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/nisimjoseph/ComfyUI_OpenAI-Prompter
    

    Its only dependency is openai>=1.0.0 (Manager handles it; otherwise pip install openai). No model downloads, no VRAM cost - it's a paid API call per run. Set the key in the environment ComfyUI launches from and restart:

    export OPENAI_API_KEY="sk-..."
    

    Because the node caches its client and model list at class level, adding a key after first load won't stick until you restart.

    Where people get burned

    The big one: GPT writes sentences, and sentences are wrong for tag-based models. On SDXL, Illustrious, or Pony, an LLM's florid prose mostly doesn't map to the CLIP vocabulary - the KB's prompting essay notes LLM-assisted prompting only "fits the architecture" on natural-language models like Flux and LLM-encoded checkpoints, and even there you hit an attention cap around 75–100 effective tokens. There's no built-in tag mode here; if you target a booru model, put "output comma-separated danbooru tags only" in additional_instructions and watch the length.

    Second trap: the node swallows errors. Expired key, exhausted quota, network blip - instead of raising, it returns a string like "⚠️ OpenAI API quota exceeded…" as the generated_prompt. Wire that into your text encoder and you've just told the sampler to "render a billing warning." Check the output before blaming the checkpoint.

    Finally, a reminder that this pack ships your prompt context to OpenAI's servers. Fine for most work, but worth knowing when ComfyUI's ecosystem already has a documented malware history - read any custom node's source before trusting it. This one is ~300 readable lines, MIT-licensed, plain openai calls, no surprise exfiltration. Still: it's a cloud dependency by design, and if you'd rather keep everything local, a local-LLM prompt-enhancer pack is the alternative to reach for.

    Categoryprompt

    Inputs (6)

    NameTypeDefaultDescription
    modelCOMBO1 options: Error: OpenAI API key not configured
    prompt_contextSTRINGGenerate a detailed prompt for an image generation AI
    additional_instructionsSTRINGgive it without any prefix, or things like "here the prompt for:". just give the image prompt
    max_tokensINT512256–4096
    temperatureFLOAT0.70–2
    seedINT00–18446744073709550000

    Outputs (1)

    NameTypeDescription
    generated_promptSTRING