Nodes/Better-Gemini/Better Gemini
ComfyUI Node

Better Gemini

The Better Gemini node

By ttulttul·Created 9 months ago·Updated 28 days ago· 1
Better Gemini
  • prompt_images
  • IMAGE
  • STRING
prompt
modelmodels/gemini-3.1-flash-lite-image
response_modalitiesIMAGE+TEXT
api_key
aspect_ratioauto
resolutionauto
width0
height0
temperature0.90
top_p0.95
top_k40
max_output_tokens8192
thinking_difficultyauto
thinking_budget0
seed0
system_prompt
cache_outputsfalse

Google's Gemini image models - the Nano Banana family - are genuinely good, and they're the ones with the most annoying plumbing: image endpoints that differ from text endpoints, an official SDK, thinking controls, and seeds that start misbehaving past int32. Better Gemini is one node that swallows all of that. Give it a prompt and a key, and it talks to Gemini for you - whether you want a 4K image out of gemini-3-pro-image or a paragraph of text out of gemini-3-flash-preview.

Let's be clear about what this isn't. It doesn't generate locally. It's a pipe to a paid Google API, so every image costs real money and nothing runs on your GPU. What it buys you is a closed image model sitting inside your ComfyUI graph - which means you can take a Gemini output, wire it straight into your local upscaler or img2img pass, and treat the API as just another node in the pipeline. That's the trick: it's the only kind of node that turns a cloud service into a component you can chain.

How it works

The node uses the official google-genai SDK, and it's imported lazily so ComfyUI boots fine even before the dependency is installed - you only get an error when the node actually runs. The model dropdown is populated by calling models.list(), so with a valid API key you see Google's live model names; without one, it falls back to a bundled list that still works if you type the model in.

The response_modalities input is the one you'll touch most. IMAGE is pure generation, IMAGE+TEXT also returns any notes or revised-prompt text, and TEXT skips image generation entirely for chat-style calls. Gemini requires seeds to fit in an int32, so if you feed it a huge ComfyUI seed the node folds it deterministically via seed % 2**31 - same seed, same result every time, which is nicer than it sounds.

The inputs and outputs that matter

  • response_modalities - pick IMAGE, IMAGE+TEXT, or TEXT. Everything else is set dressing until you decide this.
  • model - image models and text models live in the same dropdown, which is the point.
  • prompt_images - drop a reference image in and the node sends it along, which turns a plain prompt into an edit or a style-reference call.
  • aspect_ratio / resolution - best-effort hints. The tooltip is honest: the model can ignore them, and the node logs a warning if the returned size doesn't match. For exact control set width and height (both, or neither).

Outputs are IMAGE and STRING. Wire IMAGE into a Save Image node; STRING carries the text result, and in IMAGE+TEXT mode any revised prompt or notes land there too. There's a system_prompt input and thinking controls (thinking_difficulty, thinking_budget) if you want to steer text calls, and cache_outputs stores identical requests under .cache/ so re-runs don't re-bill you. If you enable caching, identical future requests reuse the cached outputs without calling Gemini at all.

Install

Easiest is ComfyUI Manager - search "Better-Gemini". If it's not listed, the clone path always works:

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

Then restart ComfyUI and set your key, either as an env var or in the node's api_key input:

export GOOGLE_API_KEY="your-key-here"

The pack's only real dependency is google-genai (the README's uv sync path is more for development). One important catch: this is a V3-era ComfyUI extension, so it needs a recent ComfyUI build with the V3 extension loader. On an older install it won't load, and there's no legacy fallback.

Where people get burned

  • The blank 1×1 image. In TEXT mode, the IMAGE output is a minimal placeholder so the graph stays connected - it's not a bug. Don't wire that into a viewer expecting pixels.
  • Auth errors when you forgot the key - the dropdown silently falls back to bundled defaults, so the node can look fine and still fail at call time.
  • Resolution mismatch warnings are the model ignoring your hint, not a fault. Set width/height if it matters.
  • Missing google-genai surfaces only at execution, with a clear error telling you to install it.

Same pack also ships Better Grok, if you want xAI's take on cloud image gen without a second install.

Categoryapi node/image/BetterGemini

Inputs (18)

NameTypeDefaultDescription
promptSTRINGText prompt for image or text generation.
modelCOMBOmodels/gemini-3.1-flash-lite-imageGemini model name (populated via models.list; requires API key).
response_modalitiesCOMBOIMAGE+TEXTChoose IMAGE-only output, IMAGE+TEXT for multimodal responses, or TEXT for text-only generation.
api_keyoptSTRINGOptional. If empty, uses env var GOOGLE_API_KEY (or GEMINI_API_KEY).
prompt_imagesoptIMAGEOptional images to include with the prompt (reference / edit). Batched IMAGE tensors send multiple images.
aspect_ratiooptCOMBOautoIf 'auto', the model chooses. Otherwise requests a specific aspect ratio.
resolutionoptCOMBOautoRequested output resolution (best-effort; may be ignored by the model). Logs a warning if the returned image size doesn't match.
widthoptINT00–8192Optional override. Set > 0 to request a specific width (must set height too).
heightoptINT00–8192Optional override. Set > 0 to request a specific height (must set width too).
temperatureoptFLOAT0.900–2Sampling temperature (model-dependent).
top_poptFLOAT0.950–1Nucleus sampling (model-dependent).
top_koptINT400–1000Top-K sampling (model-dependent).
max_output_tokensoptINT81921–131072Max tokens for any text the model returns (model-dependent).
thinking_difficultyoptCOMBOautoHint for how much 'thinking' budget to allow (model-dependent).
thinking_budgetoptINT00–131072Optional override. Set > 0 to request an explicit thinking budget.
seedoptINT00–18446744073709550000Best-effort seed for determinism (not guaranteed). Set 0 for 'unset'. Gemini requires int32; larger values are folded.
system_promptoptSTRINGOptional system prompt. If set, it will be prepended to your prompt.
cache_outputsoptBOOLEANfalseCache model outputs under .cache and reuse them for identical Gemini requests.

Outputs (2)

NameTypeDescription
IMAGEIMAGE
STRINGSTRING