From aaf35c79667db3c8f14760d5f27b15de591b590c Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Thu, 6 Jun 2024 09:03:31 -0700 Subject: [PATCH] feat - enforce enforced_params as a premium feature --- litellm/proxy/auth/auth_checks.py | 11 +++++++++++ litellm/proxy/proxy_server.py | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/litellm/proxy/auth/auth_checks.py b/litellm/proxy/auth/auth_checks.py index d5c09f6514f..969ef8831db 100644 --- a/litellm/proxy/auth/auth_checks.py +++ b/litellm/proxy/auth/auth_checks.py @@ -98,6 +98,17 @@ def common_checks( f"'user' param not passed in. 'enforce_user_param'={general_settings['enforce_user_param']}" ) if general_settings.get("enforced_params", None) is not None: + # Enterprise ONLY Feature + # we already validate if user is premium_user when reading the config + # Add an extra premium_usercheck here too, just incase + from litellm.proxy.proxy_server import premium_user, CommonProxyErrors + + if premium_user is not True: + raise ValueError( + "Trying to use `enforced_params`" + + CommonProxyErrors.not_premium_user.value + ) + if route in LiteLLMRoutes.openai_routes.value: # loop through each enforced param # example enforced_params ['user', 'metadata', 'metadata.generation_name'] diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 8cf2fa118d2..3ee1b01c2a0 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -2863,6 +2863,16 @@ class ProxyConfig: ) health_check_interval = general_settings.get("health_check_interval", 300) + ## check if user has set a premium feature in general_settings + if ( + general_settings.get("enforced_params") is not None + and premium_user is not True + ): + raise ValueError( + "Trying to use `enforced_params`" + + CommonProxyErrors.not_premium_user.value + ) + router_params: dict = { "cache_responses": litellm.cache != None, # cache if user passed in cache values