Nodes/ComfyUI-Gemini3-API-Fallback/πŸ€– Gemini 3 Pro (API Fallback)
ComfyUI Node

πŸ€– Gemini 3 Pro (API Fallback)

A Gemini-3 text brain for prompt engineering, captioning, and 64-prompt batches

By LatentnautΒ·Created 7 months agoΒ·Updated 3 months agoΒ· 0
πŸ€– Gemini 3 Pro (API Fallback)
  • images
  • text_output
β—„system_instructionYou are a creative writer. Describe the image in detail.β–Ί
β—„user_promptDescribe this imageβ–Ί
β—„batch_count1β–Ί
β—„modelgemini-3.5-flashβ–Ί
β—„seed0β–Ί
β—„max_output_tokens0β–Ί
β—„api_key_1β–Ί
β—„api_key_2β–Ί
β—„api_key_3β–Ί
β—„api_max_retries10β–Ί
β—„batch_delay2.5β–Ί
β—„use_comfyui_creditstrueβ–Ί
β—„bypassfalseβ–Ί

The πŸ€– Gemini 3 Pro (API Fallback) node - class name GeminiPromptGenerator - is the text half of this pack. Where its sibling draws images, this one runs an actual Gemini language model and hands you the text: expand a rough idea into a detailed image prompt, caption an image you feed it, translate a prompt, or batch-generate variations. It's the "make my prompts not-suck" node.

The pattern is well-trodden in ComfyUI: people use a strong cloud LLM to turn a vague thought into a rich, concrete prompt, then hand it to their local sampler. The community leans on exactly this move - one common flow is a local VLM describing an image, Gemini rewriting that into a prompt tuned for a specific model, then generating. This node is that middle step, and it's the same retry-hardened API plumbing as the image node, so it survives heavy batch work without dying on Google's 429s.

How it works

Like the image node, it streams from the Google GenAI SDK, and it brings the same resilience engine: up to three API keys rotated round-robin, exponential backoff for 503s, a 60-second cooldown on 429s, parsed "retry in Xs" delays, and stream-integrity retries. Safety filters are set to BLOCK_ONLY_HIGH to avoid refusal false positives on creative text.

Two things are special here. First, batch_count - set it to anything up to 64 and the node generates that many unique responses in one execution, offsetting the seed per item and load-balancing your keys across the batch. That's a genuinely useful feature for prompt-variation workflows (you can even wire the batch into a sampler seed grid). Second, the images input: feed it an IMAGE tensor and the node converts it to PNG parts, so you can ask Gemini "describe this image" and get a caption or style breakdown.

Note that the model dropdown here is the text model lineup - gemini-3.5-flash (default), gemini-3.1-pro-preview, gemini-3.1-flash-preview, several gemini-2.x options, and older 1.5s. That's a different list from the image node's, and it matters: don't feed this node an image and expect pixels back. It's text-only.

The fields that matter

  • system_instruction - the persona/instructions. Defaults to "You are a creative writer. Describe the image in detail."
  • user_prompt - your actual request.
  • batch_count - 1 to 64; how many independent responses to generate.
  • model, seed, max_output_tokens (0 = model default, up to 128,000).
  • api_key_1/2/3, api_max_retries, batch_delay - the retry system, same as the image node.
  • use_comfyui_credits, bypass - credits routing and last-result caching.
  • images (optional) - reference images for captioning or multimodal analysis.

Output: text_output, a STRING list (one entry per batch item), which you can wire into a CLIPTextEncode, a Save Text node, or a wildcard-style prompt builder.

Installing it

ComfyUI Manager (search "ComfyUI-Gemini3-API-Fallback"), or:

cd ComfyUI/custom_nodes
git clone https://github.com/Latentnaut/ComfyUI-Gemini3-API-Fallback
python -m pip install google-genai pillow numpy requests

then restart. No model downloads. Text models generally work on a free-tier key, though billing is recommended once you're running batches - and the same per-project quota rules apply, so three keys from one project don't triple your rate limit.

Gotchas worth knowing

  • Model IDs move fast. The dropdown lists gemini-3.5-flash as default, and the code remaps the 3.1/3.x entries to the IDs it knows. If you hit a 404, the model may not be available in your region or for your project tier yet - try a 2.x model.
  • Keys from the same project share quota. Rotating them gives you key-failure redundancy, not extra throughput; separate projects are required to actually scale.
  • Empty text means a retry. If the model streams nothing, the node treats it as an interrupted response and rotates keys - which is usually the right call, but can look like it's "stuck" during a heavy batch. The console logging shows exactly which key is being tried and why.

If you're already running prompt-enhancement through a hosted LLM in another pack, this node is mostly a different plumbing choice with a tougher retry system. If you're new to it, it's the easiest on-ramp to the "let Gemini write your prompts" workflow - and the batch support alone justifies the install.

CategoryGemini API

Inputs (14)

NameTypeDefaultDescription
system_instructionSTRINGYou are a creative writer. Describe the image in detail.β€”
user_promptSTRINGDescribe this imageβ€”
batch_countINT11–64β€”
modelCOMBOgemini-3.5-flash8 options: gemini-3.5-flash, gemini-3.1-pro-preview, gemini-3.1-flash-preview, gemini-2.0-pro-exp-02-05, gemini-2.0-flash, gemini-2.0-flash-lite-preview-02-05, +2
seedINT00–18446744073709550000β€”
max_output_tokensINT00–128000β€”
api_key_1STRINGβ€”
api_key_2STRINGβ€”
api_key_3STRINGβ€”
api_max_retriesINT101–100β€”
batch_delayFLOAT2.50–60β€”
use_comfyui_creditsBOOLEANtrueβ€”
bypassBOOLEANfalseβ€”
imagesoptIMAGEβ€”

Outputs (1)

NameTypeDescription
text_outputSTRINGβ€”