Nodes/ComfyUI_MieNodes/Qwen-Image-2.1 Prompt Generator ๐Ÿ‘
ComfyUI Node

Qwen-Image-2.1 Prompt Generator ๐Ÿ‘

Turn a scribbled idea into a prompt the sampler can eat

By MieMieeeeeยทCreated 2 years agoยทUpdated 3 days agoยท 273
Qwen-Image-2.1 Prompt Generator ๐Ÿ‘
  • llm_service_connector
  • reference_images
  • enhanced_prompt
โ—„modet2i - ๆ–‡็”Ÿๅ›พ(้ป˜่ฎค)โ–บ
โ—„user_inputโ–บ
โ—„seed0โ–บ
โ—„caption_modecache_memory_disk - ็ผ“ๅญ˜:ๅ†…ๅญ˜+็ฃ็›˜(ๆŽจ่)โ–บ
โ—„temperature0.70โ–บ
โ—„max_tokens16384โ–บ
โ—„timeout300โ–บ

What it is

A node that sits in front of the Qwen-Image-2.1 sampler and does one job: take whatever you actually typed - a sentence, a messy outline, half a paragraph of vibes - and rewrite it into the prompt the model wants.

Why this is worth a node rather than a bit of care on your part: the Qwen-Image family runs on an LLM-encoded prompt path, where your prompt is read as an instruction, not as a bag of tokens. That's the same shift that killed (word:1.3) weighting and BREAK across 2026's crop of LLM-encoded models - the punctuation is fed through as literal characters inside your instruction, which is worse than deleting it. What a model like this wants is a structured, well-written description, and most people don't enjoy writing those. So: five bundled system prompts, one LLM call, and a prompt-shaped string comes out the other end.

A note on the family, since it decides how much this node matters: Qwen-Image is Apache 2.0, and its Edit line became the community's default open instruction-editor largely because Alibaba doesn't police NSFW fine-tunes the way BFL does with Kontext. 2.0 cut the 20B base to 7B and unified generation with editing, but launched API-only. This node is written for 2.1 specifically - pick your mode to match the workflow you're actually running.

How it works

Each mode has a bundled system prompt under nodes/llm/prompts/qwen_image_21/, and the rewrite is a single LLM call through whichever connector you wired in. The model is expected to answer inside explicit markers:

--- BEGIN enhanced_prompt ---
<the rewritten prompt>
--- END enhanced_prompt ---

The node tolerates a Notes: header line and <think>-style reasoning wrappers (reasoning models emit those before the real answer), then extracts the block with a regex. If the block is missing, it raises a RuntimeError including the head of the raw reply rather than quietly passing the model's chat scaffolding downstream. That's the right call - silent fallback would let a garbage prompt into the sampler and waste the entire run - but it does mean a small, chatty model that ignores formatting will genuinely fail the node.

mode is the interesting input:

  • t2i (default) - an observer-style English paragraph, for text-to-image.
  • t2i_rgba - same, plus a forced RGBA "bookend sandwich" whether or not you asked for transparency.
  • edit - single-image edit instruction. Rewrite body is always English regardless of your input language.
  • multi_ref - multi-reference edit, addressing slots as <image1>โ€ฆ<imageN>.
  • remove_bg - short-circuits. The node returns a fixed background-removal block and makes no LLM call at all.

Two more things the tooltip is explicit about: output is always English, and text inside straight double quotes in your input is preserved verbatim in its original language - which is how you keep a short Chinese sign or a brand name spelled exactly as you typed it.

Reference images, captions, and the trap

For edit and multi_ref you can wire an IMAGE batch into reference_images. What happens next is not what people assume: the node makes a separate LLM call per image to caption it (system prompt _caption_image.txt), then injects those captions into the rewrite message as locked identity / wardrobe / palette data. The rewrite LLM never sees pixels - it sees your captioner's description of them.

Captions are cached in memory and on disk under <ComfyUI output>/mien_nodes/caption_cache/, keyed on both the image and the caption prompt - so editing _caption_image.txt invalidates the cache instead of serving you stale descriptions. caption_mode controls it: cache_memory_disk (default), cache_memory_only, no_cache, and force_recaption_once. The ceiling is about ten references; past that the node warns and forwards the full count anyway, and the model is likely to misbehave.

And the trap, straight from the author's own tooltip because it's the one people hit: a multi-view character sheet is a layout, not a reference. Feed in four standing views and you'll get four posed people in one frame. Crop to a single person - front or three-quarter - before wiring the image, and keep the output vertical.

Inputs, output, install

Set llm_service_connector, mode, user_input (the draft), and seed (0 lets the connector choose). temperature defaults to 0.7, max_tokens to 16384, timeout to 300 seconds - 16384 is generous on purpose because reasoning models count their thinking against the same cap. Output is a single STRING, enhanced_prompt; wire it into the sampler's prompt widget or the text-encode node.

cd ComfyUI/custom_nodes
git clone https://github.com/MieMieeeee/ComfyUI-MieNodes
cd ComfyUI-MieNodes && python -m pip install -r requirements.txt

Restart, or install via Manager (ComfyUI_MieNodes). No model downloads - the Qwen-Image checkpoint is yours to source separately; this node only writes text. Put a key in mie_llm_keys.json for whichever connector you use.

Where it bites

RuntimeError: โ€ฆ did not contain a --- BEGIN enhanced_prompt --- block after N attempts. The model ignored the format. Drop temperature, or use a more obedient model - this is the failure mode that node authors writing prompt enhancers keep warning about, and it's why the node refuses to fall back.

Captioning failed. The message names the fix: retry with caption_mode on no_cache to bypass a stale cache, and check the image actually has content the captioner can describe.

Timeouts on reasoning models. Bump timeout to 600 and remember the thinking counts against max_tokens.

