{"record":{"id":"bb7165589c297bb5","repo":"BerriAI/litellm","slug":"contentpolicyviolationerror-exception-provider","errorCode":null,"errorMessage":"ContentPolicyViolationError: {exception_provider} - {message}","messagePattern":"ContentPolicyViolationError: (.+?) - (.+?)","errorType":"exception","errorClass":"ContentPolicyViolationError","httpStatus":400,"severity":"error","filePath":"litellm/litellm_core_utils/exception_mapping_utils.py","lineNumber":325,"sourceCode":"            message=f\"{exception_provider} - {message}\",\n            llm_provider=custom_llm_provider,\n            model=model,\n            response=getattr(original_exception, \"response\", None),\n            litellm_debug_info=extra_information,\n        )\n    elif \"A timeout occurred\" in error_str:\n        raise Timeout(\n            message=f\"{exception_provider} - {message}\",\n            model=model,\n            llm_provider=custom_llm_provider,\n            litellm_debug_info=extra_information,\n        )\n    elif (\n        (\"invalid_request_error\" in error_str and \"content_policy_violation\" in error_str)\n        or (\"Invalid prompt\" in error_str and \"violating our usage policy\" in error_str)\n        or (\"request was rejected as a result of the safety system\" in error_str.lower())\n    ):\n        raise ContentPolicyViolationError(\n            message=f\"ContentPolicyViolationError: {exception_provider} - {message}\",\n            llm_provider=custom_llm_provider,\n            model=model,\n            response=getattr(original_exception, \"response\", None),\n            litellm_debug_info=extra_information,\n        )\n    elif \"invalid_encrypted_content\" in error_str or \"could not be verified\" in error_str:\n        helpful_message: Final = (\n            f\"{exception_provider} - {message}\\n\\n\"\n            \" This error occurs when load balancing Responses API across deployments with different API keys.\\n\"\n            \"   Encrypted content is tied to the organization that created it and cannot be decrypted by other organizations.\\n\\n\"\n            \"   Solution: Enable 'encrypted_content_affinity' to route follow-up requests to the correct deployment:\\n\\n\"\n            \"   router_settings:\\n\"\n            \"     enable_pre_call_checks: true\\n\"\n            \"     optional_pre_call_checks:\\n\"\n            \"       - encrypted_content_affinity\\n\\n\"\n            \"   Learn more: https://docs.litellm.ai/docs/response_api#encrypted-content-affinity-multi-region-load-balancing\"\n        )","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/litellm_core_utils/exception_mapping_utils.py#L307-L343","documentation":"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.","triggerScenarios":"Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:325 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}