From a6ab172db0e3fe5867a9a4f6e67c2effbb1c6065 Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Fri, 13 Mar 2026 11:42:18 -0700 Subject: [PATCH] [Fix] Use type:ignore instead of Union return type for realtime endpoint The Union[RealtimeClientSecretResponse, Response] annotation breaks FastAPI's response model generation. Revert to the original annotation and suppress mypy on the error-path return instead. Co-Authored-By: Claude Opus 4.6 --- litellm/proxy/realtime_endpoints/endpoints.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/litellm/proxy/realtime_endpoints/endpoints.py b/litellm/proxy/realtime_endpoints/endpoints.py index 4c0a407c0e7..14d004d977e 100644 --- a/litellm/proxy/realtime_endpoints/endpoints.py +++ b/litellm/proxy/realtime_endpoints/endpoints.py @@ -2,7 +2,7 @@ import json import time -from typing import Any, Dict, Optional, Union +from typing import Any, Dict, Optional import httpx from fastapi import APIRouter, Depends, HTTPException, Request, Response @@ -89,7 +89,7 @@ async def create_realtime_client_secret( request: Request, fastapi_response: Response, user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth), -) -> Union[RealtimeClientSecretResponse, Response]: +) -> RealtimeClientSecretResponse: from litellm.proxy.proxy_server import ( add_litellm_data_to_request, general_settings, @@ -181,7 +181,7 @@ async def create_realtime_client_secret( upstream_resp.status_code, upstream_resp.text, ) - return Response( + return Response( # type: ignore[return-value] content=upstream_resp.content, status_code=upstream_resp.status_code, media_type="application/json",