Repository navigation
fix(proxy): preserve team aliases in realtime websocket routing - #52124
mateo-berri merged 3 commits into
Conversation
PR overviewNo security issues were found in this pull request. Reviews
|
[Medium impact] The PR appears safe to merge, with no actionable issues found. SummaryRealtime WebSockets keep the model rewritten by shared preprocessing instead of restoring the original route model. The regression test covers two alias names across realtime, translations, and live sessions, checking that the restricted deployment’s credential reaches the upstream connection. No actionable issues were found. This review used source inspection, not runtime verification. Acknowledgments from
Reviews (1) · Last reviewed commit: "test(proxy): cover a team alias that dif..." · Reviewed by Greptile |
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 9f51ccf. Configure here.
Handwritten 1-3 sentence description
Realtime WebSocket calls now respect a team's model alias, so a team key mapped to a restricted deployment no longer runs on a shared deployment that serves the same provider model. This is the same fix as #51380, applied to /v1/realtime, /v1/realtime/translations and /v1/live/sessions
Details
TLDR
Problem this solves:
How it solves it:
User Flow
Before, a team key's realtime call runs on the shared deployment its team cannot use
Restrictedaccess group and the aliasgpt-realtime-2.1->restricted/gpt-realtime-2.1, then a key for itshared-deployment, with that deployment's key and billingAfter, the same call stays on the restricted deployment
Restrictedaccess group and the aliasgpt-realtime-2.1->restricted/gpt-realtime-2.1, then a key for itrestricted-deployment, model grouprestricted/gpt-realtime-2.1ws://litellm-domain/v1/realtime/translations and ws://litellm-domain/v1/live/sessions follow the same flow
Relevant issues
Related to #51379. #51380 fixed the Responses WebSocket route from LIT-10734, and this PR applies the same fix to the realtime, translations and live sessions WebSocket routes. Replaces #51595, which was opened under an account that cannot approve it
Linear ticket
Resolves LIT-10734
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or moreDelays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Last updated: 9f51ccf. QA ran on 4a75232. Changes since QA: tests only. Proof remains valid because the product diff is unchanged. Verification: the parametrized unit test, 6 passed at the tip and 6 failed at the merge base
Live run on 2026-11-14 against the real OpenAI realtime API with
gpt-realtime-2.1,gpt-realtime-translateandgpt-live-1. Each leg is a proxy with 2 workers and its own Postgres and Redis, booted from the merge baseac5fd9e0d0(Before) or this PR's tip4a752325fd(After). The client is the OpenAI Python SDK'sclient.realtime.connect,client.realtime.translations.connectandclient.live.connectshared/...namerestricted/...namewss://URL as the modelThe new unit test covers /v1/realtime, /v1/realtime/translations and /v1/live/sessions with an alias named like the provider model and one that differs (
voice). All 6 cases fail at the merge base and pass with the fixShared setup: config, proxy start command and client
qa_config.yamlEnvironment variables
DATABASE_URL,REDIS_HOST,REDIS_PORT,LITELLM_MASTER_KEYandOPENAI_API_KEYare set,OPENAI_API_KEYbeing a real OpenAI keyrealtime_turn.py, run withLITELLM_BASE_URLset tohttp://127.0.0.1:<port>/v1andTEAM_KEYset to the team keyBefore (ac5fd9e)
Team key, aliased name
After (4a75232)
Team key, aliased name
Other cases, Before and After
realtime_case.pytakes the model name as its argument andAPI_KEYas the keyBefore (ac5fd9e)
After (4a75232)
Translations and live sessions routes, Before and After
Each leg adds a shared (order 1) and a restricted (order 2,
Restrictedaccess group) deployment per model, then adds the two aliases to the team.realtime_routes.pyopens the route withTEAM_KEYand prints the first eventBefore (ac5fd9e)
After (4a75232)
Observations
wss://model gets the router's 400, not the URL guard/live-pr-risk at 4a75232, round 2 cells at 1bf0ecb
No breaking change. Per-model limits and budgets on team-aliased realtime calls now follow the serving model group, as they do on /chat/completions
Breaking
None found. Every realtime case in the tables above answers the same on both legs, except the deployment the team alias selects
Backward incompatible
A key's
model_rpm_limitentry now counts a team-aliased realtime call against the serving model group, not the alias name the client sent. Before, the alias was ignored, so the call ran on the group named after the alias and a limit on that name applied. /v1/chat/completions with the same team alias keys the limit by the serving group on both legs, which settles itA key's
model_max_budgetentry named after the alias stops counting realtime calls whose serving group has another name (team-realtimein the round 2 cells). Before, the budget refused the second session because the call ran on the shared deployment. /v1/chat/completions already lets all three calls through at the merge base. That gap is LIT-5091, which covers every alias mechanism, so this PR leaves it thereA key alias now wins over a global
model_alias_mapentry of the same name on realtime, and a chained key alias resolves instead of answering 400. Both match /v1/chat/completions at the merge base, per a round 3 probe through/v1/realtimewith the upstream connect mockedRegression risk
None found. Model-level guardrails were the one traced dependent, and realtime pre-call skips their merge on both legs because the handler passes no router to it
Dependency graph
wss://URL as modelhttps://URL as modelmodel_max_budgetNot verified
The tree merged with current main was not run live. Main has 4 commits on the touched files since the base as of d76cdcb, none of them change the alias, model resolution or realtime lines, the merge is clean, and CI's proxy-server-core job passed all 6 cases of the new unit test on the merge ref
Round 1 cells
Same rig as the QA legs, 2 workers each. Each leg also adds
shared/gpt-5.4-mini(order 1) andrestricted/gpt-5.4-mini(order 2,Restrictedaccess group), addsgpt-5.4-mini->restricted/gpt-5.4-minito the team's aliases, and mints team keys withmodel_rpm_limit1 keyed by the alias name or by the model groupBefore (ac5fd9e)
After (4a75232)
The spend log listing ran before the chat calls were re-run with the
*3keys, so its failedacompletionrows are the first attempts, made beforerestricted/gpt-5.4-miniexistedRound 2 cells
A fresh rig at 1bf0ecb, 2 workers each. Each leg adds
team-realtimeandteam-chatin theRestrictedaccess group, a team with the aliasesvoice->restricted/gpt-realtime-2.1,gpt-realtime-2.1->team-realtimeandgpt-5.4-mini->team-chat, and a key whosemodel_max_budgetis 0.000001 ongpt-realtime-2.1and ongpt-5.4-mini. The base budget 403s areexceeded budgetand thehttps://403s areteam not allowed to access model, both read from the proxy logBefore (ac5fd9e)
After (1bf0ecb)
Type
🐛 Bug Fix
✅ Test
Caveats (if any)
Medium
model_max_budgetentry named after a team alias stops counting realtime calls the alias sends to a differently named groupLow
model_alias_mapentry, and chained key aliases resolverouter_settings.model_group_aliasstill gets 403 at the realtime handshakeKeyError: 'result'that fix(auth): index restricted end-user registry refreshes #51772 and other PRs on current main also hitDecisions
Realtime per-model limits and budgets follow the serving model group, the way /v1/chat/completions does. Rejected fixing LIT-5091's alias-blind budget check here, since that changes budget enforcement on every route and needs its own QA
Realtime takes the model after key and team aliases are applied, so its alias precedence matches /v1/chat/completions. Rejected keeping the global alias map ahead of key aliases on realtime only, since that needs a realtime-only resolver and keeps the two routes apart
Final Attestation
Bugbot summary