Nodes/ComfyUI API Toolkit/Gemini Safety Settings
ComfyUI Node

Gemini Safety Settings

You can't actually loosen Gemini's safety

By IxMxAMAR·Created 5 months ago·Updated 2 months ago· 1
Gemini Safety Settings
    • safety_settings_json
    harassmentBLOCK_MEDIUM_AND_ABOVE
    hate_speechBLOCK_MEDIUM_AND_ABOVE
    sexually_explicitBLOCK_MEDIUM_AND_ABOVE
    dangerous_contentBLOCK_MEDIUM_AND_ABOVE

    The honest name for this node is "a form that builds a JSON blob." It takes four content categories - harassment, hate speech, sexually explicit, dangerous content - and lets you set a block threshold for each, then outputs the settings as JSON for the pack's Text Generation node to consume. If you've ever used the Gemini API, you know these knobs: BLOCK_NONE, BLOCK_ONLY_HIGH, BLOCK_MEDIUM_AND_ABOVE (the default), BLOCK_LOW_AND_ABOVE.

    Now the punchline, and it's an important one to internalize before you get excited: on the modern Gemini API these settings are largely advisory. Google tightened its own enforcement so that the API applies its content policy regardless of what threshold you request - BLOCK_NONE is not a working "unfiltered" switch for most content. The KB's llm-in-comfyui.md makes the same point more bluntly: the API path filters, which is exactly why the content the local path exists for is unavailable here. There is no local workaround, because there's nothing local to patch.

    So what is this node for, then? Two real uses: documenting your settings in a reusable, shareable node (it's cleaner than pasting JSON into the TextGen input), and keeping a per-workflow record of what thresholds you ran with, which matters if you're producing content under compliance constraints or experimenting with where the actual cutoff sits. And there's a genuine technical role: it feeds safety_settings_json on Text Generation, so if Google does honor your thresholds on your account's tier, this is the node that sets them.

    How it works

    Nothing clever. Four dropdowns, one per category, each with the four threshold levels. The node serializes your choices into a JSON string that matches what the Gemini API expects, and returns it. Wire the output into Text Generation's safety_settings_json input and the settings ride along on your generate_content calls. That's the entire mechanism - it's a config helper, not a bypass.

    Inputs and outputs

    • harassment, hate_speech, sexually_explicit, dangerous_content - the four category thresholds. All default to BLOCK_MEDIUM_AND_ABOVE.
    • Output: safety_settings_json (STRING) - feed it to AIS_Gemini_TextGen's safety_settings_json.

    How to install it

    Standard pack install:

    cd ComfyUI/custom_nodes
    git clone https://github.com/IxMxAMAR/ComfyUI-API-Toolkit
    cd ComfyUI-API-Toolkit
    pip install -r requirements.txt
    

    or "API Toolkit" from ComfyUI Manager. Needs google-genai>=0.8.0. No API key needed for this node itself - it just builds JSON.

    Common issues

    The failure mode is expectation, not mechanics. People set BLOCK_NONE on everything, run TextGen, and are shocked when Google still refuses. That's not a bug in this node - it's the platform's policy being applied server-side. If you genuinely need uncensored generation, the answer is a local model, not a slider.

    One thing this node can do usefully: when you're debugging "why did my prompt get blocked," set everything to BLOCK_NONE and re-run. If it still fails, you've cleanly proven the block is at the platform level, not your settings. Then adjust expectations and move on.

    CategoryAPI Toolkit/Gemini/Config

    Inputs (4)

    NameTypeDefaultDescription
    harassmentCOMBOBLOCK_MEDIUM_AND_ABOVEThreshold for harassment content.
    hate_speechCOMBOBLOCK_MEDIUM_AND_ABOVEThreshold for hate speech content.
    sexually_explicitCOMBOBLOCK_MEDIUM_AND_ABOVEThreshold for sexually explicit content.
    dangerous_contentCOMBOBLOCK_MEDIUM_AND_ABOVEThreshold for dangerous content.

    Outputs (1)

    NameTypeDescription
    safety_settings_jsonSTRING