Skip to content

fix(proxy): preserve team aliases in realtime websocket routing - #51595

Closed
mateo-berri wants to merge 3 commits into
mainfrom
litellm_preserve_realtime_ws_team_alias
Closed

mateo-berri wants to merge 3 commits into
mainfrom
litellm_preserve_realtime_ws_team_alias

Conversation

@mateo-berri

@mateo-berri mateo-berri commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

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

Link to Devin session: https://app.devin.ai/sessions/1310e840a55345d18387b2e9a4d68e6c
Open in Devin Desktop: https://app.devin.ai/desktop/session/1310e840a55345d18387b2e9a4d68e6c?variant=devin
Requested by: @mateo-berri

TLDR

Problem this solves:

  • Realtime WebSockets discard a team's model alias
  • Duplicate provider models then select another deployment

How it solves it:

  • Keep the model already rewritten by common request preprocessing

User Flow

Before, a team key's realtime call runs on the shared deployment its team cannot use

  1. The admin creates a team with only the Restricted access group and the alias gpt-realtime-2.1 -> restricted/gpt-realtime-2.1, then a key for it
  2. The developer opens ws://litellm-domain/v1/realtime?model=gpt-realtime-2.1 with the team key and gets a reply
  3. GET https://litellm-domain/spend/logs/v2 shows the call on shared-deployment, with that deployment's key and billing

After, the same call stays on the restricted deployment

  1. The admin creates a team with only the Restricted access group and the alias gpt-realtime-2.1 -> restricted/gpt-realtime-2.1, then a key for it
  2. The developer opens ws://litellm-domain/v1/realtime?model=gpt-realtime-2.1 with the team key and gets a reply
  3. GET https://litellm-domain/spend/logs/v2 shows the call on restricted-deployment, model group restricted/gpt-realtime-2.1

ws://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

Linear ticket

Resolves LIT-10734

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. 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 more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

Delays 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-translate and gpt-live-1. Each leg is a proxy with 2 workers and its own Postgres and Redis, booted from the merge base ac5fd9e0d0 (Before) or this PR's tip 4a752325fd (After). The client is the OpenAI Python SDK's client.realtime.connect, client.realtime.translations.connect and client.live.connect

Case Before (ac5fd9e) After (4a75232)
Team key, aliased name shared-deployment restricted-deployment
Team key, shared/... name 403 403
Admin key, provider name shared-deployment shared-deployment
Admin key, restricted/... name restricted-deployment restricted-deployment
wss:// URL as the model 400 error event 400 error event
Key alias, no team restricted-deployment restricted-deployment
Team key, translations route shared-gpt-realtime-translate restricted-gpt-realtime-translate
Team key, live sessions route shared-gpt-live-1 restricted-gpt-live-1

The 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 fix

Shared setup: config, proxy start command and client

qa_config.yaml

model_list:
  - model_name: shared/gpt-realtime-2.1
    litellm_params:
      model: gpt-realtime-2.1
      custom_llm_provider: openai
      api_key: os.environ/OPENAI_API_KEY
      order: 1
    model_info:
      id: shared-deployment
  - model_name: restricted/gpt-realtime-2.1
    litellm_params:
      model: gpt-realtime-2.1
      custom_llm_provider: openai
      api_key: os.environ/OPENAI_API_KEY
      order: 2
    model_info:
      id: restricted-deployment
      access_groups:
        - Restricted

general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY

Environment variables DATABASE_URL, REDIS_HOST, REDIS_PORT, LITELLM_MASTER_KEY and OPENAI_API_KEY are set, OPENAI_API_KEY being a real OpenAI key

python litellm/proxy/proxy_cli.py --config qa_config.yaml --host 127.0.0.1 --port <port> --num_workers 2 --timeout_worker_healthcheck 60 --telemetry False --use_prisma_db_push

realtime_turn.py, run with LITELLM_BASE_URL set to http://127.0.0.1:<port>/v1 and TEAM_KEY set to the team key

import os

from openai import OpenAI

client = OpenAI(base_url=os.environ["LITELLM_BASE_URL"], api_key=os.environ["TEAM_KEY"])
with client.realtime.connect(model="gpt-realtime-2.1") as connection:
    connection.session.update(session={"type": "realtime", "output_modalities": ["text"]})
    connection.conversation.item.create(
        item={"type": "message", "role": "user", "content": [{"type": "input_text", "text": "Reply with OK."}]}
    )
    connection.response.create()
    for event in connection:
        if event.type == "response.output_text.delta":
            print(event.delta, end="")
        elif event.type in ("response.done", "error"):
            print(f"\n{event.type}: {event.response.status if event.type == 'response.done' else event.error.message}")
            break

Before (ac5fd9e)

Team key, aliased name

$ curl -s -X POST "$BASE/team/new" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d '{"team_alias":"realtime-alias-team","models":["Restricted"],"model_aliases":{"gpt-realtime-2.1":"restricted/gpt-realtime-2.1"}}' > "$OUT/team.json"; jq "{team_id, models}" "$OUT/team.json"
{
  "team_id": "2129560a-85aa-430a-933b-d9c11610299a",
  "models": [
    "Restricted"
  ]
}
$ curl -s -X POST "$BASE/key/generate" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d "{\"team_id\":\"$(jq -r .team_id "$OUT/team.json")\",\"key_alias\":\"realtime-alias-key\"}" > "$OUT/key.json"; jq "{key_alias, team_id, models}" "$OUT/key.json"
{
  "key_alias": "realtime-alias-key",
  "team_id": "2129560a-85aa-430a-933b-d9c11610299a",
  "models": []
}

$ LITELLM_BASE_URL="$BASE/v1" "$PY" "$CLIENT"
OK
response.done: completed
$ curl -s "$BASE/spend/logs/v2?start_date=$(date -u +%Y-%m-%d)&end_date=$(date -u -d tomorrow +%Y-%m-%d)&page_size=5" -H "Authorization: Bearer $MK" | jq "[.data[] | {call_type, model, model_group, model_id, status, key_alias: .metadata.user_api_key_alias}]"
[
  {
    "call_type": "_arealtime",
    "model": "gpt-realtime-2.1",
    "model_group": "gpt-realtime-2.1",
    "model_id": "shared-deployment",
    "status": "success",
    "key_alias": "realtime-alias-key"
  }
]

