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]

fix: _extract_fields_recursive

Ishaan Jaffer57a2ec3beb7f
diff --git a/litellm/proxy/guardrails/guardrail_endpoints.py b/litellm/proxy/guardrails/guardrail_endpoints.py
index c146536e632..c1756500c63 100644
--- a/litellm/proxy/guardrails/guardrail_endpoints.py
+++ b/litellm/proxy/guardrails/guardrail_endpoints.py
@@ -841,6 +841,11 @@ def _extract_fields_recursive(
"TypeVar",
):
continue
+ # Handle Optional[T] where T is still a TypeVar
+ if hasattr(field_annotation, "__args__"):
+ non_none_args = [arg for arg in field_annotation.__args__ if arg is not type(None)]
+ if non_none_args and isinstance(non_none_args[0], TypeVar):
+ continue
# Get field metadata
description = field.description or field_name