Nodes/MilitantHitchhiker-SwitchbladePack/Groq API Prompt Enhancer
ComfyUI Node

Groq API Prompt Enhancer

Groq API Prompt Enhancer

By MilitantHitchhiker·Created 2 years ago·Updated 11 months ago· 3
Groq API Prompt Enhancer
    • enhanced_text
    model
    text
    override_system_prompt

    Prompt enhancement - pasting a rough idea and getting a polished, detail-rich prompt back - went from niche to everywhere in the last couple of years, and the natural place to put it is right in the graph. Groq API Prompt Enhancer (class GroqAPIPromptEnhancer) is that: it takes your text, sends it to a Groq-hosted LLM, and returns an expanded prompt as a string you can feed straight into your CLIP encoder. One thing to get straight up front: this is a cloud call. It needs an API key, your prompt leaves your machine, and it will not work offline. The name isn't lying.

    How it works

    On first run the node checks for the groq Python package and pip-installs it automatically if it's missing - the only dependency in the whole pack. From then on, each execution builds a chat request: a system prompt (defaulting to the one in the config file) plus your text, sent to one of three Groq models with temperature 0.5 and max_tokens 1024. The enhanced result comes back as the enhanced_text output.

    Configuration lives in modules/groq_config.json inside the pack directory - that's ComfyUI/custom_nodes/MilitantHitchhiker-SwitchbladePack/modules/groq_config.json. It holds two fields:

    • api_key - your Groq API key (from console.groq.com). Empty by default; the node won't work until you set it.
    • system_prompt - the default system instruction. The shipped default is a strict one: "respond only with the improved prompt," no chit-chat, no offers to iterate. It's good; you'll probably leave it.

    You can override the system prompt per-node with the optional override_system_prompt input without touching the file.

    The inputs that matter

    • model - dropdown: gemma2-9b-it (fast, small, fine for casual enhancement), llama-3.1-8b-instant (the middle), llama-3.3-70b-versatile (slower, strongest). Start with gemma2 and escalate only if output quality is the bottleneck.
    • text - your raw prompt, multiline.
    • override_system_prompt - optional; replaces the config's system prompt for this node instance.

    Output is enhanced_text (STRING). Wire it into a CLIP Text Encode positive input and you're done.

    Installing it

    Via ComfyUI Manager, search MilitantHitchhiker-SwitchbladePack and install, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MilitantHitchhiker/MilitantHitchhiker-SwitchbladePack
    

    Restart ComfyUI, then set your API key in the config file before first use.

    Where people get burned

    The big trap is how errors are handled: the node doesn't raise - it returns a string like Error: API key not configured. Please edit groq_config.json. If you've already wired the output into your prompt encoder, you're now generating with the words "Error: API key not configured…" as your prompt. Test the node in isolation first, and glance at the output before trusting the connection.

    Other notes: the key sits in plaintext JSON, so treat the pack folder like a secret store. This is a per-call paid API, so a workflow that runs the node on every queue item burns tokens and adds latency per image. And if you use the llama-3.3-70b model at scale, the price and response time climb noticeably - for most image prompting, the small model gets you 90% of the value. The enhance-then-generate pattern is genuinely useful (it's how a lot of the community batch-explores prompts now), but budget for it: it's a network round-trip per generation, not a local node.

    CategoryMilitantAI/Switchblade/Text Processing

    Inputs (3)

    NameTypeDefaultDescription
    modelCOMBO3 options: gemma2-9b-it, llama-3.1-8b-instant, llama-3.3-70b-versatile
    textSTRING
    override_system_promptoptSTRING

    Outputs (1)

    NameTypeDescription
    enhanced_textSTRING