ComfyUI Node

NanoB Edit Gemini

Gemini image editing without a single local model

By comrender·Created 9 months ago·Updated 6 months ago· 4
NanoB Edit Gemini
  • image1
  • image2
  • image3
  • image4
  • image5
  • image6_14
  • edited_images
promptEdit the image according to this prompt.
modelgemini-3-pro-image-preview
gemini_api_key
seed0
aspect_ratio1:1
resolution1K
output_formatpng
num_images1
use_file_apifalse
use_google_searchfalse
enable_thinkingfalse
safety_filterblock_none
debug_payloadfalse

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_KEY in 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.5K4K. Note the traps: 0.5K (mapped to 512) is only valid on 3.1 Flash, and 2.5 Flash is pinned to 1K here.
  • 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 HIGH vs MINIMAL thinking level).

On the image side you get five single-image sockets (image1image5) 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 ValueError telling you exactly that. Check the console.
  • The bill - each render is pay-per-image, and 4K Pro images cost more than 1K. Set num_images to 1 while you're iterating.
  • Censorship - safety_filter defaults to block_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 the promptFeedback block 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.

CategoryNanoGemini

Inputs (19)

NameTypeDefaultDescription
promptSTRINGEdit the image according to this prompt.
modelCOMBOgemini-3-pro-image-preview3 options: gemini-3-pro-image-preview, gemini-3.1-flash-image-preview, gemini-2.5-flash-image
gemini_api_keySTRING
seedINT00–18446744073709550000
aspect_ratioCOMBO1:114 options: 16:9, 1:1, 1:4, 1:8, 21:9, 2:3, +8
resolutionCOMBO1K4 options: 0.5K, 1K, 2K, 4K
output_formatCOMBOpng3 options: png, jpg, webp
num_imagesINT11–4
use_file_apiBOOLEANfalse
use_google_searchBOOLEANfalse
enable_thinkingBOOLEANfalse
safety_filterCOMBOblock_none4 options: block_none, block_few, block_some, block_most
debug_payloadBOOLEANfalse
image1optIMAGE
image2optIMAGE
image3optIMAGE
image4optIMAGE
image5optIMAGE
image6_14optIMAGE

Outputs (1)

NameTypeDescription
edited_imagesIMAGE