BerriAI/litellm · error · Exception

Trying to use Llm GuardYou must be a LiteLLM Enterprise user

Error message

Trying to use Llm GuardYou 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

The callback 'llmguard_moderations' resolved its import (litellm-enterprise is installed), but premium_user is not True. The proxy therefore rejects the callback with the not_premium_user message appended to 'Trying to use Llm Guard'. premium_user is computed once at proxy startup from the LITELLM_LICENSE key.

Source

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

                        "Trying to use Google Text Moderation,"
                        + CommonProxyErrors.missing_enterprise_package_docker.value
                    )

                if premium_user is not True:
                    raise Exception("Trying to use Google Text Moderation" + CommonProxyErrors.not_premium_user.value)

                google_text_moderation_obj = _ENTERPRISE_GoogleTextModeration()
                imported_list.append(google_text_moderation_obj)
            elif isinstance(callback, str) and callback == "llmguard_moderations":
                try:
                    from litellm_enterprise.enterprise_callbacks.llm_guard import (
                        _ENTERPRISE_LLMGuard,
                    )
                except ImportError:
                    raise Exception("Trying to use Llm Guard" + CommonProxyErrors.missing_enterprise_package.value)

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

                llm_guard_moderation_obj = _ENTERPRISE_LLMGuard()
                imported_list.append(llm_guard_moderation_obj)
            elif isinstance(callback, str) and callback == "blocked_user_check":
                try:
                    from enterprise.enterprise_hooks.blocked_user_list import (
                        _ENTERPRISE_BlockedUserList,
                    )
                except ImportError:
                    raise Exception(
                        "Trying to use Blocked User List" + CommonProxyErrors.missing_enterprise_package_docker.value
                    )

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

                blocked_user_list = _ENTERPRISE_BlockedUserList(prisma_client=prisma_client)
                imported_list.append(blocked_user_list)

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Set LITELLM_LICENSE to a valid enterprise key (7-day trial: https://www.litellm.ai/enterprise#trial) and restart the proxy.
  2. Or remove 'llmguard_moderations' from litellm_settings.callbacks.
  3. Confirm the env var reaches the proxy process (Docker: pass -e LITELLM_LICENSE=...; compose: list it under environment).

Example fix

# before
docker run litellm/litellm --config config.yaml   # no LITELLM_LICENSE

# after
docker run -e LITELLM_LICENSE="sk-..." litellm/litellm --config config.yaml
Defensive patterns

Strategy: validation

Validate before calling

import os

def llm_guard_config_ok(cfg: dict) -> str | None:
    callbacks = (cfg.get("litellm_settings") or {}).get("callbacks") or []
    if "llmguard_moderations" in callbacks and not os.environ.get("LITELLM_LICENSE"):
        return "llmguard_moderations requires LITELLM_LICENSE"
    return None

msg = llm_guard_config_ok(cfg)
if msg:
    raise SystemExit(msg)

Try / catch

try:
    start_proxy(cfg)
except Exception as e:
    if "Llm Guard" in str(e) and "LiteLLM Enterprise user" in str(e):
        log.error("license missing for llmguard_moderations; export LITELLM_LICENSE")
        raise SystemExit(2)
    raise

Prevention

When it happens

Trigger: litellm-enterprise is installed and callbacks include 'llmguard_moderations', but LITELLM_LICENSE is missing, expired, or invalid. The import in callback_utils.py:267 succeeded, then the check at line 275 failed.

Common situations: Package installed but the license env var was never exported. A trial key expired between runs. The license is set in a shell but the proxy runs under Docker or systemd without that env.

Related errors


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