Kotodama Prompt Enhancer
Rough idea in, actual prompt out
- prompt
The name sounds mystical. The node is boring and useful: it takes the half-sentence you typed, hands it to a chat model you already have running somewhere else, and gives you back a prompt. One STRING output, one HTTP call, no diffusion model involved.
Why put an LLM between your idea and the prompt box
On a big chunk of the current lineup, the prompt box stopped being a tag bin. Krea 2, Z-Image, Flux 2 Klein and Anima encode your text with a general-purpose language model, which reads your prompt as a message, not a bag of tokens - (word:1.3) weights, BREAK and masterpiece, best quality are inert there. Those bases want flowing descriptive prose: subject, then wardrobe, then framing, then light. That's the job an enhancer does for you.
One caveat up front: enhancers drift. The failure mode is a node that adds detail you never asked for and stamps one look on everything you make; a good system prompt narrows that, nothing eliminates it. And a small local model isn't a better writer than a frontier API, just offline and free per call - Kotodama calls whatever OpenAI-compatible endpoint you name.
How it works
When ComfyUI builds the node's input menu, Kotodama asks your endpoint for its model list - a GET /v1/models with a two-second timeout and a five-minute cache. If that route is missing, the menu falls back to the exact IDs in KOTODAMA_FALLBACK_MODELS and says so in the tooltip rather than pretending it discovered them live. On run it POSTs your text as the user message and the selected system-prompt file as the system message to /v1/chat/completions.
Chat models rarely hand back a bare prompt: they fence it, add a "Here's your enhanced prompt:" lead-in, or quote the whole thing. The node strips all three, but unwraps quotes only when what's left is balanced, so a prompt ending on "OPEN LATE" survives. The part I'd praise: it refuses to fail quietly. Bad connection, 401, malformed JSON, a reply that cleaned to empty, or output cut off at max_tokens all raise and stop the graph. An enhancer that returns "" on error still renders a picture - the wrong one, silently.
The inputs you'll touch
- text - the rough prompt. Type it, or wire it in from anything that emits a STRING.
- system_prompt - a file in
system_prompts/. Two ship:text-to-image(the default, written to work from text alone) andkrea2. Drop your own.mdor.txtin there, refresh the browser, and it appears in the menu - no restart. - model - whatever your endpoint reports, or the fallback list.
- temperature / max_tokens / seed - 0.8 is fine; raise
max_tokensif long prompts get cut; bumpseedto force a fresh answer when nothing else changed, since ComfyUI caches on input identity. Editing the prompt file or the endpoint invalidates that cache too, and the node includes both in its cache key. - passthrough_on_empty - off by default, so an empty input is an error. Enable it only if an empty conditioning string downstream is genuinely what you want.
Output is a single prompt (STRING). Wire it into CLIPTextEncode.text - right-click the encoder and pick Convert widget to input → text, because that field stays a widget until you do.
Installing it
Search the pack title in ComfyUI Manager (comfyui-kotodama, display name "Kotodama Prompt Enhancer"), or clone it:
cd ComfyUI/custom_nodes
git clone https://github.com/ericmey/comfyui-kotodama
# restart ComfyUI
Nothing to pip install: zero dependencies, standard-library urllib, Python 3.10+. What you supply is the endpoint - this is not a node that downloads a model for you.
cp ComfyUI/custom_nodes/comfyui-kotodama/.env.example \
ComfyUI/custom_nodes/comfyui-kotodama/.env
KOTODAMA_BASE_URL=http://127.0.0.1:4000
KOTODAMA_API_KEY=
KOTODAMA_FALLBACK_MODELS=your-model-id
The URL is the service root, without /v1. The key is optional for a trusted local service, and it's deliberately not a node widget: ComfyUI writes widget values into saved workflows and into the PNG metadata of every image, so a key in a field leaks into everything you share. If a package manager replaces the node folder on update, keep the .env at <ComfyUI user directory>/kotodama/.env; precedence is process environment, then that file, then the node folder.
When it doesn't work
- 401/403 - key missing, or the provider won't grant you that model. Check the Settings row first.
- Timeout -
KOTODAMA_TIMEOUTdefaults to 300s; big local models on long outputs blow past it. Lowermax_tokensrather than only raising the timeout. - Connection errors - Kotodama refuses redirects on purpose, so your bearer key can't be forwarded elsewhere. Point
KOTODAMA_BASE_URLat the final URL. - Menu says
<configure endpoint or fallback model>- the endpoint was unreachable at graph load. SetKOTODAMA_FALLBACK_MODELSto exact IDs and refresh. - The prompt never changes - that's the cache. Bump
seed. Your text and the system prompt go to that endpoint, and the returned prompt can land in the workflow and image metadata, so treat it as somewhere your drafts live.
This pack has almost no community footprint yet - a corpus search for "kotodama" across r/comfyui, r/StableDiffusion and r/civitai returns nothing, so everything here comes from the README and shipped code.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | The rough prompt to enhance. Wire it in or type it here. | |
| system_prompt | COMBO | text-to-image | A file in the node's system_prompts/ folder. |
| model | COMBO | Endpoint unavailable or unconfigured; showing the fallback list. | |
| temperature | FLOAT | 0.800–2 | — |
| max_tokens | INT | 102464–32768 | — |
| seed | INT | 00–18446744073709550000 | Bump to force a re-run with identical other inputs. ComfyUI caches node output on input identity, so without a new seed the same text comes back. Changing system_prompt, model, temperature, or max_tokens already invalidates the cache. |
| passthrough_on_empty | BOOLEAN | false | Empty input text returns empty without calling the LLM. Off = an empty input is an error. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| prompt | STRING | — |