BerriAI/litellm · error · Exception

Trying to use OpenAI Moderations CheckYou must be a LiteLLM

Error message

Trying to use OpenAI Moderations CheckYou must be a LiteLLM Enterprise user to use this feature. If you have a license please set `LITELLM_LICENSE` in your env. Get a 7 day trial key here: https://www.litellm.ai/enterprise#trial. 
Pricing: https://www.litellm.ai/#pricing

What it means

Raised at startup when 'openai_moderations' is configured and the enterprise import succeeded (Docker image), but premium_user is not True. As with other enterprise callbacks, premium status derives from the LITELLM_LICENSE env var on the proxy process; without a valid license the OpenAI moderation hook raises this Exception with the not-premium-user boilerplate, and config load aborts.

Source

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

                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
                ):
                    init_params = callback_specific_params["lakera_prompt_injection"]
                lakera_moderations_object = lakeraAI_Moderation(**init_params)
                imported_list.append(lakera_moderations_object)
            elif isinstance(callback, str) and callback == "aporia_prompt_injection":
                from litellm.proxy.guardrails.guardrail_hooks.aporia_ai.aporia_ai import (
                    AporiaGuardrail,

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Pass the license into the container: docker run -e LITELLM_LICENSE=... litellm/litellm.
  2. Renew/obtain a key at https://www.litellm.ai/enterprise#trial if expired.
  3. Verify with printenv LITELLM_LICENSE inside the running container; restart after fixing.
  4. Drop the callback if you do not plan to license this deployment.

Example fix

# before
docker run -v $PWD/config.yaml:/app/config.yaml litellm/litellm  # LITELLM_LICENSE missing

# after
docker run -e LITELLM_LICENSE=$LITELLM_LICENSE -v $PWD/config.yaml:/app/config.yaml litellm/litellm
Defensive patterns

Strategy: validation

Validate before calling

import os, importlib.util

in_image = importlib.util.find_spec('enterprise.enterprise_hooks.openai_moderation') is not None
if 'openai_moderations' in callbacks and in_image and not os.environ.get('LITELLM_LICENSE'):
    raise SystemExit('openai_moderations needs LITELLM_LICENSE set')

Prevention

When it happens

Trigger: Official Docker image with callbacks: ['openai_moderations'] but LITELLM_LICENSE not passed (-e/--env-file forgotten), expired trial, or license invalid for the instance.

Common situations: docker-compose files updated with the callback but not the license env; helm chart values missing the secret; prod has the license while staging replicas do not.

Related errors


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