BerriAI/litellm · error · HTTPException
Violated content safety policy
Error message
Violated content safety policy
What it means
Error "Violated content safety policy" thrown in BerriAI/litellm.
Source
Thrown at litellm/proxy/guardrails/guardrail_hooks/lakera_ai.py:105
if typed_cat_scores["jailbreak"] >= self.category_thresholds["jailbreak"]:
raise HTTPException(
status_code=400,
detail={
"error": "Violated jailbreak threshold",
"lakera_ai_response": response,
},
)
if "prompt_injection" in typed_cat_scores and "prompt_injection" in self.category_thresholds:
if typed_cat_scores["prompt_injection"] >= self.category_thresholds["prompt_injection"]:
raise HTTPException(
status_code=400,
detail={
"error": "Violated prompt_injection threshold",
"lakera_ai_response": response,
},
)
elif flagged is True:
raise HTTPException(
status_code=400,
detail={
"error": "Violated content safety policy",
"lakera_ai_response": response,
},
)
return
async def _check(
self,
data: dict,
user_api_key_dict: UserAPIKeyAuth,
call_type: Literal[
"completion",
"text_completion",
"embeddings",
"image_generation",View on GitHub (pinned to 77b7c6c40c)
Solutions
- Modify the request to remove content that violates the configured content safety policy.
- Review the enabled moderation categories and thresholds in the guardrail configuration.
When it happens
Trigger: Thrown at litellm/proxy/guardrails/guardrail_hooks/lakera_ai.py:105 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/8348b1f26332f936.
Report an issue: GitHub.