# SafetySpec

- [JSON representation](https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1beta/SafetySpec#SCHEMA_REPRESENTATION)
- [SafetySetting](https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1beta/SafetySpec#SafetySetting)
  - [JSON representation](https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1beta/SafetySpec#SafetySetting.SCHEMA_REPRESENTATION)
- [HarmBlockThreshold](https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1beta/SafetySpec#HarmBlockThreshold)

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 (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1beta/SafetySpec#SafetySetting`) } ] } ``` |

| Fields ||
|---|---|
| `enable` | `boolean` Enable the safety filtering on the answer response. It is false by default. |
| `safetySettings[]` | ``object (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1beta/SafetySpec#SafetySetting`)`` Optional. Safety settings. This settings are effective only when the safetySpec.enable is true. |

## SafetySetting

Safety settings.

| JSON representation |
|---|
| ``` { "category": enum (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1beta/projects.locations.collections.dataStores.sessions.answers#Answer.HarmCategory`), "threshold": enum (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1beta/SafetySpec#HarmBlockThreshold`) } ``` |

| Fields ||
|---|---|
| `category` | ``enum (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1beta/projects.locations.collections.dataStores.sessions.answers#Answer.HarmCategory`)`` Required. Harm category. |
| `threshold` | ``enum (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1beta/SafetySpec#HarmBlockThreshold`)`` 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. |