Nodes/SDXL Auto Prompter/APNext Gemini Custom Vision
ComfyUI Node

APNext Gemini Custom Vision

Flexible image-to-prompt with Gemini and dynamic templates

By dagthomas·Created 3 years ago·Updated 13 days ago· 283
APNext Gemini Custom Vision
  • images
  • output
  • clip_l
  • faded_image
custom_prompt
additive_prompt
dynamic_promptfalse
tagohwx man
sexmale
words100
pronounshim, his
fade_percentage15.0
gemini_model
seed-1
randomize_each_runtrue

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 with CustomPromptLoader.
  • 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_KEY missing 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 means dynamic_prompt is 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_prompt if that's your target, and lean on the clip_l output 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).
Categorycomfyui_dagthomas

Inputs (12)

NameTypeDefaultDescription
imagesIMAGE
custom_promptSTRING
additive_promptSTRING
dynamic_promptBOOLEANfalse
tagSTRINGohwx man
sexSTRINGmale
wordsSTRING100
pronounsSTRINGhim, his
fade_percentageFLOAT15.00.1–50
gemini_modelCOMBO5 options: gemini-2.5-pro, gemini-flash-latest, gemini-2.5-flash, gemini-flash-lite-latest, gemini-2.5-flash-lite
seedINT-1-1–18446744073709550000
randomize_each_runBOOLEANtrue

Outputs (3)

NameTypeDescription
outputSTRING
clip_lSTRING
faded_imageIMAGE