The request completed, but there is no output text and the finish reason indicates safety.
Why this happens
The model may decline to generate text or filter output segments based on safety guidelines. Always inspect candidate finish metadata instead of expecting response.text to be populated.
Answer 1: Inspect finish reasons before reading text
response = client.models.generate_content(
model="gemini-2.5-flash",
contents="Explain secure password storage.",
)
print(response)
Check for blocked content flags and handle them gracefully by returning a helpful fallback message to users.
