SafetySpec Stay organized with collections Save and categorize content based on your preferences.
Safety specification. There are two use cases: 1. when only safetySpec.enable is set, the BLOCK_LOW_AND_ABOVE threshold will be applied for all categories. 2. when safetySpec.enable is set and some safetySettings are set, only specified safetySettings are applied.
| JSON representation |
|---|
{"enable":boolean,"safetySettings":[{object ( |
| Fields | |
|---|---|
enable |
Enable the safety filtering on the answer response. It is false by default. |
safetySettings[] |
Optional. Safety settings. This settings are effective only when the safetySpec.enable is true. |
SafetySetting
Safety settings.
| JSON representation |
|---|
{"category":enum ( |
| Fields | |
|---|---|
category |
Required. Harm category. |
threshold |
Required. The harm block threshold. |
HarmBlockThreshold
Probability-based thresholds levels for blocking.
| Enums | |
|---|---|
HARM_BLOCK_THRESHOLD_UNSPECIFIED | Unspecified harm block threshold. |
BLOCK_LOW_AND_ABOVE | Block low threshold and above (i.e. block more). |
BLOCK_MEDIUM_AND_ABOVE | Block medium threshold and above. |
BLOCK_ONLY_HIGH | Block only high threshold (i.e. block less). |
BLOCK_NONE | Block none. |
OFF | Turn off the safety filter. |
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-06-27 UTC.