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 test_openai_moderation_error_raising

Ishaan Jaff1ef17c2f0e07
diff --git a/litellm/types/llms/openai.py b/litellm/types/llms/openai.py
index 912f8be2cbd..ff0aa895345 100644
--- a/litellm/types/llms/openai.py
+++ b/litellm/types/llms/openai.py
@@ -1270,6 +1270,13 @@ class ImageGenerationRequestQuality(str, Enum):
HD = "hd"
+class OpenAIModerationResult(BaseLiteLLMOpenAIResponseObject):
+ categories: Optional[Dict]
+ category_applied_input_types: Optional[Dict]
+ category_scores: Optional[Dict]
+ flagged: Optional[bool]
+
+
class OpenAIModerationResponse(BaseLiteLLMOpenAIResponseObject):
"""
Response from the OpenAI Moderation API.
@@ -1281,7 +1288,7 @@ class OpenAIModerationResponse(BaseLiteLLMOpenAIResponseObject):
model: str
"""The model used to generate the moderation results."""
- results: List[Dict]
+ results: List[OpenAIModerationResult]
"""A list of moderation objects."""
# Define private attributes using PrivateAttr