{"record":{"id":"1dc7b16fc0657b44","repo":"BerriAI/litellm","slug":"trying-to-use-openai-moderations-check-this-uses-t","errorCode":null,"errorMessage":"Trying to use OpenAI Moderations Check,This uses the enterprise folder - only available on the Docker image.","messagePattern":"Trying to use OpenAI Moderations Check,This uses the enterprise folder - only available on the Docker image\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/proxy/common_utils/callback_utils.py","lineNumber":221,"sourceCode":"                        _ENTERPRISE_SecretDetection,\n                    )\n                except ImportError:\n                    raise Exception(\n                        \"Trying to use Secret Detection\" + CommonProxyErrors.missing_enterprise_package.value\n                    )\n\n                if premium_user is not True:\n                    raise Exception(\"Trying to use secret hiding\" + CommonProxyErrors.not_premium_user.value)\n\n                _secret_detection_object = _ENTERPRISE_SecretDetection()\n                imported_list.append(_secret_detection_object)\n            elif isinstance(callback, str) and callback == \"openai_moderations\":\n                try:\n                    from enterprise.enterprise_hooks.openai_moderation import (\n                        _ENTERPRISE_OpenAI_Moderation,\n                    )\n                except ImportError:\n                    raise Exception(\n                        \"Trying to use OpenAI Moderations Check,\"\n                        + CommonProxyErrors.missing_enterprise_package_docker.value\n                    )\n\n                if premium_user is not True:\n                    raise Exception(\"Trying to use OpenAI Moderations Check\" + CommonProxyErrors.not_premium_user.value)\n\n                openai_moderations_object = _ENTERPRISE_OpenAI_Moderation()\n                imported_list.append(openai_moderations_object)\n            elif isinstance(callback, str) and callback == \"lakera_prompt_injection\":\n                from litellm.proxy.guardrails.guardrail_hooks.lakera_ai import (\n                    lakeraAI_Moderation,\n                )\n\n                init_params = {}\n                if \"lakera_prompt_injection\" in callback_specific_params and isinstance(\n                    callback_specific_params[\"lakera_prompt_injection\"], dict\n                ):","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/common_utils/callback_utils.py#L203-L239","documentation":"Raised at startup when callbacks enables 'openai_moderations' but importing enterprise.enterprise_hooks.openai_moderation._ENTERPRISE_OpenAI_Moderation fails. Note the top-level package is 'enterprise' (not 'litellm_enterprise'): that folder ships only inside LiteLLM's official enterprise Docker image, so pip installs can never satisfy it. The error text ('This uses the enterprise folder - only available on the Docker image.') says so explicitly; the leading comma is a string-concatenation artifact.","triggerScenarios":"Running the proxy via pip (litellm[proxy] or uv) with callbacks: ['openai_moderations'] in config.yaml. The import is attempted at config load and the proxy exits immediately.","commonSituations":"Migrating a docker deployment to a pip/venv install (or python:slim custom images) while keeping the same config; local dev installs copying prod config; building slim images that omit the enterprise folder.","solutions":["Run the official LiteLLM proxy Docker image, which contains the enterprise folder: docker run litellm/litellm.","Or remove 'openai_moderations' from callbacks when running from pip.","Keep in mind a license (LITELLM_LICENSE) is additionally required once the import succeeds.","Check for the module first in custom images: python -c \"import enterprise.enterprise_hooks.openai_moderation\"."],"exampleFix":"# before\npip install 'litellm[proxy]' && litellm --config config.yaml  # config has callbacks: [\"openai_moderations\"]\n\n# after\ndocker run -v $(pwd)/config.yaml:/app/config.yaml litellm/litellm --config /app/config.yaml","handlingStrategy":"validation","validationCode":"import importlib.util\n\nRUNNING_IN_OFFICIAL_IMAGE = importlib.util.find_spec('enterprise.enterprise_hooks.openai_moderation') is not None\nif 'openai_moderations' in callbacks and not RUNNING_IN_OFFICIAL_IMAGE:\n    raise SystemExit('openai_moderations requires the official LiteLLM Docker image')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a matrix note: which callbacks need pip package litellm-enterprise vs the Docker-only enterprise folder.","Smoke-test new images with python -c \"import enterprise.enterprise_hooks.openai_moderation\" before shipping config that uses it.","Run moderation-needing deployments exclusively from the official image tags."],"tags":["litellm","proxy","callbacks","moderation","enterprise","docker","importerror"],"backgroundTag":"missing-optional-dependency","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}