NanoB Edit Gemini
Gemini image editing without a single local model
- image1
- image2
- image3
- image4
- image5
- image6_14
- edited_images
This node does something most ComfyUI nodes don't: zero local inference. NanoB Edit Gemini is a bridge that turns your graph into a client for Google's Gemini image API - the "Nano Banana" family. You feed it up to 14 reference images plus a prompt, it phones home to Google, and out comes an edited image. Your GPU sits idle, you download nothing, and every render costs a little money instead of electricity.
That's the trade you're signing up for, and it's worth being clear-eyed: any workflow depending on Google's API is hostage to Google's pricing and policies - those models are "powerful, unimaginative, and heavily censored" per one well-upvoted take. But when you need Gemini's genuinely strong instruction-following and text rendering on a deadline, there is no local checkpoint that matches it. This node is how you get it inside a ComfyUI graph, beside your local stuff, instead of tabbing over to ImageFX.
How it works
No google-genai SDK here - the pack calls the raw REST endpoint https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent with plain requests. Your input tensors get converted to PNG bytes, base64-encoded, and attached as inlineData image parts with your prompt as the trailing text part (the author deliberately sends images first, which improves Gemini's image understanding). If use_file_api is on, images are uploaded first and referenced by URI instead.
The node supports three models: gemini-2.5-flash-image (Nano Banana), gemini-3-pro-image-preview (Nano Banana Pro, the default), and gemini-3.1-flash-image-preview (Nano Banana 2). Each has baked-in caps - 2.5 Flash is limited to 3 references and 1K resolution, while the 3.x models take up to 14 images and native 4K. Requests run in parallel via a thread pool, so num_images of 4 means four concurrent calls, not four sequential ones.
The inputs that matter
- prompt - multiline. Be concise but explicit; the README's own advice is that clear, concrete edits beat flowery language.
- model - pick your Nano Banana flavor. Defaults to Pro.
- gemini_api_key - leave it blank and set
GEMINI_API_KEYin your environment instead. The node prefers the env var and ignores a mismatched UI key. Do not publish workflows with a key baked into the node. - resolution -
0.5K–4K. Note the traps:0.5K(mapped to512) is only valid on 3.1 Flash, and 2.5 Flash is pinned to1Khere. - num_images - 1–4 variations, run in parallel.
- use_file_api - turn this on for big or many inputs. Inline payloads are preflight-checked against a ~19 MB budget; if you blow past it, the node fails early and tells you to flip this switch.
- use_google_search / enable_thinking - both are model-gated. Search applies to the 3.x models; thinking only exists on 3.1 Flash (mapped to a
HIGHvsMINIMALthinking level).
On the image side you get five single-image sockets (image1–image5) plus image6_14, a batched IMAGE socket that slurps up the rest. Feed up to 14; anything beyond gets truncated with a warning. One honest limitation: the node can't tell object references from character-consistency references, so it only enforces the global cap and warns if you exceed a model's recommended range.
The single output, edited_images, is an IMAGE batch stacked from however many requests succeeded - wire it into SaveImage or a PreviewImage and you're done.
Installing
Nothing heavy here. The only real dependencies are requests, torch, and PIL - all already inside ComfyUI. Install via Manager (search "ComfyUI-NanoB-Edit-Gemini") or:
cd ComfyUI/custom_nodes
git clone https://github.com/comrender/ComfyUI-NanoB-Edit-Gemini
Restart ComfyUI, then set GEMINI_API_KEY (Windows: Environment Variables; Linux/macOS: add export GEMINI_API_KEY="..." to your shell profile), and restart once more. There are no model files to download and no GPU requirement - that's the whole point.
Where people get burned
- No API key → instant
ValueErrortelling you exactly that. Check the console. - The bill - each render is pay-per-image, and 4K Pro images cost more than 1K. Set
num_imagesto 1 while you're iterating. - Censorship -
safety_filterdefaults toblock_none, but that only relaxes Google's API thresholds. The model's built-in image-safety filtering and invisible SynthID watermark are non-negotiable. If a prompt is blocked, the node logs thepromptFeedbackblock reason. - Request failures - HTTP and network errors get per-request diagnostics; a response with no image prints the finish reason plus a text snippet, which is usually enough to see that Gemini decided to explain instead of render.
For a one-off edit with Gemini's chops, this node is hard to beat. For a 2,000-image batch where a local model would cost you nothing per image, do the math before you hit run.
Inputs (19)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | Edit the image according to this prompt. | — |
| model | COMBO | gemini-3-pro-image-preview | 3 options: gemini-3-pro-image-preview, gemini-3.1-flash-image-preview, gemini-2.5-flash-image |
| gemini_api_key | STRING | — | |
| seed | INT | 00–18446744073709550000 | — |
| aspect_ratio | COMBO | 1:1 | 14 options: 16:9, 1:1, 1:4, 1:8, 21:9, 2:3, +8 |
| resolution | COMBO | 1K | 4 options: 0.5K, 1K, 2K, 4K |
| output_format | COMBO | png | 3 options: png, jpg, webp |
| num_images | INT | 11–4 | — |
| use_file_api | BOOLEAN | false | — |
| use_google_search | BOOLEAN | false | — |
| enable_thinking | BOOLEAN | false | — |
| safety_filter | COMBO | block_none | 4 options: block_none, block_few, block_some, block_most |
| debug_payload | BOOLEAN | false | — |
| image1opt | IMAGE | — | |
| image2opt | IMAGE | — | |
| image3opt | IMAGE | — | |
| image4opt | IMAGE | — | |
| image5opt | IMAGE | — | |
| image6_14opt | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| edited_images | IMAGE | — |