Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

enforece guardrails per API Key as enterprise

Ishaan Jaffcea7b7301536
diff --git a/litellm/proxy/litellm_pre_call_utils.py b/litellm/proxy/litellm_pre_call_utils.py
index c6070c2062e..9166e13413c 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"
]