From a5b86d3b2fe9383b600930d8de65c0d5a5b813f8 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 13 Mar 2026 00:57:18 +0000 Subject: [PATCH] fix: revert realtime endpoint change, replace fragile asserts with fallback - Revert realtime_endpoints/endpoints.py to original Response return (preserves backwards-compatible API contract; accepts 1 known mypy error) - Replace 'assert provider_config is not None' with proper if/else fallback that re-raises the original exception when provider_config is None, avoiding AssertionError in production and python -O issues Co-authored-by: yuneng-jiang --- litellm/llms/custom_httpx/llm_http_handler.py | 22 ++++++++++--------- litellm/proxy/realtime_endpoints/endpoints.py | 5 +++-- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/litellm/llms/custom_httpx/llm_http_handler.py b/litellm/llms/custom_httpx/llm_http_handler.py index 10caafb5ebe..a8d649064ac 100644 --- a/litellm/llms/custom_httpx/llm_http_handler.py +++ b/litellm/llms/custom_httpx/llm_http_handler.py @@ -4871,11 +4871,12 @@ class BaseLLMHTTPHandler: timeout=timeout, ) except Exception as e: - assert provider_config is not None - raise self._handle_error( - e=e, - provider_config=provider_config, - ) + if provider_config is not None: + raise self._handle_error( + e=e, + provider_config=provider_config, + ) + raise async def async_realtime_calls_handler( self, @@ -4956,11 +4957,12 @@ class BaseLLMHTTPHandler: timeout=timeout, ) except Exception as e: - assert provider_config is not None - raise self._handle_error( - e=e, - provider_config=provider_config, - ) + if provider_config is not None: + raise self._handle_error( + e=e, + provider_config=provider_config, + ) + raise async def async_responses_websocket( self, diff --git a/litellm/proxy/realtime_endpoints/endpoints.py b/litellm/proxy/realtime_endpoints/endpoints.py index 876ff330cc5..0a91112298a 100644 --- a/litellm/proxy/realtime_endpoints/endpoints.py +++ b/litellm/proxy/realtime_endpoints/endpoints.py @@ -181,9 +181,10 @@ async def create_realtime_client_secret( upstream_resp.status_code, upstream_resp.text, ) - raise HTTPException( + return Response( + content=upstream_resp.content, status_code=upstream_resp.status_code, - detail=upstream_resp.text, + media_type="application/json", ) upstream_json: dict = upstream_resp.json()