SafetyRating interface
Stay organized with collections
Save and categorize content based on your preferences.
A safety rating associated with a GenerateContentCandidate
Signature:
export interface SafetyRating
Properties
SafetyRating.blocked
Signature:
blocked: boolean;
SafetyRating.category
Signature:
category: HarmCategory;
SafetyRating.probability
Signature:
probability: HarmProbability;
SafetyRating.probabilityScore
The probability score of the harm category.
This property is only supported when using the Vertex AI Gemini API (VertexAIBackend). When using the Gemini Developer API (GoogleAIBackend), this property is not supported and will default to 0.
Signature:
probabilityScore: number;
SafetyRating.severity
The harm severity level.
This property is only supported when using the Vertex AI Gemini API (VertexAIBackend). When using the Gemini Developer API (GoogleAIBackend), this property is not supported and will default to HarmSeverity.UNSUPPORTED
.
Signature:
severity: HarmSeverity;
SafetyRating.severityScore
The severity score of the harm category.
This property is only supported when using the Vertex AI Gemini API (VertexAIBackend). When using the Gemini Developer API (GoogleAIBackend), this property is not supported and will default to 0.
Signature:
severityScore: number;
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-05-20 UTC.
[null,null,["Last updated 2025-05-20 UTC."],[],[],null,["# SafetyRating interface\n\nA safety rating associated with a [GenerateContentCandidate](./ai.generatecontentcandidate.md#generatecontentcandidate_interface)\n\n**Signature:** \n\n export interface SafetyRating \n\nProperties\n----------\n\n| Property | Type | Description |\n|-----------------------------------------------------------------------|--------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [blocked](./ai.safetyrating.md#safetyratingblocked) | boolean | |\n| [category](./ai.safetyrating.md#safetyratingcategory) | [HarmCategory](./ai.md#harmcategory) | |\n| [probability](./ai.safetyrating.md#safetyratingprobability) | [HarmProbability](./ai.md#harmprobability) | |\n| [probabilityScore](./ai.safetyrating.md#safetyratingprobabilityscore) | number | The probability score of the harm category.This property is only supported when using the Vertex AI Gemini API ([VertexAIBackend](./ai.vertexaibackend.md#vertexaibackend_class)). When using the Gemini Developer API ([GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class)), this property is not supported and will default to 0. |\n| [severity](./ai.safetyrating.md#safetyratingseverity) | [HarmSeverity](./ai.md#harmseverity) | The harm severity level.This property is only supported when using the Vertex AI Gemini API ([VertexAIBackend](./ai.vertexaibackend.md#vertexaibackend_class)). When using the Gemini Developer API ([GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class)), this property is not supported and will default to `HarmSeverity.UNSUPPORTED`. |\n| [severityScore](./ai.safetyrating.md#safetyratingseverityscore) | number | The severity score of the harm category.This property is only supported when using the Vertex AI Gemini API ([VertexAIBackend](./ai.vertexaibackend.md#vertexaibackend_class)). When using the Gemini Developer API ([GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class)), this property is not supported and will default to 0. |\n\nSafetyRating.blocked\n--------------------\n\n**Signature:** \n\n blocked: boolean;\n\nSafetyRating.category\n---------------------\n\n**Signature:** \n\n category: HarmCategory;\n\nSafetyRating.probability\n------------------------\n\n**Signature:** \n\n probability: HarmProbability;\n\nSafetyRating.probabilityScore\n-----------------------------\n\nThe probability score of the harm category.\n\nThis property is only supported when using the Vertex AI Gemini API ([VertexAIBackend](./ai.vertexaibackend.md#vertexaibackend_class)). When using the Gemini Developer API ([GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class)), this property is not supported and will default to 0.\n\n**Signature:** \n\n probabilityScore: number;\n\nSafetyRating.severity\n---------------------\n\nThe harm severity level.\n\nThis property is only supported when using the Vertex AI Gemini API ([VertexAIBackend](./ai.vertexaibackend.md#vertexaibackend_class)). When using the Gemini Developer API ([GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class)), this property is not supported and will default to `HarmSeverity.UNSUPPORTED`.\n\n**Signature:** \n\n severity: HarmSeverity;\n\nSafetyRating.severityScore\n--------------------------\n\nThe severity score of the harm category.\n\nThis property is only supported when using the Vertex AI Gemini API ([VertexAIBackend](./ai.vertexaibackend.md#vertexaibackend_class)). When using the Gemini Developer API ([GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class)), this property is not supported and will default to 0.\n\n**Signature:** \n\n severityScore: number;"]]