Gemini API
Google's models as a ComfyUI node (and a sneaky prompt optimizer)
- image1
- image2
- image3
- image4
- image5
- video
- audio
- text
This is the flagship node of the pack - the one it's named after. It pipes Google's Gemini models into a ComfyUI graph for two jobs: ask a language model questions (text, images, video, or audio in), and - more useful for image folks - have it rewrite your rough idea into a polished, model-specific prompt before it hits your sampler. The output is a plain string, so it drops into a CLIP Text Encode.
What it's actually for
Two jobs live in one node.
As a chatbot / vision model: set input_type to image and wire a picture into one of the image1–image5 slots, and Gemini will describe it, caption it, or answer questions about it. That's your auto-captioner for building datasets, or a "what's in this render" sanity check. It also accepts video and audio inputs on the models that support them.
As a prompt optimizer: this is the part people actually want and the reason nodes like this exploded. Flip structure_output on, pick a prompt_structure template - FLUX.1-dev, SDXL, Imagen4, VideoGen, FLUXKontext, GeminiNanaBananaEdit - and Gemini takes your lazy one-liner and expands it into a full prompt written the way that target model likes to be talked to. This matters because in 2026 prompting is encoder-specific: an SDXL-lineage model wants comma-separated tags, while FLUX and the newer LLM-encoded models want a plain-language instruction. Having a language model translate your intent into the right dialect is a genuinely sound idea - the community went from barely mentioning "prompt enhancer" nodes to treating them as standard kit, because if the model reads your prompt like an instruction, letting an LLM write that instruction is translating between two things that speak the same language.
The inputs and outputs that matter
Beyond prompt, the few worth knowing:
gemini_model- the eight choices run fromgemini-2.5-pro-exp(smartest, slower) down through the2.0-flashand1.5-flashtiers (fast, cheap, plenty for prompt work). Start on a flash model; you rarely need pro to rewrite a prompt.structure_output+prompt_structure- the optimizer switch and which target-model template to use. Leavestructure_outputoff and it's a plain chat call.structure_format- the instruction that governs the output. It defaults to "Return only the prompt text itself. No explanations or formatting," which is exactly what you want so the model doesn't wrap your prompt in "Sure! Here's a great prompt:".api_key(optional) - paste your key here directly, or leave it blank and let the node read it from the pack's config file.
The single output is text. Route it into a CLIP Text Encode's text box, or a Save Text node, or straight into another node that wants a string.
One gotcha: the model dropdown lists image-generation entries (imagen-3.0, an image-gen flash model), but this node only returns text. For actually generating images with Google, use the pack's dedicated Gemini Image Generator node instead - this one is for words.
Installing it and wiring up a key
ComfyUI Manager: search ComfyUI-OllamaGemini, install, restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/al-swaiti/ComfyUI-OllamaGemini
pip install -r requirements.txt
then restart. Gemini has a genuinely usable free tier - grab a key at aistudio.google.com - which is the pack's real draw over the paid OpenAI and Claude nodes. Put the key in the pack's config JSON as GEMINI_API_KEY, or paste it into the api_key input. (Heads up from the community: some Google keys route through Google Cloud and want a billing profile attached even to use free credit, so if a fresh key errors, that's usually the fix - not the node.)
Where people get burned
The honest caveat is about trust, not the node's logic. Your API key sits in a plaintext config that any custom node in your install can read, and custom nodes run arbitrary Python with full access to your machine. This pack is open-source and MIT-licensed, but the general lesson is worth internalizing: in 2024 the ComfyUI_LLMVISION malware hid an infostealer inside fake builds of the openai and anthropic libraries - the exact kind of dependency an API-integration pack legitimately pulls in. So install from the real repo above and nowhere else, keep ComfyUI updated, and don't paste a key you can't afford to rotate.
One more: if the optimizer returns paragraphs of chatter instead of a clean prompt, your structure_format was edited - restore the default line, and leave stream off inside a batch graph.
Inputs (16)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | What is the meaning of life? | — |
| input_type | COMBO | text | 4 options: text, image, video, audio |
| gemini_model | COMBO | 8 options: gemini-2.5-pro-exp-03-25, gemini-2.0-flash, gemini-2.0-flash-lite, gemini-2.0-flash-exp-image-generation, gemini-1.5-pro, gemini-1.5-flash, +2 | |
| stream | BOOLEAN | false | — |
| structure_output | BOOLEAN | false | — |
| prompt_structure | COMBO | Custom | 7 options: Custom, VideoGen, FLUX.1-dev, SDXL, FLUXKontext, Imagen4, +1 |
| structure_format | STRING | Return only the prompt text itself. No explanations or formatting. | — |
| output_format | COMBO | raw_text | 2 options: raw_text, json |
| api_keyopt | STRING | — | |
| image1opt | IMAGE | — | |
| image2opt | IMAGE | — | |
| image3opt | IMAGE | — | |
| image4opt | IMAGE | — | |
| image5opt | IMAGE | — | |
| videoopt | IMAGE | — | |
| audioopt | AUDIO | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |