AS_GeminiCaptioning
Hand an image to Gemini, get back a ready-to-run SDXL or FLUX prompt
- IMAGE
- RESULT PROMPT
- REQUEST TEXT
- LOG
This is the flagship of the AS_LLM_nodes pack, and the one you'll actually reach for. Drop an image in, and Gemini writes a text prompt that describes it - not as a flat caption, but as a generation prompt, already styled for the model family you're going to run. You've seen this workflow before: it's how people reverse-engineer a prompt from a picture they like, re-create a photo as an img2img starting point, or batch-caption a folder of images for training.
The one thing to get straight up front: the image leaves your machine. This is a Google Gemini API call, not a local captioner like the Pixtral-based caption models people run in ComfyUI. You need a Gemini API key, you need the internet, and every image you caption gets uploaded. If "fully local" is a hard requirement for your pipeline, this node is the wrong tool.
How it works
The node takes your image tensor, converts it to bytes, base64-encodes it, and sends it to Gemini alongside a carefully constructed instruction prompt. That instruction is the interesting part: it tells Gemini to return only a descriptive text prompt, no commentary, no headings, formatted to match a reference example. The result comes back as a string you can wire straight into a KSampler's positive prompt.
The PROMPT TYPE toggle is the whole point
- SD1.5 – SDXL - instructs Gemini to write a comma-separated, CLIP-style keyword list ("hyper-detailed, RAW photo, cinematic wide-angle") in the Danbooru-adjacent tag style those models expect.
- FLUX - instructs it to write flowing natural-language prose, because Flux's T5 text encoder wants sentences, not tags.
That split mirrors how prompting actually works now: the text encoder decides what your prompt should look like, and SDXL-lineage models want tag soup while Flux wants instructions. Most captioning tools make you choose one style and stick with it; this node bakes the distinction in and picks the right default reference text for you.
Inputs and outputs that matter
Required inputs: IMAGE, PROMPT TYPE, APY KEY PATH, and GEMINI MODEL (defaults to Gemini 2.0 Flash, with Flash-Lite, 1.5 Flash, and 1.5 Pro as alternatives). Yes, that's "APY" - a typo baked into the node's source. If you're hunting for it in a workflow JSON, search for the typo, not the word "API."
The optional fields are where the control is:
- PROMPT REFERENCE - paste your own example of a good prompt and Gemini matches that style instead of the built-in defaults.
- PROMPT STRUCTURE - controls the ordering (default: building type, materials, surroundings, lighting, camera).
- IGNORE / EMPHASIS - stuff to leave out or lean into.
- PROMPT LENGTH - approximate word count. Small quirk in the source: the instruction hardcodes "50" before your number, so a value of 80 produces "close to 50 80" in the payload. Gemini shrugs and figures it out; don't sweat it.
- SAVE TO PATH + TXT NAME - write the result to a
.txtfile (defaults toresult.txt), handy for batch runs.
Outputs are RESULT PROMPT (the caption), REQUEST TEXT (the exact payload sent to Google - gold for debugging), and LOG (step-by-step status). On an error, the error lands in the log and the prompt output comes back empty.
Installing it
cd ComfyUI/custom_nodes
git clone https://github.com/svetozarov/AS_LLM_nodes
then restart, or search AS_LLM_nodes in ComfyUI Manager and let it install and resolve the pip dependencies (google-generativeai, openai, Pillow, requests). No model downloads - everything lives in Google's cloud.
Troubleshooting
Most failures come from the key file: the path is wrong, the file has a trailing space or quote, or the key itself is invalid. The LOG output tells you exactly which stage failed, so read it before guessing.
Two model-specific notes. The "Gemini 2.0 Flash-Lite" option maps to the old gemini-2.0-flash-lite-preview model id in the source; if Google has since retired that alias you'll get a 404-style error and should fall back to 2.0 Flash. And because the key path lives in the workflow file, sharing a workflow exposes your key's path, not the key itself - but any node you install runs arbitrary code, and this pack is tiny enough to have no real community track record. Two minutes reading AS_LLM_nodes.py before you hand it a billed key is the right amount of paranoia.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| IMAGE | IMAGE | — | |
| PROMPT TYPE | COMBO | SD1.5 – SDXL | 2 options: SD1.5 – SDXL, FLUX |
| APY KEY PATH | STRING | — | |
| GEMINI MODEL | COMBO | Gemini 2.0 Flash | 4 options: Gemini 2.0 Flash, Gemini 2.0 Flash-Lite, Gemini 1.5 Flash, Gemini 1.5 Pro |
| PROMPT LENGTHopt | INT | 0 | — |
| PROMPT REFERENCEopt | STRING | — | |
| PROMPT STRUCTUREopt | STRING | — | |
| IGNOREopt | STRING | — | |
| EMPHASISopt | STRING | — | |
| SAVE TO PATHopt | STRING | — | |
| TXT NAMEopt | STRING | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| RESULT PROMPT | STRING | — |
| REQUEST TEXT | STRING | — |
| LOG | STRING | — |