remove_bg "still needs a connector." It never calls the LLM, but the connector input is a required socket, so ComfyUI won't queue the node without something wired into it. Connect any working connector and forget it.

Category๐Ÿ‘ MieNodes/๐Ÿ‘ Prompt Generator

Inputs (9)

NameTypeDefaultDescription
llm_service_connectorLLMServiceConnectorโ€”
modeCOMBOt2i - ๆ–‡็”Ÿๅ›พ(้ป˜่ฎค)Mode / ๆจกๅผ: t2i ๆ–‡็”Ÿๅ›พ(้ป˜่ฎค) โ€” observer English paragraph. t2i_rgba ้€ๆ˜Žๆ–‡็”Ÿๅ›พ โ€” same plus forced RGBA bookend sandwich. edit ๅ•ๅ›พ็ผ–่พ‘ โ€” single-image edit instruction (rewrite body is always English). multi_ref ๅคšๅ‚่€ƒ็ผ–่พ‘ โ€” multi-reference edit instruction (<image1>โ€ฆ<imageN>; rewrite body always English). remove_bg ๆŠ ๅ›พ โ€” fixed BG-remove block, no LLM call.
user_inputSTRINGRough idea / ่‰็จฟ: a sentence, an outline, a few lines, or a free paragraph. The rewriter expands it into the prompt the Qwen-Image-2.1 sampler consumes. Output is always English; verbatim text inside straight double quotes in your input is preserved as-is. / ๆ‰ฉๅ†™ๆญฃๆ–‡ไธ€ๅพ‹่‹ฑๆ–‡๏ผ›็›ดๅŒๅผ•ๅทๅ†…็š„ๅญ—็ฌฆไธฒไฟ็•™ๅŽŸ่ฏญ็งไธŽ้€ๅญ—ใ€‚
seedINT00โ€“18446744073709550000Seed / ็งๅญ forwarded to the LLM call. 0 lets the connector pick a fresh seed.
reference_imagesoptIMAGEOptional IMAGE batch / ๅฏ้€‰ IMAGE ๆ‰นๆฌก. For mode=edit / multi_ref ๅ•ๅ›พ็ผ–่พ‘ / ๅคšๅ‚่€ƒ็ผ–่พ‘, the node captions each image (<image1>โ€ฆ<imageN>) with the bundled _caption_image.txt system prompt and injects the captions into the rewrite user message as locked identity / wardrobe / palette DATA. Pixels are visible to the captioner LLM but NOT to the rewrite LLM. / ๆ”นๅ†™ LLM ็œ‹ไธๅˆฐๅ›พใ€‚ Recommended ceiling: 10 (model slot limit); beyond that the node logs a warning but still passes the full count. IMPORTANT / ๆณจๆ„: ๅคš่ง†ๅ›พ่ฎพๅฎš่กจๆ˜ฏ็‰ˆๅผใ€‚ๅ››่บซๆจชๆŽ’ๅ–‚่ฟ›ๅŽป๏ผŒๆˆๅ›พไผšๅคๅˆถ่ฟ™ๆŽ’ไบบ๏ผŒๆฏไธชไบบไธ€ไธชๅงฟๅŠฟใ€‚ๅ…ˆ่ฃๆˆๅ•ไบบ๏ผˆๆญฃ้ขๆˆ–ๅ››ๅˆ†ไน‹ไธ‰ไพง้ข๏ผ‰ๅ†ๆŽฅ reference_images๏ผŒ่พ“ๅ‡บ็”จ็ซ–ๅน…ใ€‚็ผ–่พ‘่Š‚็‚น็œ‹่ง็š„ไปๆ˜ฏไฝ ๆŽฅไธŠ็š„้‚ฃๅผ ๅ›พ๏ผ›่ฟ™ไธช่Š‚็‚นๅชๅ†™ๆ็คบ่ฏใ€‚ A multi-view character sheet is a layout: four standing views in, four poses out. Crop to one person before wiring the image. Wire any sampler / loader output that emits an IMAGE batch โ€” e.g. LoadImageBatch or a custom collector.
caption_modeoptCOMBOcache_memory_disk - ็ผ“ๅญ˜:ๅ†…ๅญ˜+็ฃ็›˜(ๆŽจ่)Caption cache strategy / ๆ ‡ๆณจ็ผ“ๅญ˜็ญ–็•ฅ (only used when reference_images is connected and mode in {edit, multi_ref}). cache_memory_disk (recommended) ็ผ“ๅญ˜:ๅ†…ๅญ˜+็ฃ็›˜ โ€” in-memory + persistent on-disk cache under <ComfyUI output>/mien_nodes/caption_cache/. cache_memory_only ็ผ“ๅญ˜:ไป…ๅ†…ๅญ˜ โ€” RAM-only cache, lost on restart. no_cache ็ฆ็”จ็ผ“ๅญ˜ โ€” always bypass cache. force_recaption_once ๆœฌๆฌกๅผบๅˆถ้‡ๆ‰“ๆ ‡ โ€” force fresh captions now (e.g. after editing _caption_image.txt).
temperatureoptFLOAT0.700โ€“2Sampling temperature / ้‡‡ๆ ทๆธฉๅบฆ. 0.0โ€“2.0, step 0.05. Lower = strict adherence to system prompt; higher = more surface variation.
max_tokensoptINT1638464โ€“32768Token budget / Token ไธŠ้™. 64โ€“32768. Reasoning models count their thinking against this cap; 16384 is the safe default for the whole plugin.
timeoutoptCOMBO300Per-call timeout (seconds) / ๅ•ๆฌก่ฐƒ็”จ่ถ…ๆ—ถ(็ง’).

Outputs (1)

NameTypeDescription
enhanced_promptSTRINGโ€”