Gemini 2.0 Minimum Safety Level
When using Gemini’s api
error: [handleAbortError] AI response error; aborting request: [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-pro-exp-02-05:streamGenerateContent?alt=sse: [400 Bad Request] HARM_CATEGORY_CIVIC_INTEGRITY threshold cannot be 5
The default block threshold for the Civic integrity category is Block none (for
gemini-2.0-flash-001aliased asgemini-2.0-flash,gemini-2.0-pro-exp-02-05, andgemini-2.0-flash-lite-02-05) both for Google AI Studio and the Gemini API, and Block most for all other models in Google AI Studio only. https://ai.google.dev/gemini-api/docs/safety-settings
It’s related to safety settings, specifically the
HARM_CATEGORY_CIVIC_INTEGRITY threshold. The default
settings vary between models and whether you’re using Google AI
Studio or the API directly. (See link
).
Set these for minimum safety:
GOOGLE_SAFETY_SEXUALLY_EXPLICIT=BLOCK_NONE
GOOGLE_SAFETY_HATE_SPEECH=BLOCK_NONE
GOOGLE_SAFETY_HARASSMENT=BLOCK_NONE
GOOGLE_SAFETY_DANGEROUS_CONTENT=BLOCK_NONE
GOOGLE_SAFETY_CIVIC_INTEGRITY=BLOCK_LOW_AND_ABOVE