Nodes/ComfyUI-NanoBanana2/NanoBanana - Prompt Refiner
ComfyUI Node

NanoBanana - Prompt Refiner

Feed it a rough idea, get a prompt worth spending credits on

By IxMxAMAR·Created 6 months ago·Updated about a month ago· 4
NanoBanana - Prompt Refiner
  • network
  • refined_prompt
api_key
modelgemini-2.5-pro
custom_model
base_prompt
targetimage
system_instruction
thinking_levelNONE
temperature0.70

You know the workflow: the idea in your head is sharp, but the sentence you type into the prompt box is "nice mountain sunset lake" and the model gives you exactly that - a generic postcard. This node sits between your rough thought and your generator and makes the prompt worth paying for. It takes a base prompt, hands it to a Gemini text model with a prompt-engineering system instruction, and returns an expanded, detailed version.

It's the classic "LLM writes better prompts than you do" trick, but done right: the node targets the refinement at the specific downstream generator. That matters because an image prompt and a music prompt want very different vocabularies - you don't tell a music model about camera angles.

How it works

The target dropdown is the clever part. Set it to image, video, music, text, or code, and the node swaps in a matching instruction:

  • image → "an AI Image Generator (think Imagen, Midjourney, SDXL, FLUX)"
  • video → "an AI Video Generator (think Veo, Sora, Runway)"
  • music → "an AI Music Generator (think Lyria, Suno, Udio)"
  • text → "another LLM that will produce a final answer"
  • code → "a code-generating LLM (favor explicit type / API / framework names)"

Earlier versions hardcoded "image generator," which silently broke the node for everything else - the target picker fixed that. The system instruction also demands output only the refined prompt, no conversational fluff, so the result drops cleanly into your generator's prompt input.

Other knobs: thinking_level (default NONE), temperature (default 0.7), and a system_instruction override if you want to define your own refinement style. Default model is gemini-2.5-pro - a bit spendy but the refinement quality is the point of the node.

Output: refined_prompt, a STRING you feed straight into ImageGen, Imagen, MusicGen, or a text gen node.

Installation

Part of the NanoBanana2 pack:

cd ComfyUI/custom_nodes
git clone https://github.com/IxMxAMAR/ComfyUI-NanoBanana2
pip install google-genai

ComfyUI Manager: search NanoBanana2. Needs a Gemini API key from aistudio.google.com.

Gotchas

A few honest notes. Refinement adds tokens - and on the default gemini-2.5-pro, that's the pricey model - so for high-volume work consider switching the model dropdown to a flash variant; the quality difference is smaller than the price difference. The node rewrites, it doesn't preserve: if your base prompt has a precise technical term or a specific style name, re-read the output before running, because the refiner can sand off the edge you cared about. And it's a one-shot call, so the same input gives a different result on every run (the whole pack re-executes each queue) - if you find a great refinement, copy it out before you re-run.

CategoryNanoBanana2/Text

Inputs (9)

NameTypeDefaultDescription
api_keySTRINGNanoBanana - API key. Leave blank to use GEMINI_API_KEY env var.
modelCOMBOgemini-2.5-proNanoBanana - model for prompt refinement.
custom_modelSTRINGOverride with a custom model ID.
base_promptSTRINGThe prompt to refine and improve.
targetoptCOMBOimageWhat downstream generator the prompt is for. v2.0 hardcoded 'image generator', breaking the node for video/music/text refinement.
system_instructionoptSTRINGInstructions for how to refine the prompt. Leave empty for default behavior.
thinking_leveloptCOMBONONEHow much the model should reason before answering.
temperatureoptFLOAT0.700–2Controls randomness in refinement.
networkoptNB_NETWORKOptional. Wire a NanoBanana - Network Route node here to route this request through that proxy (e.g. US egress).

Outputs (1)

NameTypeDescription
refined_promptSTRING