PVL Gemini Api
Batch prompts, retries, and one text output
- image
- text
This is the node that makes ComfyUI a place where an LLM can actually think for you mid-workflow. It calls Google's Gemini API directly - the generativelanguage.googleapis.com v1beta endpoint - and returns text, which is the currency most automation in ComfyUI runs on. Wire it into a prompt-text builder and you've got a workflow that can rewrite its own prompts, caption an image, or summarize metadata before the sampler ever runs.
What sets it apart from the simpler "one call per execution" Gemini nodes floating around is the batch machinery. batch runs multiple calls in parallel (up to 64), and delimiter joins their outputs into one string. Combined with append_variation_tag, it becomes a prompt-variation generator: flip that on with batch at 4 and it appends "Variation 1/2/3/4" to each call, then hands you all four results joined by the delimiter - ready to feed a batch-capable sampler or a queue.
How it works
The node takes your instructions (system-style context) and prompt, plus an optional image (it converts the first frame of the tensor and sends it inline), and makes parallel Gemini calls. The retry logic is genuinely thoughtful: retryable failures (rate limits, timeouts, overload) get retried up to tries times with linear backoff - 1s, then 2s, then 3s - while hard 4xx errors fail fast instead of wasting your retries. Only the failed items are retried, not the whole batch. Results come back combined into a single text output.
The inputs that matter
promptandinstructions- what to ask, and how to frame it. Multiline, so multi-paragraph system prompts are fine.model-gemini-2.5-flashby default; the dropdown also offersgemini-2.5-pro,flash-lite, and2.0-flash. Flash is the right default for most ComfyUI work; pro when you need reasoning and don't mind waiting.batchanddelimiter- the parallel-variation system described above. Default delimiter is[++].tries(default 2) andtimeout(default 45s) - leave them alone until you're hitting rate limits.temperature,top_p,top_k- standard sampling knobs; 1.0 / 0.95 / 65 are sane defaults.seed- Gemini isn't a diffusion model, but it does support a seed for more reproducible outputs. Set it if you want closer-to-deterministic runs.
The optional image input makes it multimodal - connect any IMAGE and it becomes a vision call. api_key is optional too: leave it blank and the node reads GEMINI_API_KEY from the environment.
Installing it
Part of the pvlprk "ComfyUI Assistant Node" pack:
cd ComfyUI/custom_nodes
git clone https://github.com/pvlprk/comfyui-pvl-api-nodes
Restart ComfyUI, then either set GEMINI_API_KEY in your environment or type the key into the node's api_key field. No models to download.
Common issues
The main gotcha is the batch behavior: with batch at 1 (the default) the delimiter is irrelevant, and with append_variation_tag off, every parallel call sends the same prompt - which is useful for redundancy but wastes money if you expected variation. Second, Gemini has safety blocks, and a blocked call is a hard (non-retryable) failure - the node will raise on it, not silently retry, which is correct behavior but confusing if you don't realize the model refused. Finally, the whole batch aborts if any item permanently fails - the error names the failed indices, so a rate-limited run on a big batch should just be retried with more tries. And yes, prompts go to Google's servers; fine for most stuff, worth remembering for proprietary workflows.
Inputs (15)
| Name | Type | Default | Description |
|---|---|---|---|
| model | COMBO | gemini-2.5-flash | 4 options: gemini-2.5-pro, gemini-2.5-flash, gemini-2.5-flash-lite, gemini-2.0-flash |
| tries | INT | 21–10 | — |
| timeout | INT | 451–600 | — |
| temperature | FLOAT | 1.000–2 | — |
| top_p | FLOAT | 0.950–1 | — |
| top_k | INT | 651–1000 | — |
| batch | INT | 11–64 | — |
| delimiter | STRING | [++] | — |
| append_variation_tag | BOOLEAN | false | — |
| debug | BOOLEAN | false | — |
| instructions | STRING | — | |
| prompt | STRING | — | |
| seed | INT | 0 | — |
| imageopt | IMAGE | — | |
| api_keyopt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |