Table of Contents

Class SafetyRating

Namespace
Google.GenAI.Types
Assembly
Google.GenAI.dll

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

HarmCategory?

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

HarmBlockThreshold?

Probability

Output only. The probability of harm for this category.

[JsonPropertyName("probability")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public HarmProbability? Probability { get; set; }

Property Value

HarmProbability?

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

double?

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

HarmSeverity?

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

double?

Methods

FromJson(string, JsonSerializerOptions?)

Deserializes a JSON string to a SafetyRating object.

public static SafetyRating? FromJson(string jsonString, JsonSerializerOptions? options = null)

Parameters

jsonString string

The JSON string to deserialize.

options JsonSerializerOptions

Optional JsonSerializerOptions.

Returns

SafetyRating

The deserialized SafetyRating object, or null if deserialization fails.