Nodes/ComfyUI Gemini Expanded API/Expanded Gemini Text/Image
ComfyUI Node

Expanded Gemini Text/Image

Text, vision, and image generation in one ComfyUI node

By silveroxides·Created about a year ago·Updated 15 days ago· 5
Expanded Gemini Text/Image
  • config
  • image_inputs
  • text
  • image
  • final_actual_seed
prompt
system_instructionYou are a helpful AI assistant.
modelgemini-2.5-flash
temperature1.00
top_p0.95
top_k40
max_output_tokens8192
include_imagesfalse
aspect_ratioNone
bypass_modeNone
thinking_budget0
use_proxyfalse
proxy_host127.0.0.1
proxy_port7890
use_seedtrue
seed0
timeout30
include_thoughtsfalse
thinking_levelNone
media_resolutionunspecified
max_retries3
retry_pattern
timeout_fallback_text

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 the Configure Gemini API Key node. Everything else is a setting.
  • prompt and system_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 is gemini-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. 0 disables thinking, -1 turns on dynamic thinking, any positive number sets a fixed token budget. The related thinking_level combo (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.

CategoryAPI/Gemini

Inputs (25)

NameTypeDefaultDescription
configGEMINI_CONFIG
promptSTRING
system_instructionSTRINGYou are a helpful AI assistant.
modelCOMBOgemini-2.5-flash23 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
temperatureFLOAT1.000–1
top_pFLOAT0.950–1
top_kINT401–100
max_output_tokensINT81921–65536
include_imagesBOOLEANfalse
aspect_ratioCOMBONone11 options: None, 1:1, 9:16, 16:9, 3:4, 4:3, +5
bypass_modeCOMBONone4 options: None, system_instruction, prompt, both
thinking_budgetINT0-1–245760 disables thinking mode, -1 will activate it as default dynamic thinking and anything above 0 sets specific budget
use_proxyBOOLEANfalse
proxy_hostSTRING127.0.0.1
proxy_portINT78901–65535
use_seedBOOLEANtrue
seedINT00–2147483647
timeoutINT3015–300
include_thoughtsBOOLEANfalse
thinking_levelCOMBONoneDoes 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_resolutionCOMBOunspecifiedSet input media resolution for image, video and pdf. This changes tokens consumed.
max_retriesINT30–10Maximum number of retry attempts when pattern matches. 0 disables retry.
image_inputsoptCOMFY_AUTOGROW_V3Ordered 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_patternoptSTRINGRegex pattern to match in response text. If matched, retry with new seed. Leave empty to disable.
timeout_fallback_textoptSTRINGText returned when the Gemini request times out. Leave empty to return the standard timeout message.

Outputs (3)

NameTypeDescription
textSTRING
imageIMAGE
final_actual_seedINT