BerriAI/litellm · error · HTTPException

Violated prompt_injection threshold

Error message

Violated prompt_injection threshold

What it means

Error "Violated prompt_injection threshold" thrown in BerriAI/litellm.

Source

Thrown at litellm/proxy/guardrails/guardrail_hooks/lakera_ai.py:97

        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,
                detail={
                    "error": "Violated content safety policy",
                    "lakera_ai_response": response,
                },
            )

        return

    async def _check(

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Raise the prompt_injection threshold in the lakera_ai guardrail config for false positives.
  2. Remove injection-like content (e.g. instructions to ignore prior rules) from the request.

When it happens

Trigger: Thrown at litellm/proxy/guardrails/guardrail_hooks/lakera_ai.py:97 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/ce5d7a284ea342aa. Report an issue: GitHub.