diff --git a/litellm/__init__.py b/litellm/__init__.py index 64c60ca3374..cb127bf20ef 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -424,6 +424,11 @@ disable_aiohttp_trust_env: bool = ( ) force_ipv4: bool = False # when True, litellm will force ipv4 for all LLM requests. Some users have seen httpx ConnectionError when using ipv6. network_mock: bool = False # When True, use mock transport — no real network calls +# When True, proxy Responses API WebSocket sessions directly to +# wss://api.openai.com/v1/responses instead of the managed HTTP-streaming path. +# Only enable this if your OpenAI deployment / reverse proxy reliably responds to +# response.create events over the native WebSocket protocol. +openai_responses_native_websocket: bool = False ####### STOP SEQUENCE LIMIT ####### disable_stop_sequence_limit: bool = False # when True, stop sequence limit is disabled diff --git a/litellm/llms/openai/responses/transformation.py b/litellm/llms/openai/responses/transformation.py index 3631244495e..6bad46d3f5e 100644 --- a/litellm/llms/openai/responses/transformation.py +++ b/litellm/llms/openai/responses/transformation.py @@ -348,15 +348,21 @@ class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig): return False def supports_native_websocket(self) -> bool: - """Use managed HTTP-streaming path for Responses API WebSocket mode. + """Use managed HTTP-streaming path for Responses API WebSocket mode by default. OpenAI's wss://api.openai.com/v1/responses endpoint exists but does not reliably stream events back in response to response.create messages in all deployment contexts. The ManagedResponsesWebSocketHandler makes a normal HTTP streaming call to /v1/responses and forwards the events over the WebSocket, which is proven to work. + + Set ``litellm.openai_responses_native_websocket = True`` to opt back in + to the native WebSocket path (e.g. when using a private deployment or + reverse proxy that reliably honours the native wss:// protocol). """ - return False + import litellm + + return bool(getattr(litellm, "openai_responses_native_websocket", False)) ######################################################### ########## DELETE RESPONSE API TRANSFORMATION ##############