Nodes/sml-comfyui-prompt-expansion/SML Prompt Generator
ComfyUI Node

SML Prompt Generator

Let a cheap LLM write your Flux prompt for you

By smlbiobot·Created 2 years ago·Updated 2 years ago· 16
SML Prompt Generator
    • final_prompt
    system_promptYou are a creative writer tasked to turn basic stable diffusion prompts into something expressive, succinct, and beautiful.
    prompt
    seed-1
    min_char1000
    max_char3000
    output_widgetFinal prompt will display here. Set minimum and maximum characters to control output length. 1000 min and 3000 max is a good range to start.

    The one line nobody says up front

    The name is a little misleading: SML Prompt Generator doesn't generate your image and it doesn't run on your GPU. It calls DeepSeek's cloud API and asks an LLM to turn your two-line prompt into a lush, descriptive paragraph, which you then feed into your checkpoint like any other prompt. No model downloads, no VRAM, no local weights - the only requirement is a DeepSeek API key and an internet connection.

    Why would you bother? Because prompt expansion became a real thing for a real reason. The community habit of feeding a short idea to an LLM and pasting the result into ComfyUI went from a handful of mentions in 2023 to a constant practice by 2026, and it fits the architecture: Flux, SDXL and the newer LLM-encoded models read your prompt as an instruction, and a well-structured paragraph beats masterpiece, best quality, detailed almost every time. This node just automates the copy-paste step, right inside the graph.

    How it actually works

    Under the hood it's a single node (SML_Prompt_Generator) that opens the openai Python client pointed at https://api.deepseek.com, sends your prompt to deepseek-chat with a temperature of 1.5, and hands back the rewritten text. Two details are worth knowing before you judge it:

    • Randomized length. DeepSeek's API is effectively deterministic on identical input, so the node picks a random character count inside your min_charmax_char range and asks the model for exactly that many characters. Set a range, don't set min == max.
    • Sentence salting. If it detects you're feeding the same prompt as the last run, it grabs up to three random sentences from the previous output and appends them, forcing a different result. That's the "caching mechanism" the README mentions - it's the author's workaround for the API being too stable.

    The inputs that matter

    There are six widgets, and you'll actually touch four of them:

    • prompt - the short idea you want expanded. Empty by default, obviously the one you fill in.
    • system_prompt - the persona, defaulting to "You are a creative writer tasked to turn basic stable diffusion prompts into something expressive, succinct, and beautiful." If you're on a tag-based SDXL model and want comma-separated tags instead of prose, this is the field to rewrite.
    • min_char (10–5000, default 1000) and max_char (10–10000, default 3000) - target length. The README's advice holds: 1000–3000 is good for Flux/SDXL; dial it down for SD 1.5.
    • seed (default -1) - -1 rolls a random seed each run, which also feeds the API call.

    The output_widget is a read-only display field where the result shows up (a small JS extension pastes it there after each run) - you don't type in it. The node's one output, final_prompt (a STRING), is what you wire into your positive prompt input on CLIPTextEncode or your Flux/SDXL text encoder.

    Installing it

    Via ComfyUI Manager (search "sml-comfyui-prompt-expansion"), or the manual route:

    cd ComfyUI/custom_nodes
    git clone https://github.com/smlbiobot/sml-comfyui-prompt-expansion
    cd sml-comfyui-prompt-expansion
    pip install -r requirements.txt
    cp config.ini.example config.ini
    

    Then open config.ini, put your DEEPSEEK_API_TOKEN in (get it at platform.deepseek.com - you'll need an account with a small balance), and restart ComfyUI. The only dependency is the openai package, and there are no model files to fetch.

    Where people get burned

    • The README says "Replicate API token." That's stale copy-paste from an earlier project - ignore it. The code reads DEEPSEEK_API_TOKEN and calls api.deepseek.com. Make a DeepSeek key, not a Replicate one.
    • It costs money. DeepSeek is famously cheap, but it's an API with a meter running. If the node prints Error: DEEPSEEK_API_TOKEN not found in config.ini, that's your key not being read.
    • Don't expect it on SD 1.5. The README says so outright: it writes flowing prose, and SD 1.5 wants comma-separated tags. On the LLM-encoded models (Flux 2, Z-Image, Klein, Anima) it's at home, but keep the output tight - attention caps are real, and a 3,000-character essay can make a model drift.
    • No local fallback and no NSFW. It's a commercial API, so prompts get filtered and your machine never does the thinking. If you want that, people point to comfyui-ollama or ComfyUI-Llama instead. The author's own reddit thread (+59) made exactly this tradeoff explicit.

    It's a small, single-purpose pack by an independent dev, and it does one thing well: turn "a girl in the rain, cinematic" into a paragraph your Flux model actually relishes. If that's your workflow, it's worth the two minutes of setup.

    CategorySML Prompt Expansion

    Inputs (6)

    NameTypeDefaultDescription
    system_promptSTRINGYou are a creative writer tasked to turn basic stable diffusion prompts into something expressive, succinct, and beautiful.
    promptSTRING
    seedINT-1-1–100000000000
    min_charINT100010–5000
    max_charINT300010–10000
    output_widgetSTRINGFinal prompt will display here. Set minimum and maximum characters to control output length. 1000 min and 3000 max is a good range to start.

    Outputs (1)

    NameTypeDescription
    final_promptSTRING