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
fix _read_request_body (#7706)
Ishaan Jaff7923cb1a6415
diff --git a/litellm/proxy/common_utils/http_parsing_utils.py b/litellm/proxy/common_utils/http_parsing_utils.pyindex 1fb0da275ed..63b904602ac 100644--- a/litellm/proxy/common_utils/http_parsing_utils.py+++ b/litellm/proxy/common_utils/http_parsing_utils.py@@ -1,6 +1,7 @@import jsonfrom typing import Dict, List, Optional+import orjsonfrom fastapi import Request, UploadFile, statusfrom litellm._logging import verbose_proxy_logger@@ -32,13 +33,10 @@ async def _read_request_body(request: Optional[Request]) -> Dict:if not body:return {}- # Decode the body to a string- body_str = body.decode()-# Attempt JSON parsing (safe for untrusted input)- return json.loads(body_str)+ return orjson.loads(body)- except json.JSONDecodeError:+ except (json.JSONDecodeError, orjson.JSONDecodeError):# Log detailed information for debuggingverbose_proxy_logger.exception("Invalid JSON payload received.")return {}