APNext Gemini Custom Vision
Flexible image-to-prompt with Gemini and dynamic templates
- images
- output
- clip_l
- faded_image
Of the three cloud-vision nodes in dagthomas's pack (Gemini, GPT, Claude), this is the one I'd start with - Gemini's Flash models are fast and cheap, which matters a lot when you're iterating on captions. You give it an image and your own analysis prompt, and Gemini writes back a description shaped however you asked. Same "auto-prompter from an image" idea the community keeps asking for, with the flexibility of a custom instruction and a couple of genuinely useful extras: dynamic templates and multi-image blending.
The dynamic-template feature is the reason to reach for this over a plain captioner. If you're building LoRA training captions or a repeatable house style, you don't want to hand-edit the instruction for every subject - you want a template with placeholders. This node does that.
How it works
It encodes your images, substitutes any dynamic tokens into your custom_prompt, sends it to a Gemini model, and returns the text. Turn on dynamic_prompt and the tokens ##TAG##, ##SEX##, ##WORDS##, ##PRONOUNS## get filled from the tag, sex, words, pronouns inputs - so a template like "describe ##TAG##, use ##PRONOUNS## pronouns, ~##WORDS## words" becomes a reusable captioning machine. Feed it several images and fade_percentage blends them into one composite (and hands that composite back), which is handy for style-averaging a few references.
The inputs and outputs that matter
images- the image(s) to analyze.custom_prompt- your instruction. This is the node's core; write it, or load one withCustomPromptLoader.gemini_model- the dropdown (2.5 Pro through the Flash and Flash-Lite tiers). Flash is the fast, cheap default and fine for most captioning; Pro for harder scenes.dynamic_prompt+tag/sex/words/pronouns- the LoRA-caption template system.fade_percentage(0.1–50) - blend strength when you pass multiple images.seed+randomize_each_run- vary the output across a batch.
Three outputs: output (the full description), clip_l (a trimmed variant for a CLIP-L text slot), and faded_image (the blended composite).
How to install it
ComfyUI Manager: search comfyui_dagthomas, install, restart. Manual:
cd ComfyUI/custom_nodes && git clone https://github.com/dagthomas/comfyui_dagthomas
cd comfyui_dagthomas && pip install -r requirements.txt
then restart. It needs the google-generativeai library (in requirements.txt) and a key. Set GEMINI_API_KEY in the environment before launching ComfyUI.
Where people get burned
GEMINI_API_KEYmissing or set late. Export it before starting ComfyUI; it's read at startup. This is the number-one "the node does nothing" cause.- Won't run on hosted ComfyUI. Serverless/shared instances block outbound calls and custom env vars - use a local vision node (QwenVL, MiniCPM, Florence-2) there.
##TAG##showing up literally. That meansdynamic_promptis off. Toggle it on to activate substitution.- Match output to model. Gemini writes prose by default - great for Flux/Z-Image, wrong for a tag-based SDXL/Illustrious workflow. Tell it to emit tags in your
custom_promptif that's your target, and lean on theclip_loutput for the CLIP-L slot on dual-encoder models. - Model name drift. The dropdown may list a Gemini variant your key can't hit; that errors at runtime. The list is editable JSON (
data/gemini_models.json).
Inputs (12)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| custom_prompt | STRING | — | |
| additive_prompt | STRING | — | |
| dynamic_prompt | BOOLEAN | false | — |
| tag | STRING | ohwx man | — |
| sex | STRING | male | — |
| words | STRING | 100 | — |
| pronouns | STRING | him, his | — |
| fade_percentage | FLOAT | 15.00.1–50 | — |
| gemini_model | COMBO | 5 options: gemini-2.5-pro, gemini-flash-latest, gemini-2.5-flash, gemini-flash-lite-latest, gemini-2.5-flash-lite | |
| seed | INT | -1-1–18446744073709550000 | — |
| randomize_each_run | BOOLEAN | true | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| output | STRING | — |
| clip_l | STRING | — |
| faded_image | IMAGE | — |