Gemini Batch Process
Caption a whole batch in one node
- images
- texts
- errors
Captioning one image is fun. Captioning fifty is a job. GeminiBatchProcess is the version of the Divergent Gemini node built for the job: give it a list of prompts (one per image), optionally a batch of images, and it fires off an API call for each one, collecting results and errors separately.
This is the node you reach for when you're prepping a training set or tagging a batch of generations for organization. It's the sibling of the single DivergentGeminiNode, with the same API-key plumbing, but it trades fine-grained controls for throughput - no thinking budget, no top-p/top-k, a shorter model list. It's built for "run this prompt against every image in the batch and give me the captions."
How it works
It loops over your list of prompts and calls the Gemini API once per prompt, converting each image in the images batch to JPEG bytes and attaching it to its matching prompt. There's a small mismatch guard built in: if you feed more prompts than images, the image list gets padded so every prompt still runs; if you feed more images than prompts, the extras get dropped. Each call runs with the shared retry settings, and per-item failures land in the errors output instead of killing the whole batch. One honest caveat from the source: there's no deduplication or shared-batch API - it's N sequential API calls, so cost and time scale linearly with your list.
Inputs that matter
- prompts - the list, one per line, one per image. This is the field that makes or breaks the batch.
- model - a shorter list than the single node:
gemini-2.0-flash,gemini-1.5-flash,gemini-1.5-pro. Flash is the sensible default for captioning; it's fast and cheap. - images (optional) - the IMAGE batch to caption.
- temperature and max_output_tokens - same semantics as the single node.
- api_key_override and max_retries - optional; the key resolution order (override →
config.json→ env var) is identical to the single Gemini node.
Outputs
- texts (STRING, list) - one generated result per prompt, in order.
- errors (STRING, list) - per-item error messages, empty string where a call succeeded.
Wire texts into a batch text handler or a text display; the pairing between texts[i] and prompts[i] is positional, which is fine as long as you remember batches don't rearrange themselves.
Installing it
Same pack, same dance as every other Divergent Nodes node:
cd ComfyUI/custom_nodes
git clone https://github.com/thedivergentai/divergent_nodes.git divergent_nodes
cd divergent_nodes
pip install -r requirements.txt
Or via ComfyUI Manager ("Divergent Nodes"). And the same API key setup: a config.json in the pack folder with GOOGLE_API_KEY, or a .env / environment variable.
Where people get burned
Two gotchas. First, watch your prompt list length against your batch size - padding means a prompt can run image-less without you noticing until you read the captions. Second, remember each item is its own paid API call; a long list at flash pricing is cheap, but the node will happily run a thousand calls if your list says so. The separate errors output is there for a reason: if some captions come back empty, that's where the explanation lives.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| model | COMBO | gemini-1.5-flash | 3 options: gemini-2.0-flash, gemini-1.5-flash, gemini-1.5-pro |
| prompts | STRING | List of prompts (one per image) | |
| temperature | FLOAT | 0.900–2 | — |
| max_output_tokens | INT | 20481–8192 | — |
| safety_harassment | COMBO | Block Medium & Above | 5 options: Default (Unspecified), Block Low & Above, Block Medium & Above, Block High Only, Block None |
| safety_hate_speech | COMBO | Block Medium & Above | 5 options: Default (Unspecified), Block Low & Above, Block Medium & Above, Block High Only, Block None |
| safety_sexually_explicit | COMBO | Block Medium & Above | 5 options: Default (Unspecified), Block Low & Above, Block Medium & Above, Block High Only, Block None |
| safety_dangerous_content | COMBO | Block Medium & Above | 5 options: Default (Unspecified), Block Low & Above, Block Medium & Above, Block High Only, Block None |
| imagesopt | IMAGE | Optional list of images | |
| api_key_overrideopt | STRING | — | |
| max_retriesopt | INT | 30–10 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| texts | STRING | — |
| errors | STRING | — |