ComfyUI Node

PVL Gemini Api

Batch prompts, retries, and one text output

By pvlprk·Created about a year ago·Updated 8 months ago· 1
PVL Gemini Api
  • image
  • text
modelgemini-2.5-flash
tries2
timeout45
temperature1.00
top_p0.95
top_k65
batch1
delimiter[++]
append_variation_tagfalse
debugfalse
instructions
prompt
seed0
api_key

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

  • prompt and instructions - what to ask, and how to frame it. Multiline, so multi-paragraph system prompts are fine.
  • model - gemini-2.5-flash by default; the dropdown also offers gemini-2.5-pro, flash-lite, and 2.0-flash. Flash is the right default for most ComfyUI work; pro when you need reasoning and don't mind waiting.
  • batch and delimiter - the parallel-variation system described above. Default delimiter is [++].
  • tries (default 2) and timeout (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.

CategoryPVL/LLM

Inputs (15)

NameTypeDefaultDescription
modelCOMBOgemini-2.5-flash4 options: gemini-2.5-pro, gemini-2.5-flash, gemini-2.5-flash-lite, gemini-2.0-flash
triesINT21–10
timeoutINT451–600
temperatureFLOAT1.000–2
top_pFLOAT0.950–1
top_kINT651–1000
batchINT11–64
delimiterSTRING[++]
append_variation_tagBOOLEANfalse
debugBOOLEANfalse
instructionsSTRING
promptSTRING
seedINT0
imageoptIMAGE
api_keyoptSTRING

Outputs (1)

NameTypeDescription
textSTRING