🧠 MetaPrompt Ollama
Turn 'cyberpunk girl, neon rain' into a 300-word prompt on your own GPU
- concatenated
- lines_json
- total_count
Type a rough idea - "cyberpunk girl, neon rain" - and get back a detailed, structured generation prompt: composition, lighting, lens, mood, the works. That's MetaPrompt Ollama, the sibling of the pack's plain MetaPrompt node with one addition: after the block builder assembles your prompt, a local LLM running through Ollama rewrites it into something a diffusion model can actually chew on. No API key, no cloud, no subscription. If your checkpoint's text encoder is itself a language model, having a second one write the instruction is a surprisingly natural fit.
It's the same block/list builder under the hood - same .txt/.csv lists, same per-block separators, same seed modes - so if you've used the base MetaPrompt node, you already know the first half. The second half is a runtime enhancement step that runs during the queue.
How it works
The node sends your assembled prompt to your local Ollama server at http://127.0.0.1:11434 (configurable) through either /api/chat or /api/generate - apiMode lets you force one, or leave it on auto, which tries chat first for text. A system prompt tells the model to act as a prompt engineer and return only the enriched prompt, and an instruction block controls how aggressive the rewrite is. The shipped preset uses Gemma 4 e4b with a "minimum of 300 words, add composition, lighting, camera/lens, mood, style" instruction.
The clever part is the failure handling. Local models occasionally return nothing or an exact copy of your source text. When that happens the node retries once with the seed dropped (some models behave better when Ollama does its own sampling), and if it still fails it falls back to the raw source prompt. Your generation pipeline never dies because the LLM had an off moment. The code also forces the node to re-run on every queue when Ollama is enabled - otherwise ComfyUI's caching would make it look like the enhancement "sometimes does nothing."
The inputs and outputs that matter
Two required JSON widgets, both managed from the app rather than typed by hand:
metaprompt_state_json- the block/list configuration, identical to the base MetaPrompt node.metaprompt_ollama_settings_json- the Ollama side: model name, URL, temperature, token budget,seedMode(off/fixed/randomize), plusretryIdenticalandfallbackOnEmptytoggles. You can save and reload whole setups as presets on disk underollama_presets/.
Outputs match the base node: concatenated (STRING) is the enriched prompt - wire it into CLIPTextEncode - with lines_json and total_count alongside.
Installing it
Install the pack (ComfyUI Manager → search Orion4D MetaPrompt, or clone the repo into custom_nodes), restart, and then the real prerequisite: Ollama itself.
# one-time: get Ollama running and pull a model
ollama serve
ollama pull gemma4:e4b # the shipped preset
# or whatever you like: the README suggests gemma4:12b / qwen3-vl:4b
If Ollama isn't running you get a connection error; if the model name is wrong, a hard failure. Both are instant and obvious.
Where people get burned
You're now budgeting VRAM for two models at once - the LLM and the diffusion model on the same card. Keep the LLM small (a 4B–8B class model) or it'll fight your sampler for memory. And manage expectations: a local 8B does not write better English than a frontier API. What it buys you is offline, free, and uncensored. The other trap is subject drift - an instruction telling the model to add 300 words of detail will happily invent details you never asked for. The node constrains output with system prompts and retry logic rather than hard token stops, so a chatty model can still leak preamble into your prompt. Scope the instruction tightly ("keep the subject, add lighting and composition") and you're fine. This is a prompt-starter, not a writer - that's the honest ceiling of the whole category.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| metaprompt_state_json | STRING | {} | — |
| metaprompt_ollama_settings_json | STRING | {} | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| concatenated | STRING | — |
| lines_json | STRING | — |
| total_count | INT | — |