Learning resourcesReviewed · Pydantic

Pydantic AI OpenAI Realtime Guide

This Pydantic AI guide is for Python developers building OpenAI voice agents, but its two voice options have different controls and costs. It explains GPT-Live's separate speaking and backend models alongside gpt-realtime's native speech-to-speech approach. Installation, instruction placement, tool calls, browser connections and failure handling receive detailed coverage. Exact prices and independently verified runtime performance are not established.

Researched 24 Nov 2026

In short.

This Pydantic AI documentation page helps Python developers build OpenAI voice agents, but the choice of voice family changes instruction handling, conversation control and billing. GPT-Live separates speech from a backend model that receives the agent's instructions and tools; gpt-realtime offers native speech-to-speech interaction with manual turn and interruption controls. The guide supplies installation commands, configuration examples, browser connection options and detailed limitations. Particularly consequential catches include uncancellable GPT-Live delegations, background text that may be spoken aloud, inferred turn boundaries and potentially incomplete usage totals. No examples or sessions were executed, and exact costs, latency and production reliability remain unassessed.

Researched and written by an AI model and checked by a second AI model. How it works

Covers the complete selected page at https://pydantic.dev/docs/ai/realtime/openai/index.md, including setup, model routing, GPT-Live delegation, settings, reasoning, browser WebRTC, feature limitations, provider quirks and gateway support. Includes its notices about changing model availability, unsupported features and price-data dependencies. All linked pages, package files and external examples are excluded. No commands, code, audio sessions or browser calls were executed. Runtime performance, current model access, exact prices and production suitability remain unassessed.

The overview

identity

This is Pydantic AI's OpenAI realtime provider guide at [https://pydantic.dev/docs/ai/realtime/openai/index.md]. It teaches an integration within the Python agent framework rather than providing a standalone voice application.

The page distinguishes OpenAILiveModel, which connects to the GPT-Live API at /live/sessions, from OpenAIRealtimeModel, which connects to the Realtime API at /realtime. Despite sharing an OpenAI provider prefix, these are separate protocols with different capabilities.

assessment

The guide is useful for deciding how to connect an existing Python agent to voice. Its strongest material explains differences that could otherwise produce subtle bugs: instructions reaching a different model than expected, tool work continuing after a withdrawn request, and recorded turns differing from what a caller actually heard.

Its detailed failure descriptions support implementation planning, but they do not establish measured latency, voice quality, scalability or production reliability. The page includes maintainer observations from testing; those observations have not been independently verified here.

users

The examples make this most useful to Python developers building spoken assistants that call application functions, such as an order assistant performing a lookup. Developers adding browser voice can also use its explanation of direct browser-to-OpenAI audio with server-side agent control.

Beginners receive installation commands and small examples, but the guide assumes work with application code, asynchronous functions, credentials and session handling. For applications needing push-to-talk, explicit interruption or text-only responses, its documented gpt-realtime support is more applicable than GPT-Live.

capabilities

Both families support asynchronous function-tool execution, allowing speech to continue while work runs. Pydantic AI supplies its tool loop, including argument validation, retries, dependencies and capability hooks. The page also covers transcripts, message history, usage reporting and reconnection behavior.

For gpt-realtime, documented controls include noise reduction, speech speed, automatic or manual turn handling, text output and images as context for a subsequent turn. GPT-Live instead delegates reasoning, tools and image interpretation to a backend model, with native web search available through that backend.

Browser audio can use WebRTC, a direct media connection between the browser and OpenAI, while a separate backend connection runs the agent. The exposed PCM16 audio formats are mono: gpt-realtime uses 24 kHz, while GPT-Live also supports matched 16 kHz input and output settings.

Using it

requirements

The documented installation is pydantic-ai-slim with the openai-realtime optional group, which includes the OpenAI package and WebSocket transport. The page states that this group requires openai>=3.31.0. It does not specify a minimum Python version or pin a Pydantic AI release.

Authentication requires OPENAI_API_KEY or an explicitly configured OpenAIProvider. A custom provider can supply a key or base URL, but its custom httpx client is not used by the separately opened realtime WebSocket.

