Nodes/comfyui-prompt-enhance-api-with-image/Prompt Enhance API (with Image)
ComfyUI Node

Prompt Enhance API (with Image)

An LLM rewrite node that actually means API

By dogarrowtype·Created 3 months ago·Updated 26 days ago· 0
Prompt Enhance API (with Image)
  • image
  • enhanced_prompt
api_modeopenai
system_promptYou are a helpful assistant that enhances and rewrites prompts to be more detailed and effective.
user_prompt
modelgpt-4o
seed0
keep_alive0

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): hits https://api.openai.com/v1/chat/completions and needs an API key in the config. If an image is connected, it's converted from the ComfyUI tensor to a base64 PNG and embedded as an image_url content block, so this is where a vision model like gpt-4o earns its keep.
  • ollama: calls the native http://localhost:11434/api/chat with no key at all, passing the image in Ollama's per-message images array. 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 - openai or ollama. 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-4o for OpenAI, llama3.2-vision or llava for Ollama. Defaults to gpt-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-preview or llama3.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_prompt tight ("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.

Categorytext/processing

Inputs (7)

NameTypeDefaultDescription
api_modeCOMBOopenai2 options: openai, ollama
system_promptSTRINGYou are a helpful assistant that enhances and rewrites prompts to be more detailed and effective.
user_promptSTRING
modelSTRINGgpt-4o
seedINT00–18446744073709550000
imageoptIMAGE
keep_aliveoptSTRING0

Outputs (1)

NameTypeDescription
enhanced_promptSTRING