Nodes/ComfyUI Gemini Expanded API/Expanded Gemini Interactions (Text/Image)
ComfyUI Node

Expanded Gemini Interactions (Text/Image)

Images, video and prompt in, text and pictures out

By silveroxides·Created about a year ago·Updated a day ago· 6
Expanded Gemini Interactions (Text/Image)
  • config
  • video
  • response_schema
  • image_inputs
  • text
  • image
  • final_actual_seed
  • Structured output
  • Thoughts
  • Interaction ID
◄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_levellow►
◄media_resolutionunspecified►
◄max_retries3►
◄retry_pattern(PROHIBITED_CONTENT|UNAVAILABLE|request/processing|RESOURCE_EXHAUSTED)►
◄timeout_fallback_text►
◄image_sizeNone►
◄storetrue►
◄previous_interaction_id►

This is the node that actually does something: it sends your prompt - plus any images and video you wired in - to Google's Gemini Interactions API and drops the answer back as a string. The API-wrapper pattern in its purest form, a node that looks like a generator and is really an HTTP client with your key attached (external-api-nodes.md).

Three jobs. Rewrite a rough idea into a structured prompt before your local sampler - the honest ceiling is "removes the blank page", not "writes better than you" (llm-in-comfyui.md). Read an image and describe it, for img2img seeding or caption drafts. Or generate an image outright: point model at an image model, flip include_images, and you're calling the Nano Banana line - technically excellent, aggressively filtered (closed-source-models.md, kg/entities/google.json).

On the author: silveroxides is a quantisation-and-LoRA name here who expanded tatoookan's original Gemini repo. The pack has no Reddit footprint, so everything below comes from the shipped code.

How it works

It calls client.interactions.create(...) - the newer Interactions surface, not the classic generate_content - with inputs assembled as ordered parts: video first, then images, then your prompt. A response format list rides along, built from include_images + aspect_ratio + image_size when you've picked an image model, and from a connected response schema when you've defined one.

Before any of that it fingerprints everything - prompt, system instruction, model, token cap, hashed image tensors and video bytes, safety settings, schema JSON, seed, even proxy host and port - and checks a local result cache. Two consequences: the cache is only consulted when use_seed is on, and with a fixed seed and an unchanged prompt, re-queueing returns the previous answer from memory without touching Google. Bump the seed for a new call.

The request runs in a background thread with timeout (15–300s) around it. When it expires the node puts either timeout_fallback_text or a standard "Gemini API request/processing timed out" line into text and moves on - no exception, no red node, just text that isn't an answer.

Inputs that matter

config is the credential socket from Configure Gemini Interactions API Key; nothing works without it. prompt is your ask. system_instruction defaults to "You are a helpful AI assistant." and is where you actually steer behaviour for prompt-rewriting work - the field people forget exists. model defaults to gemini-2.5-flash, and the long list spans text, thinking and image models. max_output_tokens goes to 65536.

Three widgets are traps, and the author says so in the tooltips: temperature, top_p, top_k and thinking_budget are all marked "Ignored in Interactions API". Moving them changes nothing except the cache fingerprint. Randomness control lives in seed; reasoning effort lives in thinking_level (None through high - some models reject minimal and the node swaps in low with a warning).

For vision work: image_inputs is an autogrow socket set growing from image_1 to image_100, batches sent consecutively, and media_resolution sets input resolution for images, video and PDFs. video takes a GEMINI_VIDEO_CONFIG from the pack's video node. response_schema - labelled Response format - requests JSON, returned in both text and Structured output.

Multi-turn is two widgets: store (default true) keeps the interaction server-side, previous_interaction_id continues from a prior one. max_retries with retry_pattern is the re-roll mechanism - if the response text or an error matches your regex, the node retries with a new seed. Every retry is a billable call.

bypass_mode (system_instruction, prompt, or both) rewrites your text with homoglyphs and zero-width joiners - periods, spaces, commas, quotes swapped for lookalikes - so naive keyword filters don't match. It changes what the model reads, can break exact formatting, and won't get past the model's own refusals. Last resort.

Outputs

