{"record":{"id":"21065a86135bd15e","repo":"BerriAI/litellm","slug":"setting-tag-based-guardrails-is-only-available-in","errorCode":null,"errorMessage":"Setting tag-based guardrails is only available in litellm-enterprise. You must be a premium user to use this feature.","messagePattern":"Setting tag-based guardrails is only available in litellm-enterprise\\. You must be a premium user to use this feature\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/custom_guardrail.py","lineNumber":782,"sourceCode":"            self.event_hook,\n            requested_guardrails,\n            self.default_on,\n        )\n        if self.default_on is True and self.guardrail_name in opted_out_global_guardrails:\n            return False\n\n        if self.default_on is True and disable_global_guardrail is True:\n            return False\n\n        if self.default_on is True and disable_global_guardrail is not True:\n            if self._event_hook_is_event_type(event_type):\n                if isinstance(self.event_hook, Mode):\n                    try:\n                        from litellm_enterprise.integrations.custom_guardrail import (\n                            EnterpriseCustomGuardrailHelper,\n                        )\n                    except ImportError:\n                        raise ImportError(\n                            \"Setting tag-based guardrails is only available in litellm-enterprise. You must be a premium user to use this feature.\"\n                        )\n                    result = EnterpriseCustomGuardrailHelper._should_run_if_mode_by_tag(\n                        data, self.event_hook, event_type\n                    )\n                    if result is not None:\n                        return result\n                return True\n            return False\n\n        if (\n            self.event_hook\n            and not self._guardrail_is_in_requested_guardrails(requested_guardrails)\n            and event_type.value != \"logging_only\"\n        ):\n            return False\n\n        if not self._event_hook_is_event_type(event_type):","sourceCodeStart":764,"sourceCodeEnd":800,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/custom_guardrail.py#L764-L800","documentation":"Tag-based guardrail activation — event_hook configured as a Mode object with tags/defaults — is implemented only in the closed-source litellm_enterprise package. When _should_run_hook (default_on path) hits a Mode and the litellm_enterprise.integrations.custom_guardrail import fails, it raises this ImportError stating the feature requires the premium package.","triggerScenarios":"Configuring a guardrail with a Mode event_hook (mode containing tags: {...}) while litellm_enterprise is not installed or not licensed; default_on guardrails with tag-based modes on community litellm.","commonSituations":"Copying enterprise-style YAML examples into a community deployment; feature flags written for litellm-enterprise trialing on OSS; premium license expired or key not configured so the package import path is unavailable.","solutions":["Install litellm_enterprise and configure your premium key (LITELLM_LICENSE) if you have an enterprise agreement","Otherwise flatten the config: use plain event_hook values (pre_call, during_call, post_call) instead of tag-based Modes","Confirm whether you actually need tag scoping before paying — plain modes cover most setups"],"exampleFix":"# before\nMyGuardrail(event_hook=Mode(default=[GuardrailEventHooks.pre_call], tags={'team': ['support']}))\n# ImportError: tag-based guardrails are only available in litellm-enterprise\n\n# after\nMyGuardrail(event_hook=[GuardrailEventHooks.pre_call])","handlingStrategy":"validation","validationCode":"def enterprise_available() -> bool:\n    try:\n        import litellm_enterprise  # noqa: F401\n        return True\n    except ImportError:\n        return False\n\nif isinstance(guardrail.event_hook, Mode) and not enterprise_available():\n    raise ConfigError('tag-based guardrail Modes require litellm-enterprise; use plain event_hook values')","typeGuard":"def is_mode_config(event_hook) -> bool:\n    from litellm.types.utils import Mode\n    return isinstance(event_hook, Mode)","tryCatchPattern":"except ImportError as e:\n    if 'litellm-enterprise' in str(e):\n        either install/license litellm_enterprise or replace Mode config with plain event_hook lists\n    raise","preventionTips":["Keep enterprise-only config out of community deployments via config linting","Detect Mode objects in guardrail config at load time and reject them early on OSS","Document which YAML keys require the premium package"],"tags":["enterprise","premium","license","guardrail","importerror","litellm"],"backgroundTag":"premium-feature-locked","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}