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 remote-tracking branch 'origin/litellm_internal_staging' into litellm_lit_4561_bedrock_passthrough_content_type

mateo-berri8ced9f56a1c0
diff --cc litellm/proxy/common_request_processing.py
index 24831a64410,adae59a1174..165e58c56f7
--- a/litellm/proxy/common_request_processing.py
+++ b/litellm/proxy/common_request_processing.py
@@@ -1764,9 -2037,8 +2037,9 @@@ class ProxyBaseLLMRequestProcessing
# For passthrough routes, stream directly without error parsing
# since we're dealing with raw binary data (e.g., AWS event streams)
return StreamingResponse(
- content=generator, # type: ignore[arg-type]
+ content=generator,
status_code=status.HTTP_200_OK,
+ media_type=self._passthrough_event_stream_media_type(),
headers=custom_headers,
)
else:
@@@ -2215,17 -2492,12 +2493,17 @@@
self.data.get("endpoint"),
)
- def _passthrough_event_stream_media_type(self) -> Optional[str]:
+ def _passthrough_event_stream_media_type(self) -> str | None:
"""
- Content-type for a buffered passthrough event-stream response, resolved
- from the provider handler so the proxy stays provider-agnostic. Mirrors
- the upstream content-type the non-streaming path forwards, since the
- buffered streaming generator carries no headers of its own.
+ Content-type for a passthrough event-stream response, resolved from the
+ provider handler so the proxy stays provider-agnostic. Mirrors the
+ upstream content-type the non-streaming path forwards, since the
+ streaming generator carries no headers of its own. Used for both the
+ buffered (guardrail-rewritten) and the unbuffered relay paths so
+ clients that enforce the event-stream content-type (e.g. Claude Code on
+ Bedrock invoke-with-response-stream) see the correct header instead of
+ Starlette's application/octet-stream default. Returns None for providers
+ with no event-stream media type, leaving the response default unchanged.
"""
from litellm.llms.pass_through.guardrail_translation.handler import (
LlmPassthroughRouteHandler,