{"record":{"id":"aa4e46b47e1a3c64","repo":"BerriAI/litellm","slug":"setting-tag-based-guardrail-modes-is-only-availabl","errorCode":null,"errorMessage":"Setting tag based guardrail modes is only available in litellm-enterprise. You 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. \nPricing: https://www.litellm.ai/#pricing.","messagePattern":"Setting tag based guardrail modes is only available in litellm-enterprise\\. You 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\\. \nPricing: https://www\\.litellm\\.ai/#pricing\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"enterprise/litellm_enterprise/integrations/custom_guardrail.py","lineNumber":30,"sourceCode":"        ],\n        event_type: Optional[GuardrailEventHooks] = None,\n    ) -> Optional[bool]:\n        \"\"\"\n        Returns True if the guardrail should be run for this request and event_type.\n\n        Logic:\n        - If a request tag matches a Mode tag key, only run if event_type matches\n          the tag's value (the mode for that tag).\n        - If no request tag matches, fall back to default mode(s).\n        \"\"\"\n        from litellm.litellm_core_utils.litellm_logging import (\n            StandardLoggingPayloadSetup,\n        )\n        from litellm.proxy._types import CommonProxyErrors\n        from litellm.proxy.proxy_server import premium_user\n\n        if not premium_user:\n            raise Exception(\n                f\"Setting tag based guardrail modes is only available in litellm-enterprise. {CommonProxyErrors.not_premium_user.value}.\"\n            )\n\n        if event_hook is None or not isinstance(event_hook, Mode):\n            return None\n\n        proxy_server_request = data.get(\"proxy_server_request\", {})\n\n        request_tags = StandardLoggingPayloadSetup._get_request_tags(\n            litellm_params=data,\n            proxy_server_request=proxy_server_request,\n        )\n\n        # Check if any request tag matches a Mode tag key\n        matched_mode = None\n        if request_tags:\n            for tag in request_tags:\n                if tag in event_hook.tags:","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/enterprise/litellm_enterprise/integrations/custom_guardrail.py#L12-L48","documentation":"Raised by custom_guardrail.py in LiteLLM Enterprise when tag-based guardrail modes are configured but the running proxy is not a premium (licensed) user. The hook imports premium_user from litellm.proxy.proxy_server; if the enterprise license check failed, any attempt to resolve a Mode-tagged guardrail raises this exception.","triggerScenarios":"Configuring a guardrail with per-tag modes (e.g. litellm_params tag mappings whose value is a guardrail Mode like 'pre_call_check') and sending a request through a proxy without a valid LITELLM_LICENSE. The mode-resolution path executes on every relevant request once tag-based modes are configured.","commonSituations":"Trialing tag-based guardrails on an OSS install; LITELLM_LICENSE set but expired or invalid so premium_user resolved False; license env var not passed into the Docker container.","solutions":["Set LITELLM_LICENSE to a valid enterprise license key in the proxy environment and restart (get a trial key at litellm.ai/enterprise#trial if evaluating)","If you do not have a license, remove tag-based mode configuration from guardrails and use default_mode only","Verify premium status at startup: the proxy logs a premium/enterprise banner; check for license validation errors in logs"],"exampleFix":"# before\nguardrails:\n  - guardrail_name: bedrock\n    litellm_params:\n      guardrail: bedrock\n      mode: pre_call_check\n      tag_based_modes:\n        my_tag: pre_call_check\n# no LITELLM_LICENSE set -> error\n\n# after\nexport LITELLM_LICENSE=<valid-enterprise-key>\n# restart proxy","handlingStrategy":"validation","validationCode":"def has_enterprise(proxy_url: str, key: str) -> bool:\n    # enterprise features advertise themselves; a cheap proxy is to check config side\n    return bool(os.environ.get('LITELLM_LICENSE'))\n# or catch deterministically on first request in a canary call","typeGuard":null,"tryCatchPattern":"try:\n    await litellm.acompletion(**params)  # with tag-based guardrail modes\nexcept Exception as e:\n    if 'not_premium_user' in str(e) or 'litellm-enterprise' in str(e):\n        raise ConfigError('Set LITELLM_LICENSE or remove tag_based_modes') from e\n    raise","preventionTips":["Keep tag-based guardrail mode config in a repo template only enabled when LITELLM_LICENSE is set","Run a canary request after deploy to fail fast on licensing errors","Put LITELLM_LICENSE in the same secret store as DATABASE_URL so they deploy together"],"tags":["licensing","litellm-enterprise","guardrails","configuration"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}