Class SafetyRating
A safety rating for a piece of content. The safety rating contains the harm category and the harm probability level.
public record SafetyRating : IEquatable<SafetyRating>
- Inheritance
-
SafetyRating
- Implements
- Inherited Members
Properties
Blocked
Output only. Indicates whether the content was blocked because of this rating.
[JsonPropertyName("blocked")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? Blocked { get; set; }
Property Value
- bool?
Category
Output only. The harm category of this rating.
[JsonPropertyName("category")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public HarmCategory? Category { get; set; }
Property Value
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.
[JsonPropertyName("overwrittenThreshold")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public HarmBlockThreshold? OverwrittenThreshold { get; set; }
Property Value
Probability
Output only. The probability of harm for this category.
[JsonPropertyName("probability")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public HarmProbability? Probability { get; set; }
Property Value
ProbabilityScore
Output only. The probability score of harm for this category. This field is not supported in Gemini API.
[JsonPropertyName("probabilityScore")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? ProbabilityScore { get; set; }
Property Value
Severity
Output only. The severity of harm for this category. This field is not supported in Gemini API.
[JsonPropertyName("severity")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public HarmSeverity? Severity { get; set; }
Property Value
SeverityScore
Output only. The severity score of harm for this category. This field is not supported in Gemini API.
[JsonPropertyName("severityScore")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? SeverityScore { get; set; }
Property Value
Methods
FromJson(string, JsonSerializerOptions?)
Deserializes a JSON string to a SafetyRating object.
public static SafetyRating? FromJson(string jsonString, JsonSerializerOptions? options = null)
Parameters
jsonStringstringThe JSON string to deserialize.
optionsJsonSerializerOptionsOptional JsonSerializerOptions.
Returns
- SafetyRating
The deserialized SafetyRating object, or null if deserialization fails.