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]

Merge branch 'litellm_internal_staging' into feature/improve-gigachat-provider

KnyazShe7fc00d7244c
diff --cc litellm/passthrough/main.py
index c3ebc81541d,b1d4864cea7..aa4aef74e13
--- a/litellm/passthrough/main.py
+++ b/litellm/passthrough/main.py
@@@ -544,14 -345,17 +544,16 @@@ def llm_passthrough_route
)
else:
# Sync path - client.client.send returns Response directly
- response: httpx.Response = client.client.send(request=request, stream=is_streaming_request) # type: ignore
+ response: httpx.Response = client.client.send(
+ request=request, stream=is_streaming_request
+ ) # type: ignore
response.raise_for_status()
- if (
- hasattr(response, "iter_bytes") and is_streaming_request
- ): # yield the chunk, so we can store it in the logging object
- return _sync_streaming(response, litellm_logging_obj, provider_config)
+ if hasattr(response, "iter_bytes") and is_streaming_request:
+ return PassthroughStreamingResponse(
+ response, litellm_logging_obj, provider_config
+ )
else:
- # For non-streaming responses, yield the entire response
return response
except Exception as e:
if provider_config is None:
diff --cc litellm/proxy/common_request_processing.py
index 0135d625bc9,c2ffd9b077d..0f7d40c1181
--- a/litellm/proxy/common_request_processing.py
+++ b/litellm/proxy/common_request_processing.py
@@@ -1539,16 -1506,11 +1537,18 @@@ class ProxyBaseLLMRequestProcessing
cache_hit=cache_hit,
)
- logging_obj._on_deferred_stream_complete = _on_deferred_stream_complete # type: ignore[union-attr]
+ logging_obj._on_deferred_stream_complete = (
+ _on_deferred_stream_complete # type: ignore[union-attr]
+ )
if route_type == "allm_passthrough_route":
+ streaming_headers = custom_headers
+ if hasattr(response, "headers"):
+ streaming_headers = ProxyBaseLLMRequestProcessing._merge_passthrough_streaming_headers(
+ response_headers=getattr(response, "headers", None),
+ custom_headers=custom_headers,
+ )
+
# Check if response is an async generator
if self._is_streaming_response(response):
if asyncio.iscoroutine(response):