Nodes/comfyui-jz/jz Gemini Generate
ComfyUI Node

jz Gemini Generate

Gemini image generation billed in real dollars

By j-zhang19·Created 28 days ago·Updated about 18 hours ago· 2
jz Gemini Generate
  • image
  • image_2
  • image_3
  • image_4
  • image_5
  • image_6
  • image_7
  • image_8
  • image_9
  • image_10
  • images
  • image
  • usage
  • total_tokens
promptGenerate an image of a cute dog.
service_account_base64
modelgemini-3-pro-image
locationus-central1
aspect_ratio1:1
resolution1K
seed0
backendgenerativelanguage
custom_model
batch_size1
aspect_ratio_in
resolution_in

ComfyUI ships a built-in "Nano Banana Pro (Google Gemini Image)" node, and here's the thing nobody tells you: it bills you in a made-up credit system (211 credits = $1) with zero visibility into what a single generation actually costs. Gemini Image Generate (Direct API) is the drop-in replacement that removes the middleman. It calls Google's Gemini image API with your own key and prints the real USD estimate on every run. If you already pay for a Google AI API key, or you're tired of watching credits evaporate without learning anything, this is the node you want.

A quick grounding in what "Nano Banana" even is, since the pack leans on it: Google's Gemini-native image lineup is closed and API-only - Nano Banana (Gemini 2.5 Flash Image), Nano Banana Pro (Gemini 3 Pro, 4K native, up to 14 reference images), and Nano Banana 2 (Gemini 3.1 Flash). The three model choices here map straight onto those tiers.

How it works

The node builds a Gemini GenerateContentConfig with your image size, aspect ratio, seed, and requested output modalities, then sends your prompt - plus any batched reference images - to models.generate_content. It pulls the image bytes back, saves a PNG to your ComfyUI output folder, and hands you a normal IMAGE tensor so the rest of your graph doesn't care that the pixels came from Google. The cost_info you see is an estimate from a per-model, per-resolution table (e.g. Pro at 1K–2K ≈ $0.13, 2.5 Flash at 1K ≈ $0.04), derived from output token counts.

One nice detail: seed is actually sent to the API here, so reproducibility on Gemini image generation is real - which is more than the video side of this pack can say.

The inputs that matter

  • model - Pro (best quality, $0.13–0.24), 3.1 Flash (balanced, $0.05–0.15), or 2.5 Flash (cheapest, $0.04, 1K only). The tooltip spells out the cost for each, which is worth reading before you habit-run Pro.
  • prompt - long and detailed is fine. Remember these are LLM-encoded models: structure the prompt as an instruction, and naming a real camera body or film stock is genuinely high-leverage.
  • images (optional) - batched reference images as visual context. The canonical trick: batch a background plus character photos and prompt "integrate these people into the background scene."
  • resolution / aspect_ratio - 512/1K/2K/4K, and the usual ratios. If a model doesn't support your pick it falls back silently, so 2.5 Flash is 1K no matter what you ask for.
  • timeout_sec - the field you'll actually touch. Default 120s, and the author notes the API can stall on macro / extreme-closeup prompts with Flash 3.1. If your queue locks up on a closeup, bump this instead of restarting ComfyUI.

Outputs

images (IMAGE) wires into any preview or save node. text (STRING) is the model's description when you're on IMAGE+TEXT. cost_info (STRING) is your per-run USD line. And cache_key (STRING) encodes every generation parameter deterministically - wire it into the ComfyUI-API-Optimizer's Hash Vault and identical runs become cache hits at $0.

Installing it

This is a ComfyUI Manager job: search "ComfyUI-Gemini-Direct" and hit install, or clone it by hand:

cd ComfyUI/custom_nodes/
git clone https://github.com/jeremieLouvaert/ComfyUI-Gemini-Direct.git
pip install -r ComfyUI-Gemini-Direct/requirements.txt

Restart and the nodes appear under Gemini Direct. Dependencies are light - google-genai>=2.0.0 and Pillow (PyTorch is already there). There is no model download: the model lives on Google's servers, which is the mental shift most people trip on. Set your key in one of three ways, checked in this order: a gemini_api_key.txt file in your ComfyUI root (recommended), a GEMINI_API_KEY environment variable, or pasting into the api_key input - that last one lands in your workflow JSON, so don't.

Common issues

  • "No API key found" - the error names all three fallbacks; you missed the file, the env var, or the input.
  • "No image generated. Model said: …" - that's Google's safety filter or a refusal, not a bug. Rephrase. Gemini image generation is heavily filtered (celebrity/IP restrictions tightened through 2026), and every image carries an invisible SynthID watermark.
  • Stalled queue - your prompt tripped the API's stall; raise timeout_sec.
  • Billing error - image generation needs billing enabled on the key, not just a free-tier key.
  • Stale SDK - if a model name 404s, pip install -U google-genai (the video half of this pack needs 2.0+ anyway).
Categoryjz/api

Inputs (23)

NameTypeDefaultDescription
promptSTRINGGenerate an image of a cute dog.
service_account_base64STRING
modelCOMBOgemini-3-pro-image5 options: gemini-3-pro-image, gemini-3.1-flash-image, gemini-3-pro-image-preview, gemini-3.1-flash-image-preview, custom
locationSTRINGus-central1
aspect_ratioCOMBO1:110 options: 1:1, 5:4, 4:5, 4:3, 3:4, 3:2, +4
resolutionCOMBO1K3 options: 1K, 2K, 4K
seedINT00–18446744073709550000
imageoptIMAGE
backendoptCOMBOgenerativelanguage2 options: generativelanguage, vertex
custom_modeloptSTRING
image_2optIMAGE
image_3optIMAGE
image_4optIMAGE
image_5optIMAGE
image_6optIMAGE
image_7optIMAGE
image_8optIMAGE
image_9optIMAGE
image_10optIMAGE
imagesoptIMAGEa LIST of images (e.g. from jz Resize Long Edge) — all frames are sent
batch_sizeoptINT11–8N parallel API calls -> N images out (one shared token, per-call retries)
aspect_ratio_inoptSTRINGoverrides the aspect_ratio dropdown when connected — e.g. jz Pad Calculator's aspect_ratio output
resolution_inoptSTRINGoverrides the resolution dropdown when connected — e.g. jz Pad Calculator's resolution output

Outputs (3)

NameTypeDescription
imageIMAGE
usageSTRING
total_tokensINT