diff --git a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py index 7b9e17842..8be241458 100644 --- a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py +++ b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py @@ -478,10 +478,9 @@ async def pass_through_request( # noqa: PLR0915 json=_parsed_body, ) - if ( - response.headers.get("content-type") is not None - and response.headers["content-type"] == "text/event-stream" - ): + verbose_proxy_logger.debug("response.headers= %s", response.headers) + + if _is_streaming_response(response) is True: try: response.raise_for_status() except httpx.HTTPStatusError as e: @@ -621,6 +620,13 @@ def create_pass_through_route( return endpoint_func +def _is_streaming_response(response: httpx.Response) -> bool: + _content_type = response.headers.get("content-type") + if _content_type is not None and "text/event-stream" in _content_type: + return True + return False + + async def initialize_pass_through_endpoints(pass_through_endpoints: list): verbose_proxy_logger.debug("initializing pass through endpoints")