From a5af86d57833d253e8697c9736847acf2f9ef71d Mon Sep 17 00:00:00 2001 From: Mark Ferraz <93298946+mferraznw@users.noreply.github.com> Date: Wed, 1 Apr 2026 22:25:16 -0500 Subject: [PATCH] Fix Codex CLI responses websocket warmup and routing --- litellm/proxy/response_api_endpoints/endpoints.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/litellm/proxy/response_api_endpoints/endpoints.py b/litellm/proxy/response_api_endpoints/endpoints.py index 8023853e263..5edeecf5df9 100644 --- a/litellm/proxy/response_api_endpoints/endpoints.py +++ b/litellm/proxy/response_api_endpoints/endpoints.py @@ -939,8 +939,8 @@ async def cancel_response( @router.websocket("/responses") async def responses_websocket_endpoint( websocket: WebSocket, - model: str = fastapi.Query( - ..., description="The model to use for the responses WebSocket session." + model: Optional[str] = fastapi.Query( + None, description="The model to use for the responses WebSocket session." ), user_api_key_dict=Depends(user_api_key_auth_websocket), ): @@ -981,6 +981,8 @@ async def responses_websocket_endpoint( "model": model, "websocket": websocket, } + if not model: + data["llm_router"] = llm_router # Construct a synthetic Request for pre-call processing headers_list = list(websocket.scope.get("headers") or []) @@ -994,7 +996,9 @@ async def responses_websocket_endpoint( request._url = websocket.url async def return_body(): - return f'{{"model": "{model}"}}'.encode() + if model: + return f'{{"model": "{model}"}}'.encode() + return b"{}" request.body = return_body # type: ignore