{"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":779,"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":761,"sourceCodeEnd":797,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/custom_guardrail.py#L761-L797","documentation":"When a guardrail is default_on and its event_hook is a Mode object (tag-based routing of guardrails), litellm must delegate to litellm_enterprise's EnterpriseCustomGuardrailHelper to evaluate tags. On OSS litellm that import fails and an ImportError is raised stating tag-based guardrails are a litellm-enterprise premium feature. The error is a license/edition gate, thrown at request-evaluation time in _should_run_for_event.","triggerScenarios":"Configuring a guardrail with default_on: true and mode specified with tags (a Mode object), then sending a request that reaches _should_run_for_event without litellm_enterprise installed and licensed.","commonSituations":"Copying enterprise example configs (mode with tags: {...}) into an OSS proxy deployment; previewing tag-based guardrail behavior locally without a premium key.","solutions":["Remove the tags section from the guardrail's mode config and use plain hooks (pre_call/during_call/...) supported on OSS","Install and license litellm-enterprise if tag-based guardrail selection is required","Disable default_on for that guardrail and attach it explicitly per-request/per-model instead of via tags"],"exampleFix":"# before (proxy_config.yaml)\nguardrails:\n  - guardrail_name: my-guard\n    litellm_params:\n      guardrail: my-guard\n      default_on: true\n      mode:\n        tags:\n          team: [\"finance\"]\n\n# after\nguardrails:\n  - guardrail_name: my-guard\n    litellm_params:\n      guardrail: my-guard\n      default_on: true\n      mode: during_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\nuses_tags = isinstance(guardrail.event_hook, Mode)\nif uses_tags and not enterprise_available():\n    strip_tags_from_config()  # or refuse to start","typeGuard":null,"tryCatchPattern":"try:\n    guardrail._should_run_for_event(event_type, data)\nexcept ImportError as e:\n    if \"litellm-enterprise\" in str(e):\n        remove_tag_mode_config(guardrail_name=guardrail.guardrail_name)\n    raise","preventionTips":["Keep enterprise-only config (Mode with tags) in separate yaml overlays applied only on licensed installs","Document edition requirements next to tag-based guardrail examples to avoid OSS copy-paste"],"tags":["guardrail","licensing","enterprise","config"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}