Repository navigation
fix(realtime): dial Azure's GA realtime upstream for GA clients - #40769
Conversation
Azure realtime defaulted to the beta upstream whenever realtime_protocol was not configured, so a GA client's session.update (session.type, output_modalities, nested audio) was forwarded unchanged to /openai/realtime and Azure rejected it with "Unknown parameter: 'session.type'" on gpt-realtime and gpt-realtime-1.5. The unset default now follows the client the way the OpenAI handler already does: a client that sends OpenAI-Beta: realtime=v1 keeps the beta upstream, any other client gets /openai/v1/realtime. An explicit realtime_protocol in litellm_params or LITELLM_AZURE_REALTIME_PROTOCOL still wins.
… module's websocket protocol
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Greptile SummaryThis PR updates Azure realtime routing so unconfigured connections follow the client protocol while preserving explicit configuration precedence.
Confidence Score: 5/5The PR appears safe to merge, with no outstanding correctness or repository-rule findings. The client-aware routing preserves explicit protocol overrides and beta-header compatibility while sending headerless clients and unconfigured health checks to Azure’s GA upstream. The previous health-check mismatch thread was manually resolved without explanation, and the current code also addresses its reported behavior.
|
| Filename | Overview |
|---|---|
| litellm/litellm_core_utils/realtime_streaming.py | Exposes the scoped WebSocket protocol and existing beta-header detector for reuse by Azure routing. |
| litellm/llms/azure/realtime/handler.py | Centralizes Azure realtime protocol selection based on explicit configuration, transcription intent, and the client compatibility header. |
| litellm/realtime_api/main.py | Uses client-aware protocol selection for live connections and defaults unconfigured health checks to the matching GA upstream. |
| tests/test_litellm/realtime_api/test_main.py | Verifies GA and beta client routing, explicit and environment overrides, health-check behavior, and Azure Foundry host handling. |
Reviews (2): Last reviewed commit: "fix(realtime): probe Azure's GA realtime..." | Re-trigger Greptile
…en no protocol is pinned
|
bugbot run |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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 105dc77. Configure here.
TLDR
Problem this solves:
gpt-realtimegetUnknown parameter: 'session.type'realtime_protocolwas unsetsession.updatewas forwarded to that beta upstream unchanged/healthvouched for an upstream GA clients never reachHow it solves it:
realtime_protocolnow follows the client, like the OpenAI handlerOpenAI-Beta: realtime=v1on the client socket keeps the beta upstream/openai/v1/realtimeGA upstream/healthand the Admin UI Test Connect check what headerless clients getrealtime_protocolandLITELLM_AZURE_REALTIME_PROTOCOLstill win, for clients and for the probeUser Flow
Before: a voice-agent developer pointing the OpenAI SDK's GA realtime client at the proxy's Azure
gpt-realtimedeployment gets the firstsession.updaterejected, so the agent never gets its own instructionsgpt-realtimeasazure/gpt-realtimewith the Azure resource'sapi_baseandapi_key, and norealtime_protocolwss://litellm-domain/v1/realtime?model=gpt-realtimewithclient.realtime.connect(model="gpt-realtime")from the OpenAI SDK, which sends noOpenAI-Betaheadersession.createdevent comes back, so the app shows "Speak now"session.updatewith{"session": {"type": "realtime", "output_modalities": ["audio"], "instructions": "...", "audio": {...}}}{"type": "error", "error": {"message": "Unknown parameter: 'session.type'.", "code": "unknown_parameter", "param": "session.type"}}, andgpt-realtime-1.5fails the same wayGET /healthlists the deployment as healthy anyway, because the probe dialed the beta upstream the app never touchedAfter: the same GA client gets
session.updatedback, so the voice agent runs with its own instructionsgpt-realtimeasazure/gpt-realtimewith the Azure resource'sapi_baseandapi_key, and norealtime_protocolwss://litellm-domain/v1/realtime?model=gpt-realtimewithclient.realtime.connect(model="gpt-realtime")from the OpenAI SDK, which sends noOpenAI-Betaheadersession.createdevent comes back, so the app shows "Speak now"session.updatewith{"session": {"type": "realtime", "output_modalities": ["audio"], "instructions": "...", "audio": {...}}}session.updatedcarrying"type": "realtime","output_modalities": ["audio"], and the app's instructions, andgpt-realtime-1.5behaves the sameclient.beta.realtime.connect(which sendsOpenAI-Beta: realtime=v1) keeps getting beta-shapedsession.updatedevents exactly as beforeGET /healthand the Admin UI's Test Connect on that deployment probe the same GA upstream the app reaches, and a deployment pinned withrealtime_protocol: betakeeps probing betaRelevant issues
Relates to #24212 (the same error, fixed for OpenAI by #27110; this covers the Azure path)
Reopened from #40615 with the same commits so the approval can come from someone other than the author
Linear ticket
Resolves LIT-7451
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<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@greptileaito re-request a review after pushing changes)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
Shared setup: one proxy per leg booted from the named commit with
python litellm/proxy/proxy_cli.py --config config.yaml --port <port> --num_workers 2(two uvicorn workers on both legs, one proxy at a time on a random free port). Real Azure OpenAI resource in eastus2 withgpt-realtimeandgpt-realtime-1.5deployed (resource name redacted below), openai SDK 2.33.0. The twoprobe-url-echo-*entries point at a plainhttp://base on purpose: the health probe rejects that scheme and names the exact URL it tried to dial in the/healtherror, which is how the A/B shows which upstream the probe picks. The longsession.createdlines are cut shortga_client.py, the customer's kind of client (GA realtime client, noOpenAI-Betaheader), sends the GA-shapedsession.updateand prints each event's type plus a few session fields:beta_client.pyis the same script withclient.beta.realtime.connect(model=model)(sendsOpenAI-Beta: realtime=v1) andsession={"modalities": ["text"], "instructions": "You are a voice agent. Keep answers short."}Before (692a311)
GA client, gpt-realtime
python ga_client.py http://127.0.0.1:55673 gpt-realtime sk-1234Beta-header client, gpt-realtime
python beta_client.py http://127.0.0.1:55673 gpt-realtime sk-1234GA client, gpt-realtime-1.5
python ga_client.py http://127.0.0.1:55673 gpt-realtime-1.5 sk-1234Beta-header client, gpt-realtime-1.5
python beta_client.py http://127.0.0.1:55673 gpt-realtime-1.5 sk-1234Health probe (
GET /health, every deployment inmode: realtime)curl -s http://127.0.0.1:55673/health -H 'Authorization: Bearer sk-1234' | jq '{healthy_endpoints: [.healthy_endpoints[]? | {model, api_base}], unhealthy_endpoints: [.unhealthy_endpoints[]? | {model, api_base, error: (.error // "" | split("\n")[0])}]}'After (105dc77)
GA client, gpt-realtime
python ga_client.py http://127.0.0.1:52670 gpt-realtime sk-1234Beta-header client, gpt-realtime
python beta_client.py http://127.0.0.1:52670 gpt-realtime sk-1234GA client, gpt-realtime-1.5
python ga_client.py http://127.0.0.1:52670 gpt-realtime-1.5 sk-1234Beta-header client, gpt-realtime-1.5
python beta_client.py http://127.0.0.1:52670 gpt-realtime-1.5 sk-1234Health probe (
GET /health, every deployment inmode: realtime)curl -s http://127.0.0.1:52670/health -H 'Authorization: Bearer sk-1234' | jq '{healthy_endpoints: [.healthy_endpoints[]? | {model, api_base}], unhealthy_endpoints: [.unhealthy_endpoints[]? | {model, api_base, error: (.error // "" | split("\n")[0])}]}'realtime_protocol: betaone keeps the beta upstream, and the real deployments stay healthy):QA observations:
deployment=gpt-realtime, so beta clients worked before and after/health/test_connectioninrealtimemode picks the same upstream as/healthgpt-4o-realtime-previewdeployments are deprecated on Azure, not exercised liveType
🐛 Bug Fix
Caveats (if any)
Medium
session.updatewithout theOpenAI-Betaheader now get the GA upstreamrealtime_protocol: betainlitellm_paramsorLITELLM_AZURE_REALTIME_PROTOCOL=betaLow
realtime_protocolandLITELLM_AZURE_REALTIME_PROTOCOLare in litellm-docs [Feature]: Support tpm/rpm rate limiting for users #1406, which also notes the health probe follows the same GA defaultFinal Attestation