NanoBanana - Prompt Refiner
Feed it a rough idea, get a prompt worth spending credits on
- network
- refined_prompt
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.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| api_key | STRING | NanoBanana - API key. Leave blank to use GEMINI_API_KEY env var. | |
| model | COMBO | gemini-2.5-pro | NanoBanana - model for prompt refinement. |
| custom_model | STRING | Override with a custom model ID. | |
| base_prompt | STRING | The prompt to refine and improve. | |
| targetopt | COMBO | image | What downstream generator the prompt is for. v2.0 hardcoded 'image generator', breaking the node for video/music/text refinement. |
| system_instructionopt | STRING | Instructions for how to refine the prompt. Leave empty for default behavior. | |
| thinking_levelopt | COMBO | NONE | How much the model should reason before answering. |
| temperatureopt | FLOAT | 0.700–2 | Controls randomness in refinement. |
| networkopt | NB_NETWORK | Optional. Wire a NanoBanana - Network Route node here to route this request through that proxy (e.g. US egress). |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| refined_prompt | STRING | — |