BerriAI/litellm · error · HTTPException
Violated guardrail policy
Error message
Violated guardrail policy
What it means
Raised when Aporia's /validate responds with a non-allow action: the content violated the deployed Aporia guardrail policy, and the action/warning details from the response determine the block.
Solutions
- Remove the policy-violating content and retry.
- Review the Aporia policy configuration if the block is unexpected.
Example fix
Check the Aporia dashboard for violation details.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/proxy/guardrails/guardrail_hooks/aporia_ai/aporia_ai.py:133 when the library encounters an invalid state.
Common situations: The Aporia guardrail flagged the request/response as violating policy.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/361d554bca6197a6.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/proxy/guardrails/guardrail_hooks/aporia_ai/aporia_ai.py:133
}
'
"""
response: Final = await self.async_handler.post(
url=self.aporia_api_base + "/validate",
data=_json_data,
headers={
"X-APORIA-API-KEY": self.aporia_api_key,
"Content-Type": "application/json",
},
)
verbose_proxy_logger.debug("Aporia AI response: %s", response.text)
if response.status_code == 200:
# check if the response was flagged
_json_response: Final = response.json()
action: str = _json_response.get("action") # possible values are modify, passthrough, block, rephrase
if action == "block":
raise HTTPException(
status_code=400,
detail={
"error": "Violated guardrail policy",
"aporia_ai_response": _json_response,
},
)
@log_guardrail_information
async def async_post_call_success_hook(
self,
data: dict,
user_api_key_dict: UserAPIKeyAuth,
response,
):
from litellm.proxy.common_utils.callback_utils import (
add_guardrail_to_applied_guardrails_header,
)
View on GitHub (pinned to 77b7c6c40c)