Nodes/ComfyUI-Minitools/Prompt Optimizer v1.2 👻
ComfyUI Node

Prompt Optimizer v1.2 👻

An LLM Prompt Optimizer That Speaks Bernini's Task Language

By lepiai·Created 2 years ago·Updated 3 days ago· 8
Prompt Optimizer v1.2 👻
  • source_image
  • ref_images
  • video_in
  • enhanced_prompt
user_prompt
llm_text_modelqwen3.6-27b
llm_vl_modelqwen3.6-27b
bailian_sksk-
task_show【default】通用万能模式,不确定分类就选此项

The marquee node of the pack, and it's the only one that needs a cloud account

ByteDance's Bernini generation suite defines a taxonomy of prompt-enhancement tasks - text-to-image, text-to-video, image-to-video, subject-to-video, ad insertion, and friends. This node rebuilds that whole taxonomy on top of Alibaba's Bailian (百炼) LLM API, which is what the long class name is telling you. Don't let the name fool you into thinking it's Bernini-only: the README says it plainly, and it's true - this is a standalone prompt enhancer/generator that happens to speak Bernini's task language.

Which matters more in 2026 than it used to. As the prompt-engineering essay notes, current models encode your prompt with a general-purpose LLM rather than CLIP, so a well-structured instruction beats a tag soup. Feeding a vague idea through an LLM that rewrites it into a detailed English prompt is exactly the kind of lift this node does.

What it actually does

Give it a rough user_prompt and it returns an expanded, enhanced English prompt ready to wire into your text encoder. Connect a source_image, ref_images, or video_in and it becomes multimodal: it base64-encodes the images as PNGs and sends them to the model, so it can reverse-engineer a prompt from an image or edit based on what it sees. That's the single-image and multi-image caption/reverse path the README advertises for video workflows (first/last frame, subject replacement, style transfer).

How it works under the hood

The mechanism is straightforward and robust:

  • Uses the OpenAI Python SDK against DashScope's OpenAI-compatible endpoint (https://dashscope.aliyuncs.com/compatible-mode/v1).
  • Images are embedded as image_url chat content; video frames are sampled down to 3 frames before sending.
  • The task_show dropdown selects a matching system prompt and template per Bernini task class. The default mode ("通用万能模式") passes your text straight through with a generic system prompt - safe when you don't know the category.
  • It retries up to 8 times with a 60s timeout and allows 8192 completion tokens. Reference-image tasks request JSON output and pull the rewritten_text field.
  • It fails open: if the prompt is empty or the key doesn't start with sk-, it just returns your input unchanged. No crash, no surprise API bill.

The inputs that matter

  • user_prompt (multiline) - your raw idea. Empty is allowed (fail-open), so this works as a pure image→prompt tool.
  • task_show - the 13-option dropdown: 【default】generic, 【t2i】text→image, 【t2v】text→video, 【i2v】image→video (first/last frame), 【v2v】/【mv2v】whole-video restyle, 【r2v】/【r2i】reference-image generation, 【rv2v】subject replacement in video, 【ads2v】ad insertion, 【vrc2v】local object edits. When in doubt, leave it on default.
  • bailian_sk - your Alibaba Cloud Bailian API key (sk-...), typed straight into the node. Not hardcoded, which is refreshing given the sibling translation node in this pack edits its source file for keys.
  • llm_text_model / llm_vl_model - Qwen model names, default qwen3.6-27b for both. The VL model is used whenever there are images in the request.
  • Optional: source_image, ref_images, video_in (frames as IMAGE). Output: enhanced_prompt (STRING).

Getting a key and the real-world catches

Alibaba Cloud Bailian hands out a free token quota (the README says up to 1M tokens per model on signup) and serves the Qwen line through an OpenAI-compatible API, so the setup cost is one account and one pasted key. That's the good news.

The catches:

  • It's a cloud call. It costs tokens, needs internet, and each request takes seconds. Not something you want firing on every iteration of a seed search unless you like watching your quota drain.
  • The default model names are Bailian-specific. If you swap in a model DashScope doesn't serve, you get API errors, not graceful degradation.
  • It needs the openai package. It's in requirements.txt so Manager installs it, but if you cloned the pack manually and skipped pip install -r requirements.txt, this node is the reason nothing loads at all.

Installing

Same as the rest of the pack - ComfyUI Manager → search "ComfyUI-Minitools", or:

cd ComfyUI/custom_nodes
git clone https://github.com/lepiai/ComfyUI-Minitools

then restart. No model files to download; the only "model" is the one you're renting from Alibaba.

CategoryMiniTools

Inputs (8)

NameTypeDefaultDescription
user_promptSTRING
llm_text_modelSTRINGqwen3.6-27b纯文本任务使用的大模型名称
llm_vl_modelSTRINGqwen3.6-27b带图片/视频帧任务使用的多模态或视觉模型名称
bailian_skSTRINGsk-
task_showCOMBO【default】通用万能模式,不确定分类就选此项13 options: 【default】通用万能模式,不确定分类就选此项, 【t2i】文本生成静态图片,仅文字出图, 【t2v】文本生成完整视频,自动补充镜头光影与动态, 【i2i】单张图片图生图编辑,修改画面细节, 【r2i】参考多张图生成全新图片, 【i2v】单张或参考图+提示词生成对应视频(支持首尾帧、首中尾3帧), +7
source_imageoptIMAGE
ref_imagesoptIMAGE
video_inoptIMAGE

Outputs (1)

NameTypeDescription
enhanced_promptSTRING