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: add custom_body param to URL-based endpoint_func in create_pass_through_route (#23412)

Joe Reyna483a605f6e5c
diff --git a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py
index a06a3aa3daf..8cbc8b03992 100644
--- a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py
+++ b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py
@@ -1133,6 +1133,7 @@ def create_pass_through_route(
fastapi_response: Response,
user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),
subpath: str = "", # captures sub-paths when include_subpath=True
+ custom_body: Optional[dict] = None, # caller-supplied body takes precedence over request-parsed body
):
from litellm.proxy.pass_through_endpoints.pass_through_endpoints import (
InitPassThroughEndpointHelpers,
@@ -1208,9 +1209,11 @@ def create_pass_through_route(
)
if query_params:
final_query_params.update(query_params)
- # Use the body parsed from the raw request
+ # Caller-supplied custom_body takes precedence over the request-parsed body
final_custom_body: Optional[dict] = None
- if isinstance(custom_body_data, dict):
+ if custom_body is not None:
+ final_custom_body = custom_body
+ elif isinstance(custom_body_data, dict):
final_custom_body = custom_body_data
return await pass_through_request( # type: ignore