Gemini Safety Ratings Need Candidate-Level Audit Evidence
Gemini GenerateContent candidates can include safetyRatings with one rating per harm category, including probability and a blocked flag. A production audit should retain request safety settings, prompt feedback, candidate ratings, finish reason, model version, and delivery decision without treating probability as harm severity or flattening categories into one score.

Gemini GenerateContentResponse candidates can carry safetyRatings. Each rating names a harm category and gives the probability classification for that category. It can also report whether content was blocked because of the rating. The API reference allows at most one rating per category. That structure provides candidate-level evidence with several category rows.
A useful audit record preserves the exact category rows and the request's safety settings. It also retains the candidate finish reason and the application's delivery decision. Flattening the array to safe: true discards the mechanism the review is supposed to explain.
TL;DR
- Store Gemini
safetyRatingsper candidate and per harm category without collapsing them into one score. - Preserve the request safety settings and model version beside the returned ratings.
- Treat probability classification and harm severity as different concepts.
- Record blocked or missing rating states as named audit outcomes. Do the same for unknown and contradictory states.
Ratings belong to a candidate and category
Google AI Studio's GenerateContent API reference defines safetyRatings as a list on each candidate. It says there is at most one rating per category. The SafetyRating object contains a required harm category and a required probability enum. It also contains a Boolean blocked field.
Normalize one row for each category within a candidate and response. Retain the raw category and probability strings, blocked value, finish reason, and model version. Also retain collection time, route, and policy version. Keep the original provider response or a protected digest under the route's evidence policy.
The current reference lists Gemini harm categories including harassment, hate speech, sexually explicit content, and dangerous content. It also lists jailbreak attempts. Unknown categories must survive ingestion as raw values. A strict database enum that drops a new category creates a blind spot during the exact provider change an auditor may need to reconstruct.
The AI audit log schema supplies the common identity and decision envelope around these category rows.
Request thresholds explain the returned decision
Google's safety settings guide describes a safety setting as a pairing of category and blocking threshold. A governed route should compile those settings from versioned policy or validate caller-supplied settings before dispatch. Record the exact provider-bound settings, including categories omitted from the request.
The guide documents threshold choices that range from turning an adjustable filter off to blocking content at a high probability level or at medium and low probability levels. Provider defaults and model behavior can change over time, so an audit record should avoid reconstructing the effective configuration from current documentation months later. Preserve the request and resolved model version at the time of the call.
Built-in protections also matter. Google says core harms, including content that endangers child safety, remain blocked and cannot be adjusted. The audit should describe observed response evidence without claiming every provider-side rule was caller-configurable.
The per-route AI policies guide provides the owner for allowed categories, caller override permissions, minimum thresholds, and delivery behavior.
Probability is different from severity
The safety settings guide says Gemini rates the probability that content is unsafe as high, medium, low, or negligible and blocks based on that probability rather than the severity of the harm. Those are distinct risk dimensions.
A high probability rating supports a probability statement only. A low probability also leaves the possible severity unmeasured. Preserve Google's probability label and let the application apply its separately documented risk policy.
A downstream dashboard can count ratings by category and probability. It should label that graph clearly. An internal risk team may add a severity assessment, but that assessment needs its own source and method. It also needs a reviewer and timestamp. Keep it out of the provider field.
My opinion is simple: a single red-yellow-green safety gauge is bad audit design. It hides which category fired and invites readers to confuse likelihood with consequence.
Prompt and candidate blocking need distinct records
Safety handling can occur before candidate content is available or after a candidate begins generation. The GenerateContent response schema includes prompt feedback for prompt-related blocking information, while candidate finishReason and safetyRatings describe candidate output. Preserve those locations separately.
For each operation, record whether candidates were present. If the prompt was blocked, retain the prompt feedback fields permitted by the evidence policy and mark candidate ratings as absent rather than empty. If candidate generation stopped for SAFETY, preserve that finish reason and the returned ratings. Avoid manufacturing a zero-length candidate to simplify application code.
Candidate content can also be absent for reasons outside adjustable safety filters. The finish-reason enum includes recitation, prohibited content, sensitive personally identifiable information, malformed calls, and other outcomes. Route those reasons through their own classifications.
The Google Gemini enterprise security guide covers the wider control surface at the same HTTP boundary. Safety ratings explain category probability and blocking evidence. Finish reasons explain why generation stopped.
Missing and contradictory evidence needs a policy
A rating array can be absent, empty, malformed, or contain an unknown category. The parser can also encounter duplicate category rows even though the reference says there is at most one per category. Give each condition a named outcome.
A route that requires safety evidence may fail closed when ratings are missing from a candidate expected to carry them. Another route may deliver output while recording ratings_unavailable. The policy should be explicit and tested against the API version and model used in production.
Contradictions deserve quarantine. Examples include duplicate categories, an unrecognized probability value, a blocked flag with content delivered against route policy, or a SAFETY finish reason that the response parser silently relabels as success. Preserve the raw provider fields and the local parser finding without claiming the provider contract was violated until the current reference is checked.
One physical detail helps during review: render each category as a narrow row with the raw probability text and blocked flag. Label a blank row missing; a pale-green fill would falsely suggest a pass.
Audit storage should minimize sensitive content
Safety evidence can reveal that a user or model output touched harassment, sexual, dangerous, or jailbreak categories. Restrict access to those records. The general decision log can retain category, probability, blocked flag, and finish reason. It can also retain model version and request and response digests. Keep a protected content reference with those fields.
Store raw prompts and candidate text only under the route's approved retention and access policy. Avoid copying content into alert titles or metrics labels. Ticket subjects should also exclude that content. Category labels are low-cardinality fields suitable for aggregate monitoring. Prompt text belongs in the restricted evidence store.
Separate provider evidence from application action. Record provider_blocked as observed, then record application_disposition such as delivered, withheld, redacted, or queued for review. A stricter application policy may withhold content that Google did not block. That decision should remain visible as a local rule.
The google Gemini enterprise audit logs guide covers wider platform evidence. This control focuses on the request and response fields crossing one generation route.
A release fixture should break the rating array
Put a controllable Gemini-compatible stub behind the deployed route. Return one candidate with several category ratings and a natural STOP. Verify that each category becomes a separate normalized row tied to the same candidate index.
Next, return SAFETY with a blocked rating, then return prompt feedback with no candidates. Confirm that the collector creates distinct prompt-block and candidate-block records. Add two candidates with different ratings and prove that the application selection record points to the candidate actually delivered.
Mutate the response with a duplicate category and missing probability. Then add an unknown category, unknown probability, absent ratings, and a non-Boolean blocked value. The validator should retain raw evidence and follow the route's named hold or delivery path.
Finally, send identical prompt text under two approved threshold policies. Record both outbound settings and both returned results. The fixture should make policy version and model version visible. It should also expose provider evidence without claiming that one response predicts the other.
DeepInspect
DeepInspect can inspect safety settings and candidate safety metadata on authenticated user or agent Gemini HTTP traffic deliberately routed through its proxy. It can enforce route-approved request settings, validate returned rating shapes, block delivery under declared policy, and write a per-decision record tied to identity and route.
The application owns harm-severity assessment, candidate selection, human review, content retention, user messaging, and actions taken after delivery. Gemini calls that bypass the proxy and local data copied outside the routed exchange remain outside DeepInspect's evidence.
Book a technical deep dive at deepinspect.ai.
Frequently asked questions
- What does a Gemini safety rating contain?
The GenerateContent API reference defines a harm category and probability enum for each
SafetyRating. It also defines a blocked Boolean. Ratings belong to a candidate, with at most one rating per category.- Does a low probability rating mean the possible harm is minor?
No. Google's safety guide distinguishes probability from severity and says the adjustable filters block based on probability. Store the provider probability as reported. Any severity assessment belongs in a separately named application field with its own method.
- Should missing safetyRatings be treated as safe?
Absence is an unknown evidence state. Record whether ratings were absent, empty, malformed, or unavailable because the prompt was blocked before candidates were produced. Apply the route's declared handling policy.
- Can the application use stricter rules than Gemini's blocked flag?
Yes. Preserve the provider rating and blocked value, then record the application's separate delivery decision. A route may withhold or review content under its own policy even when the provider did not block it.