Nodes/ComfyUI-DSD/DSD Gemini Prompt Enhancer
ComfyUI Node

DSD Gemini Prompt Enhancer

Gemini reads your subject photo, then rewrites your prompt to actually describe it

By irreveloper·Created about a year ago·Updated about a year ago· 42
DSD Gemini Prompt Enhancer
  • image
  • enhanced_prompt
prompt
api_key

Here's the problem this node solves: you feed DSD a photo of your subject and type "the same character riding a skateboard," but the model only knows what the subject looks like from the image. If your prompt never says what the subject looks like, the model is left guessing what to preserve. This node points Google's Gemini 2.0 Flash at your reference image, gets it to describe the subject in detail, then merges that description into your prompt - so the text and the image conditioning actually agree on who's in the frame.

The name is a little misleading in one direction: it's not an LLM that just makes your prompt fancier. It's a caption-then-enhance pipeline. First it asks Gemini to caption your image (subject, environment, pose, lighting, camera, style). Then it feeds your raw prompt plus that caption back to Gemini with an instruction to keep what you wrote and enrich the rest with details from the caption. Out comes a single-line enhanced prompt - the node's instruction to Gemini caps it at 77 tokens. That's a design choice in the node (tight prompts cost less and drift less), not a hard encoder ceiling like the old CLIP limit.

What you need

  • image - your subject reference (feed the same image you'll give the DSD Image Generator).
  • prompt - your rough idea, e.g. "a character holding an umbrella in the rain."
  • api_key - your Gemini API key. The tooltip says it plainly: enter it here or set the GEMINI_API_KEY environment variable.

Please use the environment variable. This is a real gotcha, not a style suggestion: workflows get shared as JSON and embedded in PNGs, and a hardcoded key in a node input travels with them. The README is emphatic about it for the same reason.

The output, enhanced_prompt, is a string - wire it into the DSD Image Generator's prompt input. A bundled front-end extension also pastes the enhanced prompt onto the node itself after each run, which is handy for comparing what Gemini actually produced. Enable use_gemini_prompt on the generator if you want the workflow to acknowledge it, though that flag is cosmetic in the code - the wiring is what does the work.

The safety nets

This node is designed to fail soft. No key provided? Falls back to your original prompt. No google-genai installed (the pack's requirements list it, but a manual clone only installs them if you run pip install -r requirements.txt)? Falls back. API error? Falls back. So it can't brick your workflow - worst case it quietly does nothing. The cost side is the real consideration: every run is a couple of Gemini API calls, so it's free-ish to experiment but not free. And since it's an LLM, the enhanced prompt is sometimes worse than what you wrote. If a run gives you something off, treat the output as a suggestion, not gospel - you can always edit it and pass it back through.

If you get nothing back and your terminal shows a Gemini import warning, that's the missing google-genai dependency - after a manual clone, pip install -r requirements.txt fixes it. And if you never want to touch a paid API, skip this node entirely; DSD works fine with a hand-written prompt. The Enhancer is an accelerator for prompt quality, not a requirement.

CategoryDSD

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
promptSTRING
api_keySTRINGEnter your Gemini API key here or use the environment variable GEMINI_API_KEY.

Outputs (1)

NameTypeDescription
enhanced_promptSTRING