Class SafetySetting

java.lang.Object
com.google.genai.JsonSerializable
com.google.genai.types.SafetySetting

public abstract class SafetySetting extends JsonSerializable
A safety setting that affects the safety-blocking behavior. A SafetySetting consists of a harm category and a threshold for that category.
  • Constructor Details

    • SafetySetting

      public SafetySetting()
  • Method Details

    • category

      public abstract Optional<HarmCategory> category()
      Required. The harm category to be blocked.
    • method

      public abstract Optional<HarmBlockMethod> method()
      Optional. The method for blocking content. If not specified, the default behavior is to use the probability score. This field is not supported in Gemini API.
    • threshold

      public abstract Optional<HarmBlockThreshold> threshold()
      Required. The threshold for blocking content. If the harm probability exceeds this threshold, the content will be blocked.
    • builder

      public static SafetySetting.Builder builder()
      Instantiates a builder for SafetySetting.
    • toBuilder

      public abstract SafetySetting.Builder toBuilder()
      Creates a builder with the same values as this instance.
    • fromJson

      public static SafetySetting fromJson(String jsonString)
      Deserializes a JSON string to a SafetySetting object.