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(passthrough): only fall back to url query when client sends none

Devin AI94771abd845e
diff --git a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py
index b0f8063e5f8..031b77e691b 100644
--- a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py
+++ b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py
@@ -986,10 +986,7 @@ async def pass_through_request(
forward_headers=forward_headers,
)
- requested_query_params: dict | None = {
- **dict(url.params),
- **(query_params or dict(request.query_params)),
- } or None
+ requested_query_params: dict | None = query_params or dict(request.query_params) or None
endpoint_type: Final[EndpointType] = HttpPassThroughEndpointHelpers.get_endpoint_type(str(url))
diff --git a/tests/test_litellm/proxy/pass_through_endpoints/test_pass_through_endpoints.py b/tests/test_litellm/proxy/pass_through_endpoints/test_pass_through_endpoints.py
index 8a59dcbcafd..18baeeb7103 100644
--- a/tests/test_litellm/proxy/pass_through_endpoints/test_pass_through_endpoints.py
+++ b/tests/test_litellm/proxy/pass_through_endpoints/test_pass_through_endpoints.py
@@ -2529,12 +2529,12 @@ async def test_pass_through_request_default_query_params_reach_the_wire():
@pytest.mark.asyncio
-async def test_pass_through_request_without_merge_preserves_target_query():
+async def test_pass_through_request_without_merge_replaces_target_query():
wire_url = await _run_pass_through_and_capture_wire_url(
target="https://www.bing.com/search?setLang=en-US",
incoming_query="q=litellm",
)
- assert dict(wire_url.params) == {"setLang": "en-US", "q": "litellm"}
+ assert dict(wire_url.params) == {"q": "litellm"}
@pytest.mark.asyncio
@@ -2546,15 +2546,6 @@ async def test_pass_through_request_preserves_target_query_without_client_query(
assert dict(wire_url.params) == {"alt": "sse"}
-async def test_pass_through_request_preserves_target_query_with_client_query():
- wire_url = await _run_pass_through_and_capture_wire_url(
- target="https://example.com/v1/models/gemini:streamGenerateContent?alt=sse",
- incoming_query="key=abc",
- )
- assert dict(wire_url.params) == {"alt": "sse", "key": "abc"}
-
-
@pytest.mark.asyncio
async def test_pass_through_request_merge_query_params_rewrites_managed_ids_on_the_wire():
"""