Prompt Enhance API (with Image)
An LLM rewrite node that actually means API
- image
- enhanced_prompt
Some nodes named "API" never touch a network. This one's name is honest: type a rough idea, optionally attach an image, and the node phones out to an LLM - OpenAI-compatible or native Ollama - and hands back a rewritten, expanded prompt ready for your sampler. It's the "LLM writes the prompt" trick that's become a routine part of the graph (llm-in-comfyui.md in the KB tracks the pattern), just wrapped as a single text-in/text-out box instead of a full Rube Goldberg of local-model nodes.
The pitch is the same as every enhancer: a plain English idea in, a structured, model-appropriate prompt out, wired straight into your CLIP or T5 encoder. The twist here is that the model doing the rewriting isn't on your GPU - it's behind an endpoint. That means it's flexible (any OpenAI-compatible server, from OpenAI to Azure to LM Studio to Ollama's own API), and it means you're calling someone's API per run, so the seed/caching behavior below actually matters.
How it works
The node builds a chat request - your system_prompt plus the user_prompt - and POSTs it to an endpoint configured in a config.ini file in the node's own directory. Two modes:
openai(default): hitshttps://api.openai.com/v1/chat/completionsand needs an API key in the config. If animageis connected, it's converted from the ComfyUI tensor to a base64 PNG and embedded as animage_urlcontent block, so this is where a vision model likegpt-4oearns its keep.ollama: calls the nativehttp://localhost:11434/api/chatwith no key at all, passing the image in Ollama's per-messageimagesarray. This is the local path - free, offline, uncensored, which is exactly why the KB's decision tree says local wins for anything you don't want a hosted filter to see.
The code itself is a thin requests wrapper - a couple of hundred lines, no model weights to download, nothing exotic. requirements.txt lists requests, Pillow, numpy, and torch, all of which ComfyUI already ships, so dependency pain is minimal.
The inputs that matter
You set exactly four things on the canvas:
api_mode-openaiorollama. Pick this first; it decides whether you need a key and an internet connection.user_prompt- the rough idea you want rewritten.model- the model name, e.g.gpt-4ofor OpenAI,llama3.2-visionorllavafor Ollama. Defaults togpt-4o.seed- this one's the trap. ComfyUI caches node outputs by inputs, so with an unchanged seed you get the cached result back and no API call happens. Bump the seed (or wire a randomizer into it) to force a fresh, paid call. Leave it alone and you're reusing a result for free.
Optional: image (any IMAGE output - feed it from a VAE decode or a Load Image) for vision models, and keep_alive (Ollama only) - "0" unloads the model from VRAM immediately, "5m" holds it, "-1" keeps it loaded forever. If you share VRAM between a diffusion model and Ollama, "0" is your friend.
The single output, enhanced_prompt (STRING), wires into your text encoder.
Config: the part people miss
OpenAI mode will not run until you create config.ini in the node's directory - copy config.example.ini next to the installed node and fill in api_key and api_endpoint. Ollama mode works out of the box against localhost. Everything tunable (temperature, max_tokens, num_ctx, timeouts) lives in that file, not on the node. The README and the source agree on all of this.
Install
ComfyUI Manager is easiest - search for "comfyui-prompt-enhance-api-with-image". Or, the manual way:
cd ComfyUI/custom_nodes
git clone https://github.com/dogarrowtype/comfyui-prompt-enhance-api-with-image
# restart ComfyUI
One honest caveat: this is a brand-new, zero-star pack (created mid-2026) in a category the ecosystem has already seen weaponized once (external-api-nodes.md covers the LLMVISION incident). I read the source - it's a plain HTTP client, nothing sketchy in it - but it's unproven and new. If you install it, that config file is where your API key sits, so the usual "read a fresh node before running it" advice applies.
Where people get burned
- "API key not configured" - no
config.ini, or the key isn't under[openai]. Ollama mode never hits this. - Image ignored - you're on a non-vision model. Use
gpt-4o/gpt-4-vision-previeworllama3.2-vision/llava. - Ollama connection refused - Ollama isn't serving (
ollama serve), or the model isn't pulled (ollama list). - Output has chat scaffolding - "Here is your enhanced prompt:" as literal tokens. Unlike the fancier local enhancers the KB covers, this node does zero output cleaning, so keep your
system_prompttight ("respond with only the rewritten prompt, no preamble") or it lands in your conditioning.
It won't make your images better by itself - it fixes the blank-page problem and pays for that convenience per call. For a free, unfiltered version of the same job, flip api_mode to ollama and let a local model take the wheel.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| api_mode | COMBO | openai | 2 options: openai, ollama |
| system_prompt | STRING | You are a helpful assistant that enhances and rewrites prompts to be more detailed and effective. | — |
| user_prompt | STRING | — | |
| model | STRING | gpt-4o | — |
| seed | INT | 00–18446744073709550000 | — |
| imageopt | IMAGE | — | |
| keep_aliveopt | STRING | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| enhanced_prompt | STRING | — |