After (4a75232)

Team key, aliased name

$ curl -s -X POST "$BASE/team/new" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d '{"team_alias":"realtime-alias-team","models":["Restricted"],"model_aliases":{"gpt-realtime-2.1":"restricted/gpt-realtime-2.1"}}' > "$OUT/team.json"; jq "{team_id, models}" "$OUT/team.json"
{
  "team_id": "85c96db3-d986-4fc8-a64a-7972db89cf13",
  "models": [
    "Restricted"
  ]
}
$ curl -s -X POST "$BASE/key/generate" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d "{\"team_id\":\"$(jq -r .team_id "$OUT/team.json")\",\"key_alias\":\"realtime-alias-key\"}" > "$OUT/key.json"; jq "{key_alias, team_id, models}" "$OUT/key.json"
{
  "key_alias": "realtime-alias-key",
  "team_id": "85c96db3-d986-4fc8-a64a-7972db89cf13",
  "models": []
}

$ LITELLM_BASE_URL="$BASE/v1" "$PY" "$CLIENT"
OK
response.done: completed
$ curl -s "$BASE/spend/logs/v2?start_date=$(date -u +%Y-%m-%d)&end_date=$(date -u -d tomorrow +%Y-%m-%d)&page_size=5" -H "Authorization: Bearer $MK" | jq "[.data[] | {call_type, model, model_group, model_id, status, key_alias: .metadata.user_api_key_alias}]"
[
  {
    "call_type": "_arealtime",
    "model": "gpt-realtime-2.1",
    "model_group": "restricted/gpt-realtime-2.1",
    "model_id": "restricted-deployment",
    "status": "success",
    "key_alias": "realtime-alias-key"
  }
]
Other cases, Before and After

realtime_case.py takes the model name as its argument and API_KEY as the key

import os
import sys

from openai import OpenAI

client = OpenAI(base_url=os.environ["LITELLM_BASE_URL"], api_key=os.environ["API_KEY"])
try:
    with client.realtime.connect(model=sys.argv[1]) as connection:
        connection.session.update(session={"type": "realtime", "output_modalities": ["text"]})
        connection.conversation.item.create(
            item={"type": "message", "role": "user", "content": [{"type": "input_text", "text": "Reply with OK."}]}
        )
        connection.response.create()
        for event in connection:
            if event.type == "response.output_text.delta":
                print(event.delta, end="")
            elif event.type in ("response.done", "error"):
                print(f"\n{event.type}: {event.response.status if event.type == 'response.done' else event.error.message}")
                break
except Exception as error:
    print(f"{type(error).__name__}: {str(error)[:300]}")

Before (ac5fd9e)

### case 2: team key asks for the shared deployment's model group directly
$ LITELLM_BASE_URL="$BASE/v1" API_KEY="$TEAM_KEY" "$PY" "$CASE" shared/gpt-realtime-2.1
InvalidStatus: server rejected WebSocket connection: HTTP 403
### case 3: admin key, no alias, asks for gpt-realtime-2.1 and for restricted/gpt-realtime-2.1
$ LITELLM_BASE_URL="$BASE/v1" API_KEY="$MK" "$PY" "$CASE" gpt-realtime-2.1
OK
response.done: completed
$ LITELLM_BASE_URL="$BASE/v1" API_KEY="$MK" "$PY" "$CASE" restricted/gpt-realtime-2.1
OK
response.done: completed
### case 4: a URL as the model is still refused
$ LITELLM_BASE_URL="$BASE/v1" API_KEY="$MK" "$PY" "$CASE" "wss://example.com/v1/realtime"

error: 400: {'error': '_arealtime: Invalid model name passed in model=wss://example.com/v1/realtime. Call `/v1/models` to view available models for your key.'}
### case 5: key-level alias with no team
$ curl -s -X POST "$BASE/key/generate" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d '{"key_alias":"realtime-key-alias","models":["restricted/gpt-realtime-2.1"],"aliases":{"gpt-realtime-2.1":"restricted/gpt-realtime-2.1"}}' > "$OUT/key2.json"; jq "{key_alias, models, aliases}" "$OUT/key2.json"
{
  "key_alias": "realtime-key-alias",
  "models": [
    "restricted/gpt-realtime-2.1"
  ],
  "aliases": {
    "gpt-realtime-2.1": "restricted/gpt-realtime-2.1"
  }
}
$ LITELLM_BASE_URL="$BASE/v1" API_KEY="$KEY2" "$PY" "$CASE" gpt-realtime-2.1
OK
response.done: completed
$ curl -s "$BASE/spend/logs/v2?start_date=$(date -u +%Y-%m-%d)&end_date=$(date -u -d tomorrow +%Y-%m-%d)&page_size=10" -H "Authorization: Bearer $MK" | jq "[.data[] | {model_group, model_id, status, key_alias: .metadata.user_api_key_alias}]"
[
  {
    "model_group": "restricted/gpt-realtime-2.1",
    "model_id": "restricted-deployment",
    "status": "success",
    "key_alias": "realtime-key-alias"
  },
  {
    "model_group": "restricted/gpt-realtime-2.1",
    "model_id": "restricted-deployment",
    "status": "success",
    "key_alias": null
  },
  {
    "model_group": "gpt-realtime-2.1",
    "model_id": "shared-deployment",
    "status": "success",
    "key_alias": null
  },
  {
    "model_group": "shared/gpt-realtime-2.1",
    "model_id": "shared-deployment",
    "status": "failure",
    "key_alias": "realtime-alias-key"
  },
  {
    "model_group": "gpt-realtime-2.1",
    "model_id": "shared-deployment",
    "status": "success",
    "key_alias": "realtime-alias-key"
  }
]

After (4a75232)

### case 2: team key asks for the shared deployment's model group directly
$ LITELLM_BASE_URL="$BASE/v1" API_KEY="$TEAM_KEY" "$PY" "$CASE" shared/gpt-realtime-2.1
InvalidStatus: server rejected WebSocket connection: HTTP 403
### case 3: admin key, no alias, asks for gpt-realtime-2.1 and for restricted/gpt-realtime-2.1
$ LITELLM_BASE_URL="$BASE/v1" API_KEY="$MK" "$PY" "$CASE" gpt-realtime-2.1
OK
response.done: completed
$ LITELLM_BASE_URL="$BASE/v1" API_KEY="$MK" "$PY" "$CASE" restricted/gpt-realtime-2.1
OK
response.done: completed
### case 4: a URL as the model is still refused
$ LITELLM_BASE_URL="$BASE/v1" API_KEY="$MK" "$PY" "$CASE" "wss://example.com/v1/realtime"

error: 400: {'error': '_arealtime: Invalid model name passed in model=wss://example.com/v1/realtime. Call `/v1/models` to view available models for your key.'}
### case 5: key-level alias with no team
$ curl -s -X POST "$BASE/key/generate" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d '{"key_alias":"realtime-key-alias","models":["restricted/gpt-realtime-2.1"],"aliases":{"gpt-realtime-2.1":"restricted/gpt-realtime-2.1"}}' > "$OUT/key2.json"; jq "{key_alias, models, aliases}" "$OUT/key2.json"
{
  "key_alias": "realtime-key-alias",
  "models": [
    "restricted/gpt-realtime-2.1"
  ],
  "aliases": {
    "gpt-realtime-2.1": "restricted/gpt-realtime-2.1"
  }
}
$ LITELLM_BASE_URL="$BASE/v1" API_KEY="$KEY2" "$PY" "$CASE" gpt-realtime-2.1
OK
response.done: completed
$ curl -s "$BASE/spend/logs/v2?start_date=$(date -u +%Y-%m-%d)&end_date=$(date -u -d tomorrow +%Y-%m-%d)&page_size=10" -H "Authorization: Bearer $MK" | jq "[.data[] | {model_group, model_id, status, key_alias: .metadata.user_api_key_alias}]"
[
  {
    "model_group": "restricted/gpt-realtime-2.1",
    "model_id": "restricted-deployment",
    "status": "success",
    "key_alias": "realtime-key-alias"
  },
  {
    "model_group": "restricted/gpt-realtime-2.1",
    "model_id": "restricted-deployment",
    "status": "success",
    "key_alias": null
  },
  {
    "model_group": "gpt-realtime-2.1",
    "model_id": "shared-deployment",
    "status": "success",
    "key_alias": null
  },
  {
    "model_group": "shared/gpt-realtime-2.1",
    "model_id": "shared-deployment",
    "status": "failure",
    "key_alias": "realtime-alias-key"
  },
  {
    "model_group": "restricted/gpt-realtime-2.1",
    "model_id": "restricted-deployment",
    "status": "success",
    "key_alias": "realtime-alias-key"
  }
]
Translations and live sessions routes, Before and After

Each leg adds a shared (order 1) and a restricted (order 2, Restricted access group) deployment per model, then adds the two aliases to the team. realtime_routes.py opens the route with TEAM_KEY and prints the first event

import os
import sys

from openai import OpenAI

client = OpenAI(base_url=os.environ["LITELLM_BASE_URL"], api_key=os.environ["TEAM_KEY"])
route, model = sys.argv[1], sys.argv[2]
try:
    if route == "translations":
        with client.realtime.translations.connect(model=model) as connection:
            print("first event:", connection.recv().type)
    else:
        with client.live.connect() as connection:
            connection.session.start(session={"model": model})
            print("first event:", connection.recv().type)
except Exception as error:
    print(f"{type(error).__name__}: {str(error)[:300]}")

Before (ac5fd9e)

$ curl -s -X POST "$BASE/model/new" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d '{"model_name":"shared/gpt-realtime-translate","litellm_params":{"model":"gpt-realtime-translate","custom_llm_provider":"openai","api_key":"os.environ/OPENAI_API_KEY","order":1},"model_info":{"id":"shared-gpt-realtime-translate"}}' | jq '{model_name, id: .model_info.id}'
{
  "model_name": "shared/gpt-realtime-translate",
  "id": "shared-gpt-realtime-translate"
}
$ curl -s -X POST "$BASE/model/new" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d '{"model_name":"restricted/gpt-realtime-translate","litellm_params":{"model":"gpt-realtime-translate","custom_llm_provider":"openai","api_key":"os.environ/OPENAI_API_KEY","order":2},"model_info":{"id":"restricted-gpt-realtime-translate","access_groups":["Restricted"]}}' | jq '{model_name, id: .model_info.id}'
{
  "model_name": "restricted/gpt-realtime-translate",
  "id": "restricted-gpt-realtime-translate"
}
$ curl -s -X POST "$BASE/model/new" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d '{"model_name":"shared/gpt-live-1","litellm_params":{"model":"gpt-live-1","custom_llm_provider":"openai","api_key":"os.environ/OPENAI_API_KEY","order":1},"model_info":{"id":"shared-gpt-live-1"}}' | jq '{model_name, id: .model_info.id}'
{
  "model_name": "shared/gpt-live-1",
  "id": "shared-gpt-live-1"
}
$ curl -s -X POST "$BASE/model/new" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d '{"model_name":"restricted/gpt-live-1","litellm_params":{"model":"gpt-live-1","custom_llm_provider":"openai","api_key":"os.environ/OPENAI_API_KEY","order":2},"model_info":{"id":"restricted-gpt-live-1","access_groups":["Restricted"]}}' | jq '{model_name, id: .model_info.id}'
{
  "model_name": "restricted/gpt-live-1",
  "id": "restricted-gpt-live-1"
}
$ curl -s -X POST "$BASE/team/update" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d "{\"team_id\":\"$TEAM_ID\",\"model_aliases\":{\"gpt-realtime-2.1\":\"restricted/gpt-realtime-2.1\",\"gpt-realtime-translate\":\"restricted/gpt-realtime-translate\",\"gpt-live-1\":\"restricted/gpt-live-1\"}}" | jq "{team_id: .data.team_id, models: .data.models}"
{
  "team_id": "2129560a-85aa-430a-933b-d9c11610299a",
  "models": [
    "Restricted"
  ]
}
$ LITELLM_BASE_URL="$BASE/v1" "$PY" "$CLIENT" translations gpt-realtime-translate
first event: session.created
$ LITELLM_BASE_URL="$BASE/v1" "$PY" "$CLIENT" live gpt-live-1
first event: session.started
$ curl -s "$BASE/spend/logs/v2?start_date=$(date -u +%Y-%m-%d)&end_date=$(date -u -d tomorrow +%Y-%m-%d)&page_size=3" -H "Authorization: Bearer $MK" | jq "[.data[] | {call_type, model_group, model_id, status, key_alias: .metadata.user_api_key_alias}]"
[
  {
    "call_type": "_arealtime",
    "model_group": "gpt-live-1",
    "model_id": "shared-gpt-live-1",
    "status": "success",
    "key_alias": "realtime-alias-key"
  },
  {
    "call_type": "_arealtime",
    "model_group": "gpt-realtime-translate",
    "model_id": "shared-gpt-realtime-translate",
    "status": "success",
    "key_alias": "realtime-alias-key"
  },
  {
    "call_type": "_arealtime",
    "model_group": "restricted/gpt-realtime-2.1",
    "model_id": "restricted-deployment",
    "status": "success",
    "key_alias": "realtime-key-alias"
  }
]

