From cea7b7301536bf2a8df5512e9f2a88f5d3bda90a Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Tue, 20 Aug 2024 17:34:28 -0700 Subject: [PATCH] enforece guardrails per API Key as enterprise --- litellm/proxy/litellm_pre_call_utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/litellm/proxy/litellm_pre_call_utils.py b/litellm/proxy/litellm_pre_call_utils.py index c6070c206..9166e1341 100644 --- a/litellm/proxy/litellm_pre_call_utils.py +++ b/litellm/proxy/litellm_pre_call_utils.py @@ -354,6 +354,13 @@ def move_guardrails_to_metadata( """ if user_api_key_dict.metadata: if "guardrails" in user_api_key_dict.metadata: + from litellm.proxy.proxy_server import premium_user + + if premium_user is not True: + raise ValueError( + f"Using Guardrails on API Key {CommonProxyErrors.not_premium_user}" + ) + data[_metadata_variable_name]["guardrails"] = user_api_key_dict.metadata[ "guardrails" ]