Add Azure AI Voice Live via the `azure_voice_live` setting
Add Azure AI Voice Live
Adds Azure AI Voice Live as a purely additive opt-in on the existing AzureRealtimeModel (shipped in #6324), so there's no breaking change. #6324 ships Azure OpenAI GA realtime; this adds Voice Live alongside it.
Voice Live is a distinct Azure resource and API (/voice-live/realtime), a strict superset of GA session options but not of the model catalog — the two overlap without either containing the other. It's exposed as one setting on the unified AzureRealtimeModel, not a separate class:
AzureRealtimeModelSettings(extendsOpenAIRealtimeModelSettings) withazure_voice_live: bool— when set, the model targets the Voice Live endpoint and forwards the Voice-Live-only session config.- Voice-Live-only knobs are
azure_voice_live_*-prefixed (so farazure_voice_live_turn_detection). api-keyauth, api-version2026-04-10, beta text-event mapping.- Voice Live is a distinct Azure resource, so
AzureProviderreadsAZURE_VOICELIVE_ENDPOINT/AZURE_VOICELIVE_API_KEY/AZURE_VOICELIVE_API_VERSION(or explicitvoice_live_*arguments) as a fallback to theAZURE_OPENAI_*variables, resolving each set from its own sources. - Four Voice Live WS cassettes are live-recorded (secret-scrubbed) and replay offline.
Model routing
Because Voice Live isn't a model-catalog superset, AzureRealtimeModel routes by model via azure_realtime_apis on a new AzureRealtimeModelProfile:
- Both (
gpt-realtime,gpt-realtime-mini,gpt-realtime-1.5) — default to GA;azure_voice_live=Trueselects Voice Live. - Voice Live only (
phi4-mm-realtime, and the cascade chat modelsgpt-4o/gpt-4.1/gpt-5served via Azure STT→LLM→TTS) — routed to Voice Live automatically. - GA only (
gpt-realtime-2,gpt-4o-realtime-preview, the translate/transcribe realtime models) —azure_voice_live=Trueraises a clearUserError.
An unrecognized name (a future release, or a deployment named after something else) defaults to GA and reaches Voice Live only with azure_voice_live=True; a profile= AzureRealtimeModelProfile(azure_realtime_apis=…) override corrects a mismatched deployment name.
Usage
import os
from pydantic_ai import Agent
from pydantic_ai.providers.azure import AzureProvider
from pydantic_ai.realtime.azure import AzureRealtimeModel, AzureRealtimeModelSettings
model = AzureRealtimeModel(
'gpt-realtime',
provider=AzureProvider(
azure_endpoint=os.environ['AZURE_OPENAI_ENDPOINT'],
api_key=os.environ['AZURE_OPENAI_API_KEY'],
),
settings=AzureRealtimeModelSettings(azure_voice_live=True),
)
agent = Agent(instructions='You are a helpful voice assistant.')
async def main():
async with agent.realtime(model).session() as session:
await session.send('Say hello.')
async for event in session:
... # handle audio deltas, transcripts, tool calls, ...
Follow-ups (out of scope)
- Cascade voice/transcription tuning (Azure TTS voices, Azure STT model selection): #7389.
- Foundry Agents (
agent_id/project_idrouting): #7390. - Browser WebRTC for Voice Live is deferred (#6702): Voice Live negotiates WebRTC over its own WebSocket control channel, unlike the GA
/realtime/callssignaling inherited from #6676, soanswer_webrtc_offer/create_client_secretraiseUserErrorwhen Voice Live is in effect. Browser WebRTC works today on the GA Azure OpenAI realtime model.
Closes #6702 is not intended here (WebRTC-for-Voice-Live stays tracked there).