AI / Google Antigravity Gemini Fundamentals Interview Questions
What is the Gemini API's approach to safety and content moderation?
Gemini models include built-in safety filters that evaluate both input prompts and output content across four harm categories. Developers can configure the threshold at which content is blocked, balancing safety with utility for their specific application context.
| Category | What it covers |
|---|---|
| HARM_CATEGORY_HARASSMENT | Threatening, bullying, or targeted abuse |
| HARM_CATEGORY_HATE_SPEECH | Content promoting hatred based on protected characteristics |
| HARM_CATEGORY_SEXUALLY_EXPLICIT | Adult sexual content |
| HARM_CATEGORY_DANGEROUS_CONTENT | Content facilitating serious harm, weapons, illegal activities |
from google import genai from google.genai import types client = genai.Client() # Configure safety thresholds: response = client.models.generate_content( model="gemini-3.5-flash", contents="Your prompt here", config=types.GenerateContentConfig( safety_settings=[ types.SafetySetting( category="HARM_CATEGORY_DANGEROUS_CONTENT", threshold="BLOCK_ONLY_HIGH", # options below ), types.SafetySetting( category="HARM_CATEGORY_HARASSMENT", threshold="BLOCK_MEDIUM_AND_ABOVE", ), ] ) ) # Check safety ratings on the response: for rating in response.candidates[0].safety_ratings: print(f"{rating.category}: {rating.probability}") # Check if response was blocked: if response.prompt_feedback.block_reason: print(f"Blocked: {response.prompt_feedback.block_reason}")
| Threshold | Blocks |
|---|---|
| BLOCK_NONE | Nothing (use with caution) |
| BLOCK_ONLY_HIGH | Only HIGH probability harm |
| BLOCK_MEDIUM_AND_ABOVE | MEDIUM and HIGH probability harm |
| BLOCK_LOW_AND_ABOVE | LOW, MEDIUM, and HIGH (most restrictive) |
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