GPT-Live also needs access to its delegated backend model. The backend name is tried only when delegation first occurs; an unavailable or unauthorized backend ends the session with live_backend_model_unavailable. Browser deployments require server-side configuration and agent execution in the documented topology.

mechanism

With an openai: model string, names beginning with gpt-live select OpenAILiveModel; other names select OpenAIRealtimeModel. Constructing a class directly bypasses that routing. An azure: prefix always selects AzureRealtimeModel, and the page states that Azure OpenAI does not serve GPT-Live.

GPT-Live receives its speaking instructions through openai_live_instructions. The agent's instructions, system prompt and tools go to the backend instead. Because Live rephrases backend answers, language, style or exact wording specified only on the agent may not survive into speech. Replacing the default Live instructions also removes their delegation guidance, so custom instructions need to explain when to delegate.

Backend selection follows an explicit delegation setting, a model name after +, a compatible OpenAI agent model reached through the same route, then an automatically recommended model. Pinning the backend avoids changes caused by the automatic recommendation. Delegations run one at a time, although speech and delegated work proceed independently.

setup

Install with pip install 'pydantic-ai-slim[openai-realtime]' or uv add 'pydantic-ai-slim[openai-realtime]', configure the API key, then create an Agent and select a voice model through agent.realtime(). The page illustrates openai:gpt-live-1 and openai:gpt-realtime. Sessions use a server-side WebSocket by default.

Use OpenAILiveModelSettings or OpenAIRealtimeModelSettings for the chosen family. GPT-Live fixes voice, audio format and starting instructions for the session. For a GPT-Live session without microphone audio, openai_live_idle_audio=True supplies silence so speech can advance; that silence is billable.

For browser voice, answer_webrtc_offer relays the browser's connection offer through the server and returns a session for backend control without exposing a token to the browser. Alternatively, gpt-realtime supports create_client_secret for a short-lived browser token. GPT-Live does not support client secrets. The page points to the session quickstart at [https://pydantic.dev/docs/ai/realtime/overview/#quickstart].

example

The order-assistant example assigns business rules to the agent and registers an asynchronous lookup_order function. Its Live instructions separately identify the speaker as Sam, set a warm and brief style, and tell the voice model to delegate order lookups. The backend is explicitly set to gpt-6.1-sol with low reasoning effort.

The sample lookup function only returns a formatted statement saying an order ships tomorrow. It demonstrates tool wiring, not a connection to a real order database. Other snippets illustrate sending typed requests, adding background context, sending an image with respond=True and pruning completed tool rounds. These examples were not executed.

Assessment & evidence

limitations

GPT-Live cannot cancel a delegation: backend work and tools continue even after a caller withdraws the request. The page recommends approval for tools that change state when retracted requests must not proceed. Live also lacks manual turn control, explicit interruption commands, text-only output and speech-start/end events. Turn completion is inferred from silence, with a default threshold of 2000 milliseconds, rather than confirmed by a protocol event.

Background text sent with respond=False can still be spoken aloud. Live's context input is capped at 500 tokens; oversized background context raises an error, while long typed requests reach the backend without necessarily telling Live what was typed. Images require respond=True and go to the backend. Seeded history is text-only and limited to 128 messages and 8192 tokens; older conversation may be summarized during a call.

GPT-Live transcripts do not reliably identify interrupted speech, and backend web-search sources and citations are not recorded. GPT-Live is not supported through the Pydantic AI Gateway in this page. For gpt-realtime, native remote MCP tools are not exposed through Pydantic AI, reconnection loses in-flight media, and rejected content can remain in server history and cause repeated response failures until a new session excludes it.

reasoning

GPT-Live performs reasoning on its backend model. The shared thinking setting controls backend reasoning effort, unless openai_live_delegation specifies reasoning_effort explicitly. Neither family streams readable reasoning as ThinkingPart content.

For gpt-realtime, thinking applies only when the model profile reports support, including the documented gpt-realtime-2 family. True selects medium effort, False selects none, and an effort string selects a level. The GA gpt-realtime model ignores this setting.

