BerriAI/litellm · error · HTTPException
Violated jailbreak threshold
Error message
Violated jailbreak threshold
What it means
Error "Violated jailbreak threshold" thrown in BerriAI/litellm.
Source
Thrown at litellm/proxy/guardrails/guardrail_hooks/lakera_ai.py:88
self.api_base = api_base or get_secret("LAKERA_API_BASE") or "https://api.lakera.ai"
super().__init__(**kwargs)
#### CALL HOOKS - proxy only ####
def _check_response_flagged(self, response: dict) -> None:
_results: Final = response.get("results", [])
if len(_results) <= 0:
return
flagged: Final = _results[0].get("flagged", False)
category_scores: Final[dict | None] = _results[0].get("category_scores", None)
if self.category_thresholds is not None:
if category_scores is not None:
typed_cat_scores: Final = LakeraCategoryThresholds(**category_scores)
if "jailbreak" in typed_cat_scores and "jailbreak" in self.category_thresholds:
# check if above jailbreak threshold
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,View on GitHub (pinned to 77b7c6c40c)
Solutions
- Raise the jailbreak threshold in the lakera_ai guardrail config if legitimate prompts are being flagged.
- Rephrase the request to remove jailbreak-like phrasing.
When it happens
Trigger: Thrown at litellm/proxy/guardrails/guardrail_hooks/lakera_ai.py:88 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/c5244787c7201d41.
Report an issue: GitHub.