Nodes/ComfyUI-ZMongo/05 Gemini Image + Text
ComfyUI Node

05 Gemini Image + Text

A multimodal vision call from your own render

By CentralFloridaAttorney·Created 5 months ago·Updated 2 months ago· 1
05 Gemini Image + Text
  • session
  • image
  • json
  • text
  • success
  • refresh
promptDescribe this image.
modelgemini-3.1-flash-image
max_output_tokens1024
temperature0.40
max_image_side1024
jpeg_quality85
system_instruction
gemini_prefix/gemini
refresh_token

05 Gemini Image + Text takes an image straight off your ComfyUI canvas, bundles it with a text prompt, and sends both to a Gemini vision model. It's how you get an LLM to look at what you just generated - describe it, critique it, caption it, or extract structured observations from it - without exporting the image and re-uploading it somewhere.

This is the node that closes the loop on the "self-critiquing workflow": generate → VAE decode → Gemini Image + Text → feed the critique back into a prompt rewriter → regenerate. It's also handy for the more mundane version: "describe this image" on demand, or a one-shot alt-text generator for assets you're about to save into a ZMongo collection.

How it works

Required inputs:

  • session - from the API Key Session node.
  • image - an IMAGE tensor. Anywhere images flow in ComfyUI works.
  • prompt - default "Describe this image."
  • model - default gemini-3.1-flash-image (note: an image-capable model, and a reminder to check what your account can reach with Gemini List Models).
  • max_output_tokens - default 1024.
  • temperature - default 0.4.
  • max_image_side - default 1024. The image is downscaled to this max dimension before sending - the vision model doesn't need full resolution, and smaller images send faster and cost less.
  • jpeg_quality - default 85. Compression knob for the upload.

Optional: system_instruction, gemini_prefix, refresh_token.

Under the hood it grabs the first frame of your tensor (a batch takes frame 0), clamps and converts it to JPEG bytes, base64-encodes them, and ships the whole thing to the backend - which forwards it to Gemini. Outputs:

  • json - full payload.
  • text - the model's response. The headline output.
  • success - boolean.
  • refresh - dirty token, for forcing downstream re-runs when the image changes.

Tips

  • First frame only. If you feed a video-ish or batched tensor, only frame 0 goes - the node is explicit about pulling tensor[0]. For multi-image analysis, call it per-image.
  • Downscale aggressively. max_image_side: 1024 is the default and usually plenty; bumping to 4096 costs tokens and latency for negligible quality on a caption.
  • The refresh output exists because this node should re-run when the upstream image changes - wire it to force re-analysis on a new render.

Install

ComfyUI Manager → ComfyUI-ZMongo, or:

cd ComfyUI/custom_nodes
git clone https://github.com/CentralFloridaAttorney/ComfyUI-ZMongo

restart. This node is local for the image encode (Pillow/numpy) and server-side for the Gemini call - so it needs the API session plus the pack's image deps, but no local Google SDK.

CategoryZMongo/06 Gemini

Inputs (11)

NameTypeDefaultDescription
sessionZMONGO_API_SESSION
imageIMAGE
promptSTRINGDescribe this image.
modelSTRINGgemini-3.1-flash-image
max_output_tokensINT10241–65536
temperatureFLOAT0.400–2
max_image_sideINT1024256–4096
jpeg_qualityINT8540–95
system_instructionoptSTRING
gemini_prefixoptSTRING/gemini
refresh_tokenoptSTRING

Outputs (4)

NameTypeDescription
jsonSTRING
textSTRING
successBOOLEAN
refreshSTRING