Nodes/Comfyui_gemini_node/Google Gemini - Image Analysis
ComfyUI Node

Google Gemini - Image Analysis

Ask Gemini what's in your image — without leaving the graph

By DannyTuu·Created 5 months ago·Updated 5 months ago· 0
Google Gemini - Image Analysis
  • image1
  • image2
  • image3
  • image4
  • analysis
prompt
modelgemini-3.1-pro-preview
api_key
base_url
temperature1.0
top_p0.95
max_tokens8192
system_instruction

Google Gemini - Image Analysis is the pack's vision node: you hand it up to four images and a text prompt, it asks Google's Gemini model what it sees, and it hands you back a text answer. Out of the box you've got a captioner, an image-QA bot, a "which of these is the better render" judge, or the decision-maker for a smarter workflow - all inside your node graph, no local VLM weights eating VRAM.

How it works

This is a thin REST client, not a model runner. It converts each input image to a PNG, base64-encodes it, stuffs it into the inlineData parts of a generateContent request, appends your prompt, and posts it to Gemini. The node then returns the first text part of the reply. One nice detail in the source: it explicitly skips thought parts, so you get the actual answer and not Gemini's private chain-of-reasoning that some endpoints return alongside it.

The inputs that matter

  • prompt (required, multiline) - what you want to know. "Describe this in detail for a prompt," "Are these two images the same person?" - the whole point of the node.
  • model (required, free text, defaults to gemini-3.1-pro-preview) - note this one is a plain text field, not a dropdown, because you can type any Gemini model id. Bigger models reason better and cost more; the defaults are fine for most captioning.
  • image1–image4 - up to four inputs. Feed them from Load Image nodes. That's your multi-image context, and it's what makes this a comparison/routing tool rather than just a captioner.
  • temperature (0–2), top_p, max_tokens - sampling knobs. Defaults are sensible; dial temperature down if you want more factual, less creative answers.
  • system_instruction (multiline) - a system prompt, e.g. "You are a professional tagger. Reply with comma-separated booru tags only."
  • api_key / base_url - runtime overrides. Leave empty if you've set the key once in the pack's Config Manager node.

The single output is analysis (a STRING). Wire it to a text display node, into a prompt template, or into a conditional/switch node to route the graph based on what Gemini said. That last one - "is this image a face or not, then do X" - is where this node earns its keep.

Install

cd /path/to/ComfyUI/custom_nodes
git clone https://github.com/DannyTuu/Comfyui_gemini_node.git
python -m pip install -U requests pillow numpy

Restart ComfyUI, or search Comfyui_gemini_node in ComfyUI Manager. No model downloads; the pack is a pure API client. You need a Gemini API key (Google AI Studio) or a compatible relay endpoint.

Where people get burned

  • "Error: API key not provided." You never configured the key. Use the pack's Config Manager node to set it, or type it into api_key on this node.
  • Cost creep. Every run is a paid API call. If you're captioning a dataset of thousands of images, that bill adds up - for batch local captioning, a free local model like Florence-2 or JoyCaption is usually the better tool. Reach for this when you need Gemini's reasoning quality or multi-image understanding, not for mass captioning.
  • Your images leave the machine. That's the mechanism, not a bug: your prompts and reference images are logged by Google for abuse monitoring. If you're analyzing anything you'd rather keep local, don't.
  • Errors come back as strings. The node returns errors like Error: ... through the analysis output rather than throwing, so a failed run can look like a successful one if you're not reading the text. Glance at the output before you trust it.
CategoryGoogle/Gemini

Inputs (12)

NameTypeDefaultDescription
promptSTRING
modelSTRINGgemini-3.1-pro-preview
image1optIMAGE
image2optIMAGE
image3optIMAGE
image4optIMAGE
api_keyoptSTRING
base_urloptSTRING
temperatureoptFLOAT1.00–2
top_poptFLOAT0.950–1
max_tokensoptINT81921–65536
system_instructionoptSTRING

Outputs (1)

NameTypeDescription
analysisSTRING