After (4a75232)

$ curl -s -X POST "$BASE/model/new" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d '{"model_name":"shared/gpt-realtime-translate","litellm_params":{"model":"gpt-realtime-translate","custom_llm_provider":"openai","api_key":"os.environ/OPENAI_API_KEY","order":1},"model_info":{"id":"shared-gpt-realtime-translate"}}' | jq '{model_name, id: .model_info.id}'
{
  "model_name": "shared/gpt-realtime-translate",
  "id": "shared-gpt-realtime-translate"
}
$ curl -s -X POST "$BASE/model/new" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d '{"model_name":"restricted/gpt-realtime-translate","litellm_params":{"model":"gpt-realtime-translate","custom_llm_provider":"openai","api_key":"os.environ/OPENAI_API_KEY","order":2},"model_info":{"id":"restricted-gpt-realtime-translate","access_groups":["Restricted"]}}' | jq '{model_name, id: .model_info.id}'
{
  "model_name": "restricted/gpt-realtime-translate",
  "id": "restricted-gpt-realtime-translate"
}
$ curl -s -X POST "$BASE/model/new" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d '{"model_name":"shared/gpt-live-1","litellm_params":{"model":"gpt-live-1","custom_llm_provider":"openai","api_key":"os.environ/OPENAI_API_KEY","order":1},"model_info":{"id":"shared-gpt-live-1"}}' | jq '{model_name, id: .model_info.id}'
{
  "model_name": "shared/gpt-live-1",
  "id": "shared-gpt-live-1"
}
$ curl -s -X POST "$BASE/model/new" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d '{"model_name":"restricted/gpt-live-1","litellm_params":{"model":"gpt-live-1","custom_llm_provider":"openai","api_key":"os.environ/OPENAI_API_KEY","order":2},"model_info":{"id":"restricted-gpt-live-1","access_groups":["Restricted"]}}' | jq '{model_name, id: .model_info.id}'
{
  "model_name": "restricted/gpt-live-1",
  "id": "restricted-gpt-live-1"
}
$ curl -s -X POST "$BASE/team/update" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d "{\"team_id\":\"$TEAM_ID\",\"model_aliases\":{\"gpt-realtime-2.1\":\"restricted/gpt-realtime-2.1\",\"gpt-realtime-translate\":\"restricted/gpt-realtime-translate\",\"gpt-live-1\":\"restricted/gpt-live-1\"}}" | jq "{team_id: .data.team_id, models: .data.models}"
{
  "team_id": "85c96db3-d986-4fc8-a64a-7972db89cf13",
  "models": [
    "Restricted"
  ]
}
$ LITELLM_BASE_URL="$BASE/v1" "$PY" "$CLIENT" translations gpt-realtime-translate
first event: session.created
$ LITELLM_BASE_URL="$BASE/v1" "$PY" "$CLIENT" live gpt-live-1
first event: session.started
$ curl -s "$BASE/spend/logs/v2?start_date=$(date -u +%Y-%m-%d)&end_date=$(date -u -d tomorrow +%Y-%m-%d)&page_size=3" -H "Authorization: Bearer $MK" | jq "[.data[] | {call_type, model_group, model_id, status, key_alias: .metadata.user_api_key_alias}]"
[
  {
    "call_type": "_arealtime",
    "model_group": "restricted/gpt-live-1",
    "model_id": "restricted-gpt-live-1",
    "status": "success",
    "key_alias": "realtime-alias-key"
  },
  {
    "call_type": "_arealtime",
    "model_group": "restricted/gpt-realtime-translate",
    "model_id": "restricted-gpt-realtime-translate",
    "status": "success",
    "key_alias": "realtime-alias-key"
  },
  {
    "call_type": "_arealtime",
    "model_group": "restricted/gpt-realtime-2.1",
    "model_id": "restricted-deployment",
    "status": "success",
    "key_alias": "realtime-key-alias"
  }
]

Observations

  • 403'd direct call logs failure on shared-deployment, both legs, pre-existing
  • URL model gets a 400 error event after connect, unchanged
  • 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_limit entry 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 it

A key's model_max_budget entry named after the alias stops counting realtime calls whose serving group has another name (team-realtime in 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 there

A key alias now wins over a global model_alias_map entry 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/realtime with the upstream connect mocked

Regression 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

Dependent Status Evidence
/v1/realtime verified live QA table
/realtime, /openai/v1/realtime verified live round 1 cells
/v1/realtime/translations verified live QA table
/v1/live/sessions verified live QA table
Alias named differently verified live round 2 cells
wss:// URL as model verified live QA case 4
https:// URL as model verified live round 2 cells
Key alias, no team verified live QA case 5
Per-model RPM limit verified live round 1 cells
Key model_max_budget verified live round 2 cells
Spend log model group verified live both rounds
Model-level guardrails unreachable realtime pre-call passes no router
Realtime provider tests tested on head 163 passed, 2 skipped
WebSocket auth tests tested on head 127 passed

Not 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) and restricted/gpt-5.4-mini (order 2, Restricted access group), adds gpt-5.4-mini -> restricted/gpt-5.4-mini to the team's aliases, and mints team keys with model_rpm_limit 1 keyed by the alias name or by the model group

Before (ac5fd9e)

### realtime, rpm 1 keyed by the alias name, two sessions
$ K=$(jq -r .key "$OUT/key-alias.json"); for i in 1 2; do LITELLM_BASE_URL="$BASE/v1" API_KEY="$K" "$PY" "$CASE" gpt-realtime-2.1; done
OK
response.done: completed

