ComfyUI Node

Gemini Chat

The Safety Slider Is the Interesting Part

By yogurt7771·Created 2 years ago·Updated 6 days ago· 3
Gemini Chat
  • images
  • history
  • provider
  • text
  • thought
  • history
◄prompt►
◄model▾►
◄seed0►
◄safety_levelBLOCK_NONE►
◄extra►
◄retry_count1►
◄system_prompt►

Gemini is the model most people mean when they say "I'll have an LLM write my prompt." It's cheap, fast, handles vision, and - uniquely among the big three - exposes a safety threshold you can actually set from inside the node. That last bit is why this version is more interesting than the GPT or Claude equivalents in the same pack.

The job is the routine one: rough idea in, structured prompt out, into your CLIP text encoder. Or image in, caption out, for seeding an img2img pass. Google is the closed benchmark everybody measures against and the supplier of the encoders the open models run on (the KB's google.json), which is a roundabout way of saying: using Gemini to write prompts for a local model is the normal thing to do, not a weird hybrid.

Inputs, in order of how much you'll touch them

  • prompt - multiline, the user turn.
  • model - dynamic dropdown covering the Gemini Flash/Pro line. The inputs below it change with your pick, which is why reasoning controls appear on newer versions and plain sampling controls on older ones. Custom model is in the list if you need an ID the dropdown doesn't know.
  • safety_level - default BLOCK_NONE. The scale runs from BLOCK_NONE through BLOCK_ONLY_HIGH, BLOCK_MEDIUM_AND_ABOVE and BLOCK_LOW_AND_ABOVE, plus OFF and DEFAULT (which sends no safety settings at all and therefore inherits Google's defaults). Read the pack author's own words on it: the threshold applies to all harm categories at once. This is a genuine lever, but it's a per-request hint to Google's own moderation, not a bypass - nothing you set here makes the model do something it won't.
  • seed - 0 lets the API pick, and changing a non-zero value forces a re-run. Handy for "same prompt, different rewrite."
  • images - autogrow vision socket, up to 16, batches expanded. Connect one and the next slot appears.
  • system_prompt - for prompt-writing jobs, this is where your money is: "reply with the prompt only. No preamble, no quotes, no markdown."
  • history - previous turns in, for a continuing conversation.
  • extra - JSON merged into the request, for parameters the pack doesn't expose.
  • retry_count - total attempts, ~3s apart.

Outputs are text, thought and history. On this node thought is worth a look: the pack asks Gemini to include its thinking, so reasoning text lands there instead of polluting your prompt - which is exactly the failure mode that makes prompt-enhancer nodes frustrating (the KB's llm-in-comfyui.md calls it dirty output, and it's the number one reason people give up on them).

Install and key it

cd ComfyUI/custom_nodes
git clone https://github.com/yogurt7771/ComfyUI-YogurtNodes
cd ComfyUI-YogurtNodes
pip install -r requirements.txt

That pulls google-genai among others. Leave the provider socket empty and this node falls back to Google AI Studio, reading gemini from custom_nodes/ComfyUI-YogurtNodes/yogurt_nodes/llm/api_key.json or GEMINI_API_KEY. Precedence is field → JSON → env.

{ "gemini": "AIza..." }

Because the default provider is Google's own API, you can skip the provider node entirely for a simple setup - and that's fine, right up until you want to route it through a relay, at which point you add a Provider node and re-wire one socket.

Where it goes wrong

text is empty, thought has content. You built a reasoner-shaped request. Either read thought, or turn the thinking level down in the model's parameters.

Preamble in your prompt. A chat model chats. Constrain it with system_prompt and strip anything left with a regex node - do not trust a single free-form rewrite, because subject drift is real and an enhancer that invents detail you never asked for is worse than no enhancer.

Vision that ignores half the batch. Batches expand into individual slots against a 16-image ceiling; go over and the node errors rather than truncating. That's good behaviour, but it means the failure looks like a hard stop mid-run.

Safety refusals that look like empty output. Turn safety_level to DEFAULT and you're back on Google's defaults, which for a lot of creative work is stricter than you want. BLOCK_NONE is the default here for a reason.

One last fit-and-finish note: history out is the same type the other chat nodes accept, so chaining Gemini Chat → GPT Chat with shared history works. That's how people build the "describe with a vision model, rewrite with a chat model, generate locally" three-step that shows up in every thread about prompt pipelines.

CategoryYogurtNodes/LLM/Text

Inputs (10)

NameTypeDefaultDescription
promptSTRINGPrompt sent to the model.
modelCOMBOModel version; the inputs below change with the selected model.
seedINT00–2147483647Sent to the API when the model supports it; changing it also forces a re-run. 0 lets the API pick a random seed.
safety_levelCOMBOBLOCK_NONESafety threshold for all harm categories; DEFAULT sends no safety settings.
extraSTRINGOptional JSON object merged into the request (for parameters not exposed as inputs).
imagesCOMFY_AUTOGROW_V3Optional reference image(s); batches are expanded. Up to 16.
retry_countINT11–10Total attempts on failure.
system_promptoptSTRINGSystem instruction sent with the request.
historyoptHISTORYPrevious turns.
provideroptYOGURT_LLM_PROVIDERProvider node. When unconnected, the official API is used with keys from api_key.json or environment variables.

Outputs (3)

NameTypeDescription
textSTRING—
thoughtSTRING—
historyHISTORY—