BerriAI/litellm · error · ContentPolicyViolationError
ContentPolicyViolationError
Error message
ContentPolicyViolationError: {exception_provider} - {message} What it means
Exception-mapping branch: when the error string indicates a content policy violation (e.g. 'content_policy_violation'), the exception is re-raised as litellm ContentPolicyViolationError, meaning the provider refused the request for safety-policy reasons.
Solutions
- The provider's content policy rejected the request; revise the prompt or inputs.
- Check the provider's usage policies for the flagged content category.
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:325 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/bb7165589c297bb5.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:325
message=f"{exception_provider} - {message}",
llm_provider=custom_llm_provider,
model=model,
response=getattr(original_exception, "response", None),
litellm_debug_info=extra_information,
)
elif "A timeout occurred" in error_str:
raise Timeout(
message=f"{exception_provider} - {message}",
model=model,
llm_provider=custom_llm_provider,
litellm_debug_info=extra_information,
)
elif (
("invalid_request_error" in error_str and "content_policy_violation" in error_str)
or ("Invalid prompt" in error_str and "violating our usage policy" in error_str)
or ("request was rejected as a result of the safety system" in error_str.lower())
):
raise ContentPolicyViolationError(
message=f"ContentPolicyViolationError: {exception_provider} - {message}",
llm_provider=custom_llm_provider,
model=model,
response=getattr(original_exception, "response", None),
litellm_debug_info=extra_information,
)
elif "invalid_encrypted_content" in error_str or "could not be verified" in error_str:
helpful_message: Final = (
f"{exception_provider} - {message}\n\n"
" This error occurs when load balancing Responses API across deployments with different API keys.\n"
" Encrypted content is tied to the organization that created it and cannot be decrypted by other organizations.\n\n"
" Solution: Enable 'encrypted_content_affinity' to route follow-up requests to the correct deployment:\n\n"
" router_settings:\n"
" enable_pre_call_checks: true\n"
" optional_pre_call_checks:\n"
" - encrypted_content_affinity\n\n"
" Learn more: https://docs.litellm.ai/docs/response_api#encrypted-content-affinity-multi-region-load-balancing"
)View on GitHub (pinned to 77b7c6c40c)