From e4e76c626114da94477f356a71aa70087c3f08e8 Mon Sep 17 00:00:00 2001 From: Rohit Panda Date: Wed, 23 Apr 2025 17:42:53 +0000 Subject: [PATCH] fix: resolve Content-Length mismatch in pass-through endpoints --- .../proxy/pass_through_endpoints/pass_through_endpoints.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py index 2fbedaeb22..d438d9ad6a 100644 --- a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py +++ b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py @@ -402,13 +402,14 @@ class HttpPassThroughEndpointHelpers: requested_query_params=requested_query_params, ) else: + json_str = json.dumps(_parsed_body) # Pre-serialize JSON to avoid Content-Length mismatch # Generic httpx method response = await async_client.request( method=request.method, url=url, headers=headers, params=requested_query_params, - json=_parsed_body, + data=json_str ) return response @@ -584,10 +585,11 @@ async def pass_through_request( # noqa: PLR0915 }, ) if stream: + json_str = json.dumps(_parsed_body) # Pre-serialize JSON to avoid Content-Length mismatch req = async_client.build_request( "POST", url, - json=_parsed_body, + data=json_str, params=requested_query_params, headers=headers, )