05 Gemini Image + Text
A multimodal vision call from your own render
- session
- image
- json
- text
- success
- refresh
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- anIMAGEtensor. Anywhere images flow in ComfyUI works.prompt- default "Describe this image."model- defaultgemini-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: 1024is the default and usually plenty; bumping to 4096 costs tokens and latency for negligible quality on a caption. - The
refreshoutput 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.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| session | ZMONGO_API_SESSION | — | |
| image | IMAGE | — | |
| prompt | STRING | Describe this image. | — |
| model | STRING | gemini-3.1-flash-image | — |
| max_output_tokens | INT | 10241–65536 | — |
| temperature | FLOAT | 0.400–2 | — |
| max_image_side | INT | 1024256–4096 | — |
| jpeg_quality | INT | 8540–95 | — |
| system_instructionopt | STRING | — | |
| gemini_prefixopt | STRING | /gemini | — |
| refresh_tokenopt | STRING | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| json | STRING | — |
| text | STRING | — |
| success | BOOLEAN | — |
| refresh | STRING | — |