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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
[Bug Fix] Content Filter Guard (#16414)
Ishaan Jaffb2425677788a
diff --git a/litellm/__init__.py b/litellm/__init__.pyindex 7adc528b949..a879e1e6388 100644--- a/litellm/__init__.py+++ b/litellm/__init__.py@@ -34,7 +34,7 @@ from litellm.types.utils import (all_litellm_params as _litellm_completion_params,CredentialItem,PriorityReservationDict,-) # maintain backwards compatibility for root param+) # maintain backwards compatibility for root param.from litellm._logging import (set_verbose,_turn_on_debug,diff --git a/litellm/proxy/guardrails/guardrail_registry.py b/litellm/proxy/guardrails/guardrail_registry.pyindex d5e82695c7e..9369acd6462 100644--- a/litellm/proxy/guardrails/guardrail_registry.py+++ b/litellm/proxy/guardrails/guardrail_registry.py@@ -232,7 +232,13 @@ class GuardrailRegistry:"""try:guardrail_name = guardrail.get("guardrail_name")- litellm_params: str = safe_dumps(dict(guardrail.get("litellm_params", {})))+ # Properly serialize LitellmParams Pydantic model to dict+ litellm_params_obj = guardrail.get("litellm_params", {})+ if hasattr(litellm_params_obj, 'model_dump'):+ litellm_params_dict = litellm_params_obj.model_dump()+ else:+ litellm_params_dict = dict(litellm_params_obj) if litellm_params_obj else {}+ litellm_params: str = safe_dumps(litellm_params_dict)guardrail_info: str = safe_dumps(guardrail.get("guardrail_info", {}))# Create guardrail in DB@@ -278,7 +284,13 @@ class GuardrailRegistry:"""try:guardrail_name = guardrail.get("guardrail_name")- litellm_params: str = safe_dumps(dict(guardrail.get("litellm_params", {})))+ # Properly serialize LitellmParams Pydantic model to dict+ litellm_params_obj = guardrail.get("litellm_params", {})+ if hasattr(litellm_params_obj, 'model_dump'):+ litellm_params_dict = litellm_params_obj.model_dump()+ else:+ litellm_params_dict = dict(litellm_params_obj) if litellm_params_obj else {}+ litellm_params: str = safe_dumps(litellm_params_dict)guardrail_info: str = safe_dumps(guardrail.get("guardrail_info", {}))# Update in DB