BerriAI/litellm · error · Exception

Trying to use OpenAI Moderations Check,This uses the enterpr

Error message

Trying to use OpenAI Moderations Check,This uses the enterprise folder - only available on the Docker image.

What it means

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.

Source

Thrown at litellm/proxy/common_utils/callback_utils.py:221

                        _ENTERPRISE_SecretDetection,
                    )
                except ImportError:
                    raise Exception(
                        "Trying to use Secret Detection" + CommonProxyErrors.missing_enterprise_package.value
                    )

                if premium_user is not True:
                    raise Exception("Trying to use secret hiding" + CommonProxyErrors.not_premium_user.value)

                _secret_detection_object = _ENTERPRISE_SecretDetection()
                imported_list.append(_secret_detection_object)
            elif isinstance(callback, str) and callback == "openai_moderations":
                try:
                    from enterprise.enterprise_hooks.openai_moderation import (
                        _ENTERPRISE_OpenAI_Moderation,
                    )
                except ImportError:
                    raise Exception(
                        "Trying to use OpenAI Moderations Check,"
                        + CommonProxyErrors.missing_enterprise_package_docker.value
                    )

                if premium_user is not True:
                    raise Exception("Trying to use OpenAI Moderations Check" + CommonProxyErrors.not_premium_user.value)

                openai_moderations_object = _ENTERPRISE_OpenAI_Moderation()
                imported_list.append(openai_moderations_object)
            elif isinstance(callback, str) and callback == "lakera_prompt_injection":
                from litellm.proxy.guardrails.guardrail_hooks.lakera_ai import (
                    lakeraAI_Moderation,
                )

                init_params = {}
                if "lakera_prompt_injection" in callback_specific_params and isinstance(
                    callback_specific_params["lakera_prompt_injection"], dict
                ):

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Run the official LiteLLM proxy Docker image, which contains the enterprise folder: docker run litellm/litellm.
  2. Or remove 'openai_moderations' from callbacks when running from pip.
  3. Keep in mind a license (LITELLM_LICENSE) is additionally required once the import succeeds.
  4. Check for the module first in custom images: python -c "import enterprise.enterprise_hooks.openai_moderation".

Example fix

# before
pip install 'litellm[proxy]' && litellm --config config.yaml  # config has callbacks: ["openai_moderations"]

# after
docker run -v $(pwd)/config.yaml:/app/config.yaml litellm/litellm --config /app/config.yaml
Defensive patterns

Strategy: validation

Validate before calling

import importlib.util

RUNNING_IN_OFFICIAL_IMAGE = importlib.util.find_spec('enterprise.enterprise_hooks.openai_moderation') is not None
if 'openai_moderations' in callbacks and not RUNNING_IN_OFFICIAL_IMAGE:
    raise SystemExit('openai_moderations requires the official LiteLLM Docker image')

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/1dc7b16fc0657b44. Report an issue: GitHub.