After shipping the TypeScript SDK, the Python ecosystem had the same gap. Python developers building voice agents or FastAPI backends had no clean way to connect to Azure OpenAI's Realtime API without weeks of low-level WebSocket work.
Python companion to the npm package. Async WebSocket client, streaming iterators, function calling, and server middleware for Flask & FastAPI.
After shipping the TypeScript SDK, the Python ecosystem had the same gap. Python developers building voice agents or FastAPI backends had no clean way to connect to Azure OpenAI's Realtime API without weeks of low-level WebSocket work.
Built az-realtime-webrtc: an async-first Python SDK. RealtimeClient wraps the WebSocket with a clean context manager. Streaming is built in — async for chunk in session.transcript_stream(). Flask blueprint and FastAPI router handle the token server in under 10 lines each.
Flask blueprint or FastAPI router handles POST /api/realtime/token — keeps API key server-side.
async with client.connect() as session opens the WebSocket, completes session handshake, yields a RealtimeSession.
async for chunk in session.transcript_stream() yields TranscriptChunk objects word by word.
register_tool() binds a handler to a ToolDefinition. SDK runs the handler and sends the result back automatically.
async with as the primary API pattern is the right choice for Python — it makes session lifecycle explicit and prevents the most common bug: not closing the WebSocket cleanly.
Mirroring the TypeScript SDK's naming conventions makes it immediately familiar to developers using both packages.
Flask's sync nature requires asyncio.run() internally for the token endpoint — surfacing this in docs proactively saved many support questions.
py.typed marker + dataclass-based types makes the SDK first-class for mypy and pyright.
Async-first WebSocket client — async with, async for, async generators
Underlying WebSocket transport layer
Blueprint for token server — POST /api/realtime/token
Async router for token server with Swagger UI auto-generated
Microsoft Entra ID auth support via DefaultAzureCredential