Nodes/ComfyUI Gemini Nodes/Unofficial Stream API Call
ComfyUI Node

Unofficial Stream API Call

The same relay trick, but the answer arrives live

By jqy-yoΒ·Created about a year agoΒ·Updated 11 months agoΒ· 7
Unofficial Stream API Call
  • image1
  • image2
  • image3
  • image4
  • image5
  • response
  • image
  • stream_log
  • api_request
  • api_response
β—„promptβ€”β–Ί
β—„api_keyβ–Ί
β—„api_formatOpenAI Compatibleβ–Ί
β—„modelclaude-3-5-sonnet-20240620β–Ί
β—„temperature0.70β–Ί
β—„max_tokens1024β–Ί
β—„base_urlhttps://www.chataiapi.com/v1β–Ί
β—„streamtrueβ–Ί
β—„seed0β–Ί
β—„system_promptYou are a helpful assistant.β–Ί
β—„top_p0.95β–Ί

Streaming, but only if you're already in the unofficial world

UnofficialGeminiAPI talks to relay endpoints; this node does the same thing but streams. Instead of a long silence followed by the whole answer, the response arrives chunk by chunk as the model generates it, and the node keeps a running stream_log so you can watch progress. For long generations - big write-ups, structured analysis, anything that takes a while - that's a genuinely nicer experience than staring at an empty wire.

That said, be honest about the context: this is a streaming variant of an unofficial-endpoint node. If you're not already using relays, you have no reason to start here. If you are, this is the version you want for long answers.

How it works

Same dual-format engine as UnofficialGeminiAPI - api_format of OpenAI Compatible or Gemini Native, a base_url pointing at your relay, up to five image1–image5 inputs, and the same temperature, top_p, max_tokens dials. The addition is the stream toggle (default true): responses are received incrementally, and in Gemini Native format any image returned by the relay is still extracted into the image output mid-stream.

The README's advice is worth repeating: use Gemini Native format for image-generation tasks through a relay, OpenAI Compatible for Claude/GPT-style text.

Inputs you'll set

  • api_key - your relay's key, same as the non-streaming node.
  • api_format / base_url / model - the relay contract; match all three to your provider.
  • stream - leave on for long responses; turn off if you need the whole answer atomically.
  • image1–image5 - multimodal or image-gen inputs.

Outputs: response (the complete streamed text), image (extracted image when applicable), stream_log (the running progress log - this node's signature output), and the standard api_request / api_response pair.

Install

Identical to the rest of the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/jqy-yo/comfyui-gemini-nodes
cd comfyui-gemini-nodes
pip install -r requirements.txt

Or "ComfyUI Gemini Nodes" via ComfyUI Manager, restart. Needs aiohttp, which the pack's requirements already install.

Where people get burned

Every caveat from UnofficialGeminiAPI applies, plus one streaming-specific one: not all relay endpoints support streaming, even when they claim OpenAI compatibility. If you get a broken or empty response with stream on, flip it off - some relays only implement the non-streaming path and the failure is on their side, not the node's. The stream_log output is your debugging tool here; if the log shows chunks arriving but response stays empty, look at how the relay terminates the stream. And the trust warning is doubled: streaming keeps the connection open to a third party longer, and your prompts and keys are still passing through that relay. Know the provider before you paste a key into it.

CategoryπŸ€– Gemini/Unofficial

Inputs (16)

NameTypeDefaultDescription
promptSTRINGβ€”
api_keySTRINGβ€”
api_formatCOMBOOpenAI Compatible2 options: OpenAI Compatible, Gemini Native
modelSTRINGclaude-3-5-sonnet-20240620β€”
temperatureFLOAT0.700–1β€”
max_tokensINT102464–8192β€”
base_urlSTRINGhttps://www.chataiapi.com/v1β€”
streamBOOLEANtrueβ€”
seedINT00–2147483647β€”
system_promptoptSTRINGYou are a helpful assistant.β€”
image1optIMAGEβ€”
image2optIMAGEβ€”
image3optIMAGEβ€”
image4optIMAGEβ€”
image5optIMAGEβ€”
top_poptFLOAT0.950–1β€”

Outputs (5)

NameTypeDescription
responseSTRINGβ€”
imageIMAGEβ€”
stream_logSTRINGβ€”
api_requestSTRINGβ€”
api_responseSTRINGβ€”