Class SafetyRating

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

public abstract class SafetyRating extends JsonSerializable
A safety rating for a piece of content. The safety rating contains the harm category and the harm probability level.
  • Constructor Details

    • SafetyRating

      public SafetyRating()
  • Method Details

    • blocked

      public abstract Optional<Boolean> blocked()
      Output only. Indicates whether the content was blocked because of this rating.
    • category

      public abstract Optional<HarmCategory> category()
      Output only. The harm category of this rating.
    • overwrittenThreshold

      public abstract Optional<HarmBlockThreshold> overwrittenThreshold()
      Output only. The overwritten threshold for the safety category of Gemini 2.0 image out. If minors are detected in the output image, the threshold of each safety category will be overwritten if user sets a lower threshold. This field is not supported in Gemini API.
    • probability

      public abstract Optional<HarmProbability> probability()
      Output only. The probability of harm for this category.
    • probabilityScore

      public abstract Optional<Float> probabilityScore()
      Output only. The probability score of harm for this category. This field is not supported in Gemini API.
    • severity

      public abstract Optional<HarmSeverity> severity()
      Output only. The severity of harm for this category. This field is not supported in Gemini API.
    • severityScore

      public abstract Optional<Float> severityScore()
      Output only. The severity score of harm for this category. This field is not supported in Gemini API.
    • builder

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

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

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