text is the answer - and the error channel. Failures, timeouts and blocks all come back as strings here, so a downstream node will happily consume your error message as content.

image is a real generated image when image generation was enabled; otherwise it's a dark grey 64×64 placeholder, still perfectly connectable - which is how people wire a fake image in and wonder why the output is grey. final_actual_seed is the seed the API actually used. Structured output holds parsed JSON when a response format succeeded. Thoughts carries returned thinking when include_thoughts is on. Interaction ID feeds back into previous_interaction_id for a follow-up turn.

Install

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

Then restart. The requirements floor is google-genai>=2.17.0; an older copy left behind by another pack shows up as 'Client' object has no attribute 'interactions' in text. import cv2 is used but not listed - stock ComfyUI ships OpenCV, a bare Python env doesn't.

Where people get burned

  • Re-queuing gives the identical answer. Cached, by design, when use_seed is on and nothing changed. Randomize the seed.
  • Errors arrive as text, not as failures. Timeouts, bad keys, policy blocks - all string output, and your downstream prompt-formatter will forward them.
  • include_images plus a non-image model does nothing. The response-format branch only fires for models in the image list, and image generation plus a connected response format is an error rather than a silent choice.
  • image_size is model-specific. The node validates it and names the allowed values.
  • Policy refusals look like bugs. The README's NoneType object has no attribute 'parts' note is a prohibited-use refusal; the Interactions path reports blocks as Interaction blocked/failed instead. Test with ordinary subject matter first.
  • The README is a step behind. It documents the older non-Interactions text node (Configure Gemini API Key, different api_version list, no Interaction ID output). Here the tooltips are the documentation.
CategoryAPI/Gemini/Interactions

Inputs (30)

NameTypeDefaultDescription
configGEMINI_CONFIG—
promptSTRING—
system_instructionSTRINGYou are a helpful AI assistant.—
modelCOMBOgemini-2.5-flash24 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, +18
temperatureFLOAT1.000–1Ignored in Interactions API
top_pFLOAT0.950–1Ignored in Interactions API
top_kINT401–100Ignored in Interactions API
max_output_tokensINT81921–65536—
include_imagesBOOLEANfalse—
aspect_ratioCOMBONone15 options: None, 1:1, 9:16, 16:9, 3:4, 4:3, +9
bypass_modeCOMBONone4 options: None, system_instruction, prompt, both
thinking_budgetINT0-1–24576Ignored in Interactions API. Use thinking_level instead.
use_proxyBOOLEANfalse—
proxy_hostSTRING127.0.0.1—
proxy_portINT78901–65535—
use_seedBOOLEANtrue—
seedINT00–2147483647—
timeoutINT3015–300—
include_thoughtsBOOLEANfalse—
thinking_levelCOMBOlowThinking level for reasoning models.
media_resolutionCOMBOunspecifiedSet input media resolution for image, video and pdf.
max_retriesINT30–10Maximum number of retry attempts when pattern matches. 0 disables retry.
retry_patternoptSTRING(PROHIBITED_CONTENT|UNAVAILABLE|request/processing|RESOURCE_EXHAUSTED)Regex 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.
image_sizeoptCOMBONoneGenerated image resolution. Gemini 3.1 Flash Lite Image supports only 1K; 512 is supported only by Gemini 3.1 Flash Image.
storeoptBOOLEANtrueStore interaction on server for multi-turn conversations. When enabled with an empty previous_interaction_id, automatically continues the last active interaction.
previous_interaction_idoptSTRINGOptional ID of previous interaction to continue multi-turn conversation. If left empty when store is enabled, automatically uses the last active interaction ID.
videooptGEMINI_VIDEO_CONFIGOptional configured Gemini video input with embedded audio and sampling FPS.
response_schemaoptGEMINI_RESPONSE_SCHEMAConnect an answer format to request the fields you defined. Leave disconnected for a normal answer.
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.

Outputs (6)

NameTypeDescription
textSTRING—
imageIMAGE—
final_actual_seedINT—
Structured outputSTRING—
ThoughtsSTRING—
Interaction IDSTRING—