google.SafetySetting
One Gemini safety filter setting, in the API's own spelling — pass a list of these as a client's `safety_settings`:
Reference version
Signature
class google.SafetySettingOne Gemini safety filter setting, in the API's own spelling — pass a list
of these as a client's safety_settings:
google.GeminiClient.new(
model = "gemini-2.5-flash",
safety_settings = [
google.SafetySetting.new("HARM_CATEGORY_DANGEROUS_CONTENT", "BLOCK_ONLY_HIGH"),
],
)
Categories are HARM_CATEGORY_HARASSMENT, HARM_CATEGORY_HATE_SPEECH,
HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT and
HARM_CATEGORY_CIVIC_INTEGRITY; thresholds are BLOCK_NONE,
BLOCK_ONLY_HIGH, BLOCK_MEDIUM_AND_ABOVE, BLOCK_LOW_AND_ABOVE and
OFF. The strings go on the wire verbatim, so a category this build has
never heard of still works.
Source:<builtin>/google/gemini.bamlbytes 763–1112
Fields
category
stringthreshold
stringStatic methods
function
new
(category: string, threshold: string) -> google.SafetySettingCreates a safety setting pairing a harm category with a blocking
threshold. Both strings go on the wire verbatim.