GPT-Live can retain encrypted backend reasoning associated with web search for continuation through OpenAIResponsesModel. Requesting a reasoning summary can add readable summary text, but some parts may remain empty. The page supplies no measurements showing how reasoning settings affect accuracy, delay or cost.

alternatives

Within the guide, gpt-realtime is the documented option for applications needing manual turns, explicit interruption, text output or images retained as context. GPT-Live offers a separate speaking model and delegated backend, with stricter controls and duration-based voice billing. The page does not establish a quality or latency winner.

The guide also mentions AzureRealtimeModel, OpenAI-compatible realtime endpoints and the Pydantic AI Gateway. Gateway routing is documented for gpt-realtime, while GPT-Live must connect directly through OpenAI. Detailed Azure behavior, competing frameworks and other voice providers are outside the supplied page and were not assessed.

evidence

The evidence is the complete Pydantic AI provider documentation page at [https://pydantic.dev/docs/ai/realtime/openai/index.md], retained as selected-page.txt. It includes configuration examples, feature-support tables, usage explanations and provider-specific error behavior. Linked documentation and repository issues supply navigation only; their contents are not included.

The page reports maintainer observations about spoken wording, background-context acknowledgments and other runtime quirks. Those are attributed observations rather than independently reproduced results. No installation, code example, voice session or browser call was executed.

The captured source revision is sha256:f49e7739ce63dcaf3a5629c3e00ebae2e22c0f6bdce8e574c9733a63188c912d.

Access & freshness

costs

Exact prices and realistic per-call totals are unknown from this page. GPT-Live charges for audio duration, including streamed silence, while its delegated backend incurs separate token charges. Every typed request that asks for a reply runs the backend, even when no tool is needed. Cost reporting depends on available model prices in genai-prices.

GPT-Live usage totals can omit the interval after the last provider report if final usage does not arrive. Closing a browser control connection leaves the browser call running and cannot obtain its final total. A cost_limit covers spoken seconds and backend tokens only when both are priced; token limits cover the backend, and there is no direct duration-limit field. Backend request limits are counted after responses have run.

For gpt-realtime, the page warns that later responses are billed against accumulated conversation content, including earlier tool calls and results. openai_prune_tool_items deletes answered tool rounds from provider context, while openai_keep_tool_items preserves selected tools. This can reduce repeated context but removes those results from the model's subsequent context; the full local message history remains.

rights

The supplied page does not establish the documentation's redistribution license, the library's license, OpenAI service terms or rights in generated speech. No redistribution permission can be inferred from this evidence.

openai_live_store defaults to False. Enabling it retains the session at OpenAI so it can be downloaded, forked or used for reconnection with the conversation preserved. The page does not establish retention periods, deletion guarantees, data residency or broader provider data-use terms.

freshness

The page was captured on 24 November 2026 at 02:37:15 UTC. This is an acquisition timestamp, not a publication or update date. The supplied text does not identify a Pydantic AI release or establish when each documented feature became available.

The page explicitly warns that model availability and aliases can change. Automatic backend selection can also move, and cost reporting depends on current price data. Its examples and statements about SDK requirements, gateway support and model access therefore describe the captured documentation, without a separate live availability check.

actions

Choose the voice family against concrete requirements first: push-to-talk, interruption, text-only output, image handling and billing. For GPT-Live, pin the backend when consistency matters and put persona, language and delegation guidance in openai_live_instructions. Keep business rules and tools on the agent.

Before relying on a deployment, verify backend access on an actual delegation, spoken instruction adherence, background-context disclosure, withdrawn requests, reconnection and final usage accounting. Protect consequential tools with the documented approval mechanism. If call duration must be bounded, use an application timer rather than assuming token limits cap the voice session.

For browser use, follow the documented offer-relay and backend-control topology. For tool-heavy gpt-realtime sessions, decide which results must remain available before enabling pruning. Obtain current prices and applicable licensing and service terms separately.

Evidence for this report

selected-page.txtselected · checked 2026-11-24