BerriAI/litellm · error · HTTPException

Blocked by Prompt Security, Violations

Error message

Blocked by Prompt Security, Violations: {', '.join(violations)}

What it means

Error "Blocked by Prompt Security, Violations: {', '.join(violations)}" thrown in BerriAI/litellm.

Solutions

  1. Review the joined violations list and remove the offending content from the prompt.
  2. Tune the Prompt Security policy thresholds for false positives.

When it happens

Trigger: Thrown at litellm/proxy/guardrails/guardrail_hooks/prompt_security/prompt_security.py:280 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/1bdbdd3680af7398. Report an issue: GitHub.

Appendix: source

Thrown at litellm/proxy/guardrails/guardrail_hooks/prompt_security/prompt_security.py:280

        )
        response.raise_for_status()
        res: Final = response.json()

        self._log_api_response(
            url=f"{self.api_base}/api/protect",
            status_code=response.status_code,
            payload={"result": res.get("result")},
        )

        result: Final = res.get("result", {}).get("response", {})
        if result is None:
            return inputs

        action: Final = result.get("action")
        violations: Final = result.get("violations", [])

        if action == "block":
            raise HTTPException(
                status_code=400,
                detail="Blocked by Prompt Security, Violations: " + ", ".join(violations),
            )
        elif action == "modify":
            modified_text: Final = result.get("modified_text")
            if modified_text is not None:
                # If we combined multiple texts, return the modified version as single text
                # The framework will handle distributing it back
                inputs["texts"] = [modified_text]

        return inputs

    def _extract_texts_from_messages(self, messages: list) -> list[str]:
        """Extract text content from messages."""
        texts: Final = []
        for message in messages:
            content = message.get("content")
            if isinstance(content, str):

View on GitHub (pinned to 77b7c6c40c)