Configure Gemini Safety
Gemini Refused Your Prompt. This Is the Knob Panel.
- safety_config
You wired a Gemini node into your graph, hit queue, and got nothing back - or got the pack's own cryptic 'NoneType' object has no attribute 'parts' in the console. That's the safety filter, not your prompt, not your GPU. Configure Gemini Safety (class SSL_GeminiSafetyConfig, under API/Gemini) is the node that lets you argue with it, per harm category, instead of accepting whatever the API decides.
It's a purely local settings node. No API call, no key, no network - it packages your choices into a GEMINI_SAFETY_CONFIG value that another node puts on the wire.
Why this exists at all
A local checkpoint you can abliterate or LoRA away. A closed model you can't - whatever Google refuses, the node refuses, and there are no weights to patch. The entire leverage you have over a hosted model's refusals is the handful of request parameters it exposes, and safety settings are one of them.
The pack already loosens things by default. Dig into gemini_nodes.py and the fallback list it sends for a normal Gemini API key is BLOCK_NONE across the five text harm categories - harassment, hate speech, sexually explicit, dangerous content, civic integrity. So the usual complaint isn't "too strict for text." It's that the four image categories aren't in that list at all, and there's no way to tighten anything if you want a stricter filter. That's the gap this fills.
How it works
The node runs no request. It builds a list of small dicts - one per category you haven't left on default - and hands them out as safety_config. Downstream, SSL_GeminiAPIKeyConfig takes that list on its optional safety_override input and stashes it in the config the text/image node consumes. When the text node fires, it converts each dict into a types.SafetySetting with category, threshold and optionally method, and passes the set as safety_settings on the request.
Which means the wiring is the bit people get wrong: the safety node plugs into the API key config node, not into the Gemini text node. The text node inherits whatever the config carries.
The knobs that actually matter
Nine identical per-category dropdowns: harassment, hate_speech, sexually_explicit, dangerous_content, civic_integrity, then image_harassment, image_hate, image_sexually_explicit, image_dangerous_content. All default to off, and each offers off, block_none, block_only_high, block_medium_and_above, block_low_and_above, default.
off and default are not the same thing, and this is the trap. off sends an explicit OFF threshold - you're telling Google to stop filtering that category. default sends nothing at all for that category, so the API applies its own house rules. If you want fewer refusals, off is the value; picking default and expecting a change is how people conclude the node doesn't work.
Then there's jailbreak, which defaults to default - the author's tooltip spells it out: "'default' keeps filter disabled," and on default it's omitted from the request entirely. Leave it alone unless you know your endpoint supports it; if errors start after you enable it, set it back first.
And method, defaulting to severity, which rides along on every entry. Severity grades how severe the harm is; probability is the classifier's confidence that the content matches at all. If a prompt keeps bouncing, threshold and method are the two dials worth changing - flip one, re-queue, see what happens.
Installing it
It ships in the same pack as everything else, so install once:
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
Or search "Gemini Expanded API" in ComfyUI Manager. The requirements are google-genai>=2.17.0 plus numpy, torch and Pillow - no model downloads. Restart, then wire Configure Gemini Safety's safety_config output into the safety_override input on Configure Gemini API Key.
Common issues
The console says 'NoneType' object has no attribute 'parts'. The README calls this out: your image or prompt tripped Google's Generative AI Prohibited Use Policy. Test with an ordinary product photo first. This node helps with threshold-level refusals, but it is not a bypass for a policy violation - don't buy the pack expecting that.
Your settings seem ignored. Check the wire: safety_config → the config node's safety_override. A GEMINI_SAFETY_CONFIG output won't connect to the text node, and with two config nodes in the graph the text node is probably reading the other one.
You're on Vertex / Enterprise and nothing changed. With no override connected, the pack already sends threshold OFF with SEVERITY for the five core categories on that path, so you're starting from a very permissive baseline. Add this node if you want the image categories covered or want to tighten something - not because the default is strict.
Last thing, and it's not paranoia: this pack is arbitrary Python that holds your API key and calls the network by design, expanded by the author from tatookan's original node. Read gemini_nodes.py if you're the type - it's 1,800 readable lines. And keep expectations honest: the safety node can only ask for looser thresholds. Google decides which knobs it honours, and some categories aren't knobs at all.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| harassment | COMBO | off | Negative or harmful comments targeting identity. |
| hate_speech | COMBO | off | Content that promotes violence or incites hatred. |
| sexually_explicit | COMBO | off | Contains references to sexual acts or other lewd content. |
| dangerous_content | COMBO | off | Promotes, facilitates, or encourages harmful acts. |
| civic_integrity | COMBO | off | Content that may mislead or influence elections. |
| image_harassment | COMBO | off | Images depicting harassment. |
| image_hate | COMBO | off | Images depicting hate speech. |
| image_sexually_explicit | COMBO | off | Images containing sexually explicit content. |
| image_dangerous_content | COMBO | off | Images depicting dangerous content. |
| jailbreak | COMBO | default | Prompts designed to bypass safety filters. 'default' keeps filter disabled. |
| method | COMBO | severity | Method for blocking content: severity vs probability score. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| safety_config | GEMINI_SAFETY_CONFIG | — |