fix(user_api_key_auth.py): add auth check for websocket endpoint

Fixes https://github.com/BerriAI/litellm/issues/6926
This commit is contained in:
Krrish Dholakia 2024-11-27 17:45:59 +05:30
parent 037171b98b
commit 9ec6ebaeeb
3 changed files with 58 additions and 3 deletions

View file

@ -134,7 +134,10 @@ from litellm.proxy.auth.model_checks import (
get_key_models,
get_team_models,
)
from litellm.proxy.auth.user_api_key_auth import user_api_key_auth
from litellm.proxy.auth.user_api_key_auth import (
user_api_key_auth,
user_api_key_auth_websocket,
)
## Import All Misc routes here ##
from litellm.proxy.caching_routes import router as caching_router
@ -4394,7 +4397,11 @@ from litellm import _arealtime
@app.websocket("/v1/realtime")
async def websocket_endpoint(websocket: WebSocket, model: str):
async def websocket_endpoint(
websocket: WebSocket,
model: str,
user_api_key_dict=Depends(user_api_key_auth_websocket),
):
import websockets
await websocket.accept()