error: 429: Rate limit exceeded for model_per_key: d9edf9df7e446eb794ad74aa9f3948ac80c3b26eb81f774d544c1c7885f009bd:gpt-realtime-2.1. Limit type: requests. Current limit: 1, Remaining: 0. Limit resets at: 2026-11-14 03:32:56 UTC
### realtime, rpm 1 keyed by the aliased model group, two sessions
$ K=$(jq -r .key "$OUT/key-group.json"); for i in 1 2; do LITELLM_BASE_URL="$BASE/v1" API_KEY="$K" "$PY" "$CASE" gpt-realtime-2.1; done
OK
response.done: completed
OK
response.done: completed
### chat completions, key rpm-chatalias3, two calls
$ K=$(jq -r .key "$OUT/key-chatalias3.json"); for i in 1 2; do curl -s -o "$OUT/chat.json" -w "%{http_code} " "$BASE/v1/chat/completions" -H "Authorization: Bearer $K" -H "Content-Type: application/json" -d "{\"model\":\"gpt-5.4-mini\",\"messages\":[{\"role\":\"user\",\"content\":\"Reply with OK.\"}],\"max_completion_tokens\":16}"; jq -c "{model, error: .error.message[0:140]}" "$OUT/chat.json"; done
200 {"model":"gpt-5.4-mini","error":null}
200 {"model":"gpt-5.4-mini","error":null}
### chat completions, key rpm-chatgroup3, two calls
$ K=$(jq -r .key "$OUT/key-chatgroup3.json"); for i in 1 2; do curl -s -o "$OUT/chat.json" -w "%{http_code} " "$BASE/v1/chat/completions" -H "Authorization: Bearer $K" -H "Content-Type: application/json" -d "{\"model\":\"gpt-5.4-mini\",\"messages\":[{\"role\":\"user\",\"content\":\"Reply with OK.\"}],\"max_completion_tokens\":16}"; jq -c "{model, error: .error.message[0:140]}" "$OUT/chat.json"; done
200 {"model":"gpt-5.4-mini","error":null}
429 {"model":null,"error":"Rate limit exceeded for model_per_key: 13233eb2b44bd8fa6165f969e9913930ca3d74b4266d210fcfbdcb035cc5f93b:restricted/gpt-5.4-mini. Limit type:"}
### team key on the /realtime and /openai/v1/realtime path aliases
$ LITELLM_BASE_URL="$BASE" API_KEY="$TEAM_KEY" "$PY" "$CASE" gpt-realtime-2.1
OK
response.done: completed
$ LITELLM_BASE_URL="$BASE/openai/v1" API_KEY="$TEAM_KEY" "$PY" "$CASE" gpt-realtime-2.1
OK
response.done: completed
$ curl -s "$BASE/spend/logs/v2?start_date=$(date -u +%Y-%m-%d)&end_date=$(date -u -d tomorrow +%Y-%m-%d)&page_size=12" -H "Authorization: Bearer $MK" | jq -c ".data[] | {call_type, model_group, model_id, status, key_alias: .metadata.user_api_key_alias}"
{"call_type":"_arealtime","model_group":"gpt-realtime-2.1","model_id":"shared-deployment","status":"success","key_alias":"realtime-alias-key"}
{"call_type":"_arealtime","model_group":"gpt-realtime-2.1","model_id":"shared-deployment","status":"success","key_alias":"realtime-alias-key"}
{"call_type":"acompletion","model_group":"","model_id":"","status":"failure","key_alias":"rpm-chatgroup"}
{"call_type":"acompletion","model_group":"","model_id":"","status":"failure","key_alias":"rpm-chatgroup"}
{"call_type":"acompletion","model_group":"","model_id":"","status":"failure","key_alias":"rpm-chatalias"}
{"call_type":"acompletion","model_group":"","model_id":"","status":"failure","key_alias":"rpm-chatalias"}
{"call_type":"_arealtime","model_group":"gpt-realtime-2.1","model_id":"shared-deployment","status":"success","key_alias":"rpm-group"}
{"call_type":"_arealtime","model_group":"gpt-realtime-2.1","model_id":"shared-deployment","status":"success","key_alias":"rpm-group"}
{"call_type":"_arealtime","model_group":"gpt-realtime-2.1","model_id":"shared-deployment","status":"success","key_alias":"rpm-alias"}
{"call_type":"_arealtime","model_group":"gpt-live-1","model_id":"shared-gpt-live-1","status":"success","key_alias":"realtime-alias-key"}
{"call_type":"_arealtime","model_group":"gpt-realtime-translate","model_id":"shared-gpt-realtime-translate","status":"success","key_alias":"realtime-alias-key"}
{"call_type":"_arealtime","model_group":"restricted/gpt-realtime-2.1","model_id":"restricted-deployment","status":"success","key_alias":"realtime-key-alias"}

After (4a75232)

### realtime, rpm 1 keyed by the alias name, two sessions
$ K=$(jq -r .key "$OUT/key-alias.json"); for i in 1 2; do LITELLM_BASE_URL="$BASE/v1" API_KEY="$K" "$PY" "$CASE" gpt-realtime-2.1; done
OK
response.done: completed
OK
response.done: completed
### realtime, rpm 1 keyed by the aliased model group, two sessions
$ K=$(jq -r .key "$OUT/key-group.json"); for i in 1 2; do LITELLM_BASE_URL="$BASE/v1" API_KEY="$K" "$PY" "$CASE" gpt-realtime-2.1; done
OK
response.done: completed

error: 429: Rate limit exceeded for model_per_key: c85246fbc2fd38fcf9d1d991fde2020a565abf46c339e19dba15ad17de4ed536:restricted/gpt-realtime-2.1. Limit type: requests. Current limit: 1, Remaining: 0. Limit resets at: 2026-11-14 03:33:00 UTC
### chat completions, key rpm-chatalias3, two calls
$ K=$(jq -r .key "$OUT/key-chatalias3.json"); for i in 1 2; do curl -s -o "$OUT/chat.json" -w "%{http_code} " "$BASE/v1/chat/completions" -H "Authorization: Bearer $K" -H "Content-Type: application/json" -d "{\"model\":\"gpt-5.4-mini\",\"messages\":[{\"role\":\"user\",\"content\":\"Reply with OK.\"}],\"max_completion_tokens\":16}"; jq -c "{model, error: .error.message[0:140]}" "$OUT/chat.json"; done
200 {"model":"gpt-5.4-mini","error":null}
200 {"model":"gpt-5.4-mini","error":null}
### chat completions, key rpm-chatgroup3, two calls
$ K=$(jq -r .key "$OUT/key-chatgroup3.json"); for i in 1 2; do curl -s -o "$OUT/chat.json" -w "%{http_code} " "$BASE/v1/chat/completions" -H "Authorization: Bearer $K" -H "Content-Type: application/json" -d "{\"model\":\"gpt-5.4-mini\",\"messages\":[{\"role\":\"user\",\"content\":\"Reply with OK.\"}],\"max_completion_tokens\":16}"; jq -c "{model, error: .error.message[0:140]}" "$OUT/chat.json"; done
200 {"model":"gpt-5.4-mini","error":null}
429 {"model":null,"error":"Rate limit exceeded for model_per_key: 26d28e11dd862a055d45133ac8b6378a76bf2328e86baefe34e4c51233947aa2:restricted/gpt-5.4-mini. Limit type:"}
### team key on the /realtime and /openai/v1/realtime path aliases
$ LITELLM_BASE_URL="$BASE" API_KEY="$TEAM_KEY" "$PY" "$CASE" gpt-realtime-2.1
OK
response.done: completed
$ LITELLM_BASE_URL="$BASE/openai/v1" API_KEY="$TEAM_KEY" "$PY" "$CASE" gpt-realtime-2.1
OK
response.done: completed
$ curl -s "$BASE/spend/logs/v2?start_date=$(date -u +%Y-%m-%d)&end_date=$(date -u -d tomorrow +%Y-%m-%d)&page_size=12" -H "Authorization: Bearer $MK" | jq -c ".data[] | {call_type, model_group, model_id, status, key_alias: .metadata.user_api_key_alias}"
{"call_type":"_arealtime","model_group":"restricted/gpt-realtime-2.1","model_id":"restricted-deployment","status":"success","key_alias":"realtime-alias-key"}
{"call_type":"_arealtime","model_group":"restricted/gpt-realtime-2.1","model_id":"restricted-deployment","status":"success","key_alias":"realtime-alias-key"}
{"call_type":"acompletion","model_group":"","model_id":"","status":"failure","key_alias":"rpm-chatgroup"}
{"call_type":"acompletion","model_group":"","model_id":"","status":"failure","key_alias":"rpm-chatgroup"}
{"call_type":"acompletion","model_group":"","model_id":"","status":"failure","key_alias":"rpm-chatalias"}
{"call_type":"acompletion","model_group":"","model_id":"","status":"failure","key_alias":"rpm-chatalias"}
{"call_type":"_arealtime","model_group":"restricted/gpt-realtime-2.1","model_id":"restricted-deployment","status":"success","key_alias":"rpm-group"}
{"call_type":"_arealtime","model_group":"restricted/gpt-realtime-2.1","model_id":"restricted-deployment","status":"success","key_alias":"rpm-alias"}
{"call_type":"_arealtime","model_group":"restricted/gpt-realtime-2.1","model_id":"restricted-deployment","status":"success","key_alias":"rpm-alias"}
{"call_type":"_arealtime","model_group":"restricted/gpt-live-1","model_id":"restricted-gpt-live-1","status":"success","key_alias":"realtime-alias-key"}
{"call_type":"_arealtime","model_group":"restricted/gpt-realtime-translate","model_id":"restricted-gpt-realtime-translate","status":"success","key_alias":"realtime-alias-key"}
{"call_type":"_arealtime","model_group":"restricted/gpt-realtime-2.1","model_id":"restricted-deployment","status":"success","key_alias":"realtime-key-alias"}

The spend log listing ran before the chat calls were re-run with the *3 keys, so its failed acompletion rows are the first attempts, made before restricted/gpt-5.4-mini existed

Round 2 cells

A fresh rig at 1bf0ecb, 2 workers each. Each leg adds team-realtime and team-chat in the Restricted access group, a team with the aliases voice -> restricted/gpt-realtime-2.1, gpt-realtime-2.1 -> team-realtime and gpt-5.4-mini -> team-chat, and a key whose model_max_budget is 0.000001 on gpt-realtime-2.1 and on gpt-5.4-mini. The base budget 403s are exceeded budget and the https:// 403s are team not allowed to access model, both read from the proxy log

Before (ac5fd9e)

$ curl -s -X POST "$BASE/model/new" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d '{"model_name":"team-realtime","litellm_params":{"model":"gpt-realtime-2.1","custom_llm_provider":"openai","api_key":"os.environ/OPENAI_API_KEY","order":2},"model_info":{"id":"team-realtime-deployment","access_groups":["Restricted"]}}' | jq -c "{model_name, id: .model_info.id}"
{"model_name":"team-realtime","id":"team-realtime-deployment"}
$ curl -s -X POST "$BASE/model/new" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d '{"model_name":"team-chat","litellm_params":{"model":"gpt-5.4-mini","custom_llm_provider":"openai","api_key":"os.environ/OPENAI_API_KEY"},"model_info":{"id":"team-chat-deployment","access_groups":["Restricted"]}}' | jq -c "{model_name, id: .model_info.id}"
{"model_name":"team-chat","id":"team-chat-deployment"}
$ curl -s -X POST "$BASE/team/new" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d '{"team_alias":"alias-team-2","models":["Restricted"],"model_aliases":{"voice":"restricted/gpt-realtime-2.1","gpt-realtime-2.1":"team-realtime","gpt-5.4-mini":"team-chat"}}' > "$OUT/team2.json"; jq -c "{team_id, models}" "$OUT/team2.json"
{"team_id":"d57ba195-f58e-410f-a3ad-24819f3a373b","models":["Restricted"]}
$ curl -s -X POST "$BASE/key/generate" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d "{\"team_id\":\"$TEAM2\",\"key_alias\":\"alias-key-2\"}" > "$OUT/key2.json"; jq -c "{key_alias, team_id}" "$OUT/key2.json"
{"key_alias":"alias-key-2","team_id":"d57ba195-f58e-410f-a3ad-24819f3a373b"}
$ curl -s -X POST "$BASE/key/generate" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d "{\"team_id\":\"$TEAM2\",\"key_alias\":\"budget-key\",\"model_max_budget\":{\"gpt-realtime-2.1\":{\"budget_limit\":0.000001,\"time_period\":\"1d\"},\"gpt-5.4-mini\":{\"budget_limit\":0.000001,\"time_period\":\"1d\"}}}" > "$OUT/key-budget.json"; jq -c "{key_alias, model_max_budget, error: .error.message}" "$OUT/key-budget.json"
{"key_alias":"budget-key","model_max_budget":{"gpt-realtime-2.1":{"budget_limit":0.000001,"time_period":"1d"},"gpt-5.4-mini":{"budget_limit":0.000001,"time_period":"1d"}},"error":null}
### team alias voice -> restricted/gpt-realtime-2.1
$ LITELLM_BASE_URL="$BASE/v1" API_KEY="$K2" "$PY" "$CASE" voice
ConnectionClosedError: received 1011 (internal error) 400: {'error': '_arealtime: Invalid model name passed in model=voice. Call `/v1/models` to view available models for your k; then sent 1011 (internal error) 400: {'error': '_arealtime: Invalid model name passed in model=voice. Call `/v1/models` to view available models
### https URL as the model
$ LITELLM_BASE_URL="$BASE/v1" API_KEY="$K2" "$PY" "$CASE" https://169.254.169.254/latest
InvalidStatus: server rejected WebSocket connection: HTTP 403
### realtime, model_max_budget keyed gpt-realtime-2.1, alias target team-realtime, three sessions
$ for i in 1 2 3; do LITELLM_BASE_URL="$BASE/v1" API_KEY="$KB" "$PY" "$CASE" gpt-realtime-2.1; sleep 10; done
OK
response.done: completed
InvalidStatus: server rejected WebSocket connection: HTTP 403
InvalidStatus: server rejected WebSocket connection: HTTP 403
### chat completions, model_max_budget keyed gpt-5.4-mini, alias target team-chat, three calls
$ for i in 1 2 3; do curl -s -o "$OUT/chat.json" -w "%{http_code} " "$BASE/v1/chat/completions" -H "Authorization: Bearer $KB" -H "Content-Type: application/json" -d "{\"model\":\"gpt-5.4-mini\",\"messages\":[{\"role\":\"user\",\"content\":\"Reply with OK.\"}],\"max_completion_tokens\":16}"; jq -c "{model, error: .error.message[0:160]}" "$OUT/chat.json"; sleep 10; done
200 {"model":"gpt-5.4-mini","error":null}
200 {"model":"gpt-5.4-mini","error":null}
200 {"model":"gpt-5.4-mini","error":null}
$ curl -s "$BASE/spend/logs/v2?start_date=$(date -u +%Y-%m-%d)&end_date=$(date -u -d tomorrow +%Y-%m-%d)&page_size=10" -H "Authorization: Bearer $MK" | jq -c ".data[] | {call_type, model_group, model_id, status, key_alias: .metadata.user_api_key_alias}"
{"call_type":"acompletion","model_group":"team-chat","model_id":"team-chat-deployment","status":"success","key_alias":"budget-key"}
{"call_type":"acompletion","model_group":"team-chat","model_id":"team-chat-deployment","status":"success","key_alias":"budget-key"}
{"call_type":"acompletion","model_group":"team-chat","model_id":"team-chat-deployment","status":"success","key_alias":"budget-key"}
{"call_type":"_arealtime","model_group":"","model_id":"","status":"failure","key_alias":"budget-key"}
{"call_type":"_arealtime","model_group":"","model_id":"","status":"failure","key_alias":"budget-key"}
{"call_type":"_arealtime","model_group":"gpt-realtime-2.1","model_id":"shared-deployment","status":"success","key_alias":"budget-key"}
{"call_type":"_arealtime","model_group":"","model_id":"","status":"failure","key_alias":"alias-key-2"}
{"call_type":"/v1/models","model_group":"","model_id":"","status":"failure","key_alias":null}

After (1bf0ecb)

$ curl -s -X POST "$BASE/model/new" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d '{"model_name":"team-realtime","litellm_params":{"model":"gpt-realtime-2.1","custom_llm_provider":"openai","api_key":"os.environ/OPENAI_API_KEY","order":2},"model_info":{"id":"team-realtime-deployment","access_groups":["Restricted"]}}' | jq -c "{model_name, id: .model_info.id}"
{"model_name":"team-realtime","id":"team-realtime-deployment"}
$ curl -s -X POST "$BASE/model/new" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d '{"model_name":"team-chat","litellm_params":{"model":"gpt-5.4-mini","custom_llm_provider":"openai","api_key":"os.environ/OPENAI_API_KEY"},"model_info":{"id":"team-chat-deployment","access_groups":["Restricted"]}}' | jq -c "{model_name, id: .model_info.id}"
{"model_name":"team-chat","id":"team-chat-deployment"}
$ curl -s -X POST "$BASE/team/new" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d '{"team_alias":"alias-team-2","models":["Restricted"],"model_aliases":{"voice":"restricted/gpt-realtime-2.1","gpt-realtime-2.1":"team-realtime","gpt-5.4-mini":"team-chat"}}' > "$OUT/team2.json"; jq -c "{team_id, models}" "$OUT/team2.json"
{"team_id":"0a2e9569-0d20-47b1-b5ea-db0b499643da","models":["Restricted"]}
$ curl -s -X POST "$BASE/key/generate" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d "{\"team_id\":\"$TEAM2\",\"key_alias\":\"alias-key-2\"}" > "$OUT/key2.json"; jq -c "{key_alias, team_id}" "$OUT/key2.json"
{"key_alias":"alias-key-2","team_id":"0a2e9569-0d20-47b1-b5ea-db0b499643da"}
$ curl -s -X POST "$BASE/key/generate" -H "Authorization: Bearer $MK" -H "Content-Type: application/json" -d "{\"team_id\":\"$TEAM2\",\"key_alias\":\"budget-key\",\"model_max_budget\":{\"gpt-realtime-2.1\":{\"budget_limit\":0.000001,\"time_period\":\"1d\"},\"gpt-5.4-mini\":{\"budget_limit\":0.000001,\"time_period\":\"1d\"}}}" > "$OUT/key-budget.json"; jq -c "{key_alias, model_max_budget, error: .error.message}" "$OUT/key-budget.json"
{"key_alias":"budget-key","model_max_budget":{"gpt-realtime-2.1":{"budget_limit":0.000001,"time_period":"1d"},"gpt-5.4-mini":{"budget_limit":0.000001,"time_period":"1d"}},"error":null}
### team alias voice -> restricted/gpt-realtime-2.1
$ LITELLM_BASE_URL="$BASE/v1" API_KEY="$K2" "$PY" "$CASE" voice
OK
response.done: completed
### https URL as the model
$ LITELLM_BASE_URL="$BASE/v1" API_KEY="$K2" "$PY" "$CASE" https://169.254.169.254/latest
InvalidStatus: server rejected WebSocket connection: HTTP 403
### realtime, model_max_budget keyed gpt-realtime-2.1, alias target team-realtime, three sessions
$ for i in 1 2 3; do LITELLM_BASE_URL="$BASE/v1" API_KEY="$KB" "$PY" "$CASE" gpt-realtime-2.1; sleep 10; done
OK
response.done: completed
OK
response.done: completed
OK
response.done: completed
### chat completions, model_max_budget keyed gpt-5.4-mini, alias target team-chat, three calls
$ for i in 1 2 3; do curl -s -o "$OUT/chat.json" -w "%{http_code} " "$BASE/v1/chat/completions" -H "Authorization: Bearer $KB" -H "Content-Type: application/json" -d "{\"model\":\"gpt-5.4-mini\",\"messages\":[{\"role\":\"user\",\"content\":\"Reply with OK.\"}],\"max_completion_tokens\":16}"; jq -c "{model, error: .error.message[0:160]}" "$OUT/chat.json"; sleep 10; done
200 {"model":"gpt-5.4-mini","error":null}
200 {"model":"gpt-5.4-mini","error":null}
200 {"model":"gpt-5.4-mini","error":null}
$ curl -s "$BASE/spend/logs/v2?start_date=$(date -u +%Y-%m-%d)&end_date=$(date -u -d tomorrow +%Y-%m-%d)&page_size=10" -H "Authorization: Bearer $MK" | jq -c ".data[] | {call_type, model_group, model_id, status, key_alias: .metadata.user_api_key_alias}"
{"call_type":"acompletion","model_group":"team-chat","model_id":"team-chat-deployment","status":"success","key_alias":"budget-key"}
{"call_type":"acompletion","model_group":"team-chat","model_id":"team-chat-deployment","status":"success","key_alias":"budget-key"}
{"call_type":"acompletion","model_group":"team-chat","model_id":"team-chat-deployment","status":"success","key_alias":"budget-key"}
{"call_type":"_arealtime","model_group":"team-realtime","model_id":"team-realtime-deployment","status":"success","key_alias":"budget-key"}
{"call_type":"_arealtime","model_group":"team-realtime","model_id":"team-realtime-deployment","status":"success","key_alias":"budget-key"}
{"call_type":"_arealtime","model_group":"team-realtime","model_id":"team-realtime-deployment","status":"success","key_alias":"budget-key"}
{"call_type":"_arealtime","model_group":"","model_id":"","status":"failure","key_alias":"alias-key-2"}
{"call_type":"_arealtime","model_group":"restricted/gpt-realtime-2.1","model_id":"restricted-deployment","status":"success","key_alias":"alias-key-2"}
{"call_type":"/v1/models","model_group":"","model_id":"","status":"failure","key_alias":null}

Type

🐛 Bug Fix
✅ Test

Caveats (if any)

Medium

  • A pre-existing gap went to security engineering
  • A key's model_max_budget entry named after a team alias stops counting realtime calls the alias sends to a differently named group
    • No other entry was found that caps them
    • /v1/chat/completions already works this way at the merge base, tracked in LIT-5091

Low

  • Per-model RPM and TPM limits on team-aliased realtime calls follow the serving model group
    • Same as /v1/chat/completions, and the base limit also followed the serving group
  • Key aliases on realtime now follow /v1/chat/completions
    • A key alias beats a same-named global model_alias_map entry, and chained key aliases resolve
  • A team's router_settings.model_group_alias still gets 403 at the realtime handshake
    • /v1/chat/completions routes it, and the handshake check is outside this diff
  • Image Scan verify (backend) and (migrations) fail with the admin MCP KeyError: 'result' that fix(auth): index restricted end-user registry refreshes #51772 and other PRs on current main also hit
Decisions

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

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR
Bugbot summary

[!NOTE]
Medium Risk
Changes which deployment serves team-aliased realtime WebSockets, affecting access control, billing, and per-model limits; behavior now aligns with chat completions rather than silently routing to a different deployment.

Overview
Realtime WebSocket pre-call no longer passes model=route_model into common_processing_pre_call_logic, so resolve_inference_model keeps the model already rewritten by shared preprocessing (including team model aliases) instead of forcing the route-resolved client/provider name. Team keys on /v1/realtime, /v1/realtime/translations, and /v1/live/sessions therefore route to the aliased deployment (e.g. restricted) rather than another deployment that shares the same upstream model.

A parametrized unit test covers those three routes with alias names gpt-realtime and voice, asserting the upstream connection uses the restricted deployment’s API key.

Reviewed by Cursor Bugbot for commit 9f51ccf. Bugbot is set up for automated code reviews on this repo. Configure here.

@veria-ai

veria-ai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

No security issues were found in this pull request.

Reviews

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@greptile-apps

greptile-apps Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with no new actionable issue found.

Summary

Realtime WebSocket routing keeps the model chosen by team alias rewriting.

  • Realtime WebSocket sessions follow the team's model alias.

Reviews (4) · Last reviewed commit: "test(proxy): cover a team alias that dif..." · Reviewed by Greptile

Comment thread litellm/proxy/proxy_server.py Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@codspeed

codspeed Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 2 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 44 untouched benchmarks


Comparing litellm_preserve_realtime_ws_team_alias (9f51ccf) with main (d76cdcb)

Open in CodSpeed

@mateo-berri
mateo-berri enabled auto-merge (squash) November 13, 2026 08:56
@codecov

codecov Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.

@mateo-berri

Copy link
Copy Markdown
Contributor Author

Superseded by #52124, the same commit opened from an account whose PRs Mateo can approve. Closing this one

auto-merge was automatically disabled November 16, 2026 21:37

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant