SafetySetting

A safety setting that affects the safety-blocking behavior.

A SafetySetting consists of a harm category and a threshold for that category.

Fields
category enum (HarmCategory )

Required. The harm category to be blocked.

threshold enum (HarmBlockThreshold )

Required. The threshold for blocking content. If the harm probability exceeds this threshold, the content will be blocked.

method enum (HarmBlockMethod )

Optional. The method for blocking content. If not specified, the default behavior is to use the probability score.

JSON representation
{
 "category": enum (HarmCategory ),
 "threshold": enum (HarmBlockThreshold ),
 "method": enum (HarmBlockMethod )
}

HarmBlockMethod

The method for blocking content.

Enums
HARM_BLOCK_METHOD_UNSPECIFIED The harm block method is unspecified.
SEVERITY The harm block method uses both probability and severity scores.
PROBABILITY The harm block method uses the probability score.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年10月27日 UTC.