Expanded Gemini Text/Image
Text, vision, and image generation in one ComfyUI node
- config
- image_inputs
- text
- image
- final_actual_seed
This is the node that actually does the work. The pack's other two nodes are bookkeeping - SSL_GeminiAPIKeyConfig builds your credentials and GetKeyAPI feeds it a key from a file. SSL_GeminiTextPrompt ("Expanded Gemini Text/Image") is where your prompt leaves your machine, hits Google's servers, and comes back as text or an image. It's a cloud-API node, not a local diffusion model: nothing downloads, nothing runs on your GPU, and every run costs tokens billed to your API key.
The core trick is that one node covers three jobs. Text-to-text is the default: connect your config, type a prompt, get text. Image understanding works by also wiring an image into input_image (or input_image_2 for a second one) - Gemini reads it alongside your prompt. And text-to-image is just a matter of switching the model combo to one of the image-capable models, like gemini-2.5-flash-image or the nano-banana lineup (nano-banana-pro-preview). The KB's closed-source-models essay has the full story on those; they're Google's hosted image generators with real text rendering, and they're excellent at following long, specific prompts.
The inputs you'll actually touch, most days:
config- required, from theConfigure Gemini API Keynode. Everything else is a setting.promptandsystem_instruction- your message and the system prompt (default "You are a helpful AI assistant."). Set the system instruction to "you are an image editing assistant" for editing workflows.model- a big combo spanning Gemini 1.5 through 3.x, plus the image models. Default isgemini-2.5-flash, a good cost/speed balance.temperature,top_p,top_k,max_output_tokens- the standard sampling controls. Crank temperature up for creative text, leave it low for editing tasks.thinking_budget- Gemini's reasoning toggle.0disables thinking,-1turns on dynamic thinking, any positive number sets a fixed token budget. The relatedthinking_levelcombo (low/medium/high) only works on the newest models and takes precedence when set.
Three outputs come out: text (the model's reply), image (an IMAGE tensor), and final_actual_seed (the seed that was really used). That image output is a trap worth knowing: when the model returns text only, the node emits a small blank dark placeholder tensor instead of nothing, so a downstream preview node shows a black box that looks broken but isn't. The final_actual_seed matters because Gemini lets you pass a seed, and this node exposes it so you can lock in a result you like - pass the same seed back and you get the same image.
There's real engineering under the hood beyond the obvious API call. The node fingerprints every input - including a hash of your input images - and caches results, so re-running an identical workflow returns the cached answer instead of burning another API call. That's great for iteration and mildly surprising the first time you tweak something and the output doesn't change; turn use_seed off or change any input to bust the cache. There's also a regex retry system: put a pattern in retry_pattern, and if the response matches (say, a refusal or a known bad token), the node re-rolls the seed and tries again up to max_retries times. And the proxy settings (use_proxy, proxy_host, proxy_port, defaulting to 127.0.0.1:7890) exist because the README was written with China-based users in mind.
Install is the same as the rest of the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI_Gemini_Expanded_API.git
cd ComfyUI_Gemini_Expanded_API
pip install -r requirements.txt
Restart, or install via ComfyUI Manager by searching "ComfyUI Gemini Expanded API". The only new dependency that matters is google-genai.
The troubleshooting list, from the README and the source: the specific error [ERROR]API call error: 'NoneType' object has no attribute 'parts' means your prompt or image tripped Google's "Generative AI Prohibited Use Policy" - the request went out and got blocked, so test with a plain product or scene image before assuming your workflow is broken. A failed call with no response usually means the API key is wrong, the network can't reach Google (check your proxy), or you hit the default 30-second timeout on a slow generation - raise timeout up to 300 for image models. One caveat: Google's filters and rate limits change out from under you, and this node can't fix a policy block. It can only make the API easy to hit, which it genuinely does.
Inputs (25)
| Name | Type | Default | Description |
|---|---|---|---|
| config | GEMINI_CONFIG | — | |
| prompt | STRING | — | |
| system_instruction | STRING | You are a helpful AI assistant. | — |
| model | COMBO | gemini-2.5-flash | 23 options: gemini-1.5-pro-002, gemini-2.0-flash, gemini-2.0-flash-lite, gemini-2.5-flash-preview-04-17, gemini-2.5-pro-exp-03-25, gemini-2.5-pro, +17 |
| temperature | FLOAT | 1.000–1 | — |
| top_p | FLOAT | 0.950–1 | — |
| top_k | INT | 401–100 | — |
| max_output_tokens | INT | 81921–65536 | — |
| include_images | BOOLEAN | false | — |
| aspect_ratio | COMBO | None | 11 options: None, 1:1, 9:16, 16:9, 3:4, 4:3, +5 |
| bypass_mode | COMBO | None | 4 options: None, system_instruction, prompt, both |
| thinking_budget | INT | 0-1–24576 | 0 disables thinking mode, -1 will activate it as default dynamic thinking and anything above 0 sets specific budget |
| use_proxy | BOOLEAN | false | — |
| proxy_host | STRING | 127.0.0.1 | — |
| proxy_port | INT | 78901–65535 | — |
| use_seed | BOOLEAN | true | — |
| seed | INT | 00–2147483647 | — |
| timeout | INT | 3015–300 | — |
| include_thoughts | BOOLEAN | false | — |
| thinking_level | COMBO | None | Does not work at the same time as 'thinking_budget'. If this is set, then thinking budget is ignored. Gemini 3.7 Flash always uses this control, defaults to medium, and ignores thinking_budget. |
| media_resolution | COMBO | unspecified | Set input media resolution for image, video and pdf. This changes tokens consumed. |
| max_retries | INT | 30–10 | Maximum number of retry attempts when pattern matches. 0 disables retry. |
| image_inputsopt | COMFY_AUTOGROW_V3 | Ordered Gemini image parts growing from image_1 through image_100. Images inside a batch are sent consecutively before the next socket. Provider request-size and model-specific reference limits still apply. | |
| retry_patternopt | STRING | Regex pattern to match in response text. If matched, retry with new seed. Leave empty to disable. | |
| timeout_fallback_textopt | STRING | Text returned when the Gemini request times out. Leave empty to return the standard timeout message. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| image | IMAGE | — |
| final_actual_seed | INT | — |