Learning resourcesReviewed · Pydantic

Pydantic AI: ElevenLabs realtime integration guide

This guide shows Python developers how to connect voice assistants to ElevenLabs through Pydantic AI, but its two connection routes have different setup and recovery limits. It covers hosted ElevenLabs Agents and direct Eleven Realtime models, including tools, audio, authentication and incomplete usage reporting.

Researched 15 Nov 2026

In short.

This guide explains ElevenLabs voice integration for Python developers using Pydantic AI, but choosing a connection route changes who controls the agent and whether a dropped conversation can recover. Eleven Realtime takes instructions, tools and history from the Python agent and supports reconnection by replaying completed local history. ElevenLabs Agents connects to a hosted agent with platform features such as knowledge bases and workflows, but requires additional configuration and cannot restore a dropped session. The page documents substantial provider-specific restrictions, and neither route supplies usable live cost figures through Pydantic AI. Runtime behavior, voice quality and performance were not tested.

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

Coverage is the complete captured page at [https://pydantic.dev/docs/ai/realtime/elevenlabs/index.md], including both ElevenLabs Agents and Eleven Realtime, their examples, settings, support tables, costs and provider-specific quirks. The page also contains documentation-index and agent-query-parameter notices. Linked pages, package source, service terms and external pricing pages are excluded. No commands, examples, API calls or audio journeys were executed; runtime behavior and performance remain untested.

The overview

What the resource covers

This is Pydantic AI's ElevenLabs realtime integration documentation at [https://pydantic.dev/docs/ai/realtime/elevenlabs/index.md]. It teaches two ways to connect a Python voice agent: elevenlabs-agents:<agent_id> addresses an agent hosted on ElevenLabs, while elevenlabs:<model> connects directly to an Eleven Realtime speech-to-speech model.

The resource is an implementation guide covering configuration, protocol behavior and limitations. It is not a complete voice application, and its examples do not establish a deployed microphone-to-speaker experience.

Practical fit

The guide is useful for deciding which ElevenLabs connection matches an existing Pydantic AI application. Its central recommendation is to use Eleven Realtime when the Python agent should define the conversation, and to use ElevenLabs Agents when the application needs the hosted platform's knowledge bases, workflows, guardrails or configurable cascaded pipeline.

Its strongest material explains integration failures that can otherwise be difficult to diagnose: override permissions, mismatched tool definitions, incompatible audio profiles, abandoned tool calls and incomplete usage information. It provides no measured comparison of latency, speech quality, reliability or total cost.

Who it is for

The primary audience is Python developers building conversational voice assistants with Pydantic AI. Developers already using ElevenAgents can use it to understand which settings remain on the hosted agent and which can change for each conversation.

Beginners receive installation commands and short examples, but the page assumes familiarity with Python agents, API keys and tools. A working application also needs audio handling and session lifecycle code; the page refers readers to separate quickstart and deployment documentation for those topics.

Documented capabilities

Eleven Realtime supports speech conversations, local function tools, voice and language settings, automatic turn detection, push-to-talk, explicit interruption and reconnection. Its interruption support can trim remembered speech to what the user actually heard. History seeding accepts user and assistant text; audio and images cannot be seeded.

ElevenLabs Agents offers access to a hosted agent's configuration and platform features, with permitted conversation-level overrides for instructions, greeting, language, voice and other settings. It supports client-tool validation or synchronization, word-level speech timestamps and interruption corrections supplied by ElevenLabs. Server-side turn-taking remains under the hosted agent's control.

The page describes eleven_realtime_v1_mini as optimized for price and latency, and eleven_realtime_v1_max as focused on quality, reasoning and multi-step tool use. These are documented positioning claims without benchmark results on the selected page.

Using it

Requirements and dependencies

Both routes require a Python environment, the relevant pydantic-ai-slim optional dependency group and an ElevenLabs API key. The hosted-agent route additionally requires an existing ElevenLabs agent ID. Its key is required even for a public agent because the connection begins with an authenticated REST check.

Default hosted-tool checking and the off mode require read access; sync mode also requires write access to agents and tools. The direct integration includes the openai package because it reuses OpenAI Realtime protocol event types.

eleven_realtime_v1_max requires max_tokens to be at least 1024 or unset, and the page says it is unavailable in the India and Singapore data-residency regions. Minimum Python versions, pinned package versions and hardware requirements are not specified.

How the connections work

The direct route uses ElevenLabs' OpenAI Realtime-compatible API. Pydantic AI supplies the agent's instructions, tools and history. Reconnection creates a new session and replays completed local history; media still in flight is lost.

The hosted route first fetches the agent over REST, checks permitted overrides and reconciles client tools, then opens the agent WebSocket. A conventional hosted pipeline combines speech recognition, a configurable language model, speech synthesis and server-side turn-taking. A hosted agent can alternatively use ElevenLabs' Realtime voice mode, selected in its platform configuration.

Hosted responses identify the agent ID rather than the answering language model. ElevenLabs can use a fallback model after errors, invalid tool calls or timeouts. Context reports may name that model without linking it to an individual response; the conversations API supplies producing_llm per message afterwards. The page documents configuration to disable or customize this fallback cascade.

Setup described by the guide

For direct models, the documented installation command is pip install "pydantic-ai-slim[elevenlabs-realtime]". Set ELEVENLABS_API_KEY or supply ElevenLabsProvider with api_key, then select a model such as elevenlabs:eleven_realtime_v1_mini through agent.realtime(). The guide also provides an equivalent uv command.

For hosted agents, install pip install "pydantic-ai-slim[elevenlabs-agents-realtime]" and provision an ElevenLabs agent. Enable System prompt overrides when supplying local instructions, enable each other override being used, and add context_usage to the agent's client events. Choose how client-tool definitions should be reconciled before connecting.

The default tool mode, error, rejects differences. The sync mode creates or updates tools and changes the agent's attached client tools. These writes affect shared platform state, and concurrent sync operations can overwrite each other's final tool attachment. The guide recommends synchronizing during deployment rather than on a customer's first call.

ElevenLabsProvider.base_url selects a data-residency host. For hosted agents, the page says this keeps both REST and WebSocket traffic in that region. Actual residency behavior was not independently verified.

What the examples demonstrate

The hosted-agent example defines a friendly concierge and an asynchronous find_restaurant tool with cuisine and party_size arguments. It connects through elevenlabs-agents:agent_0101k2example and enables tool synchronization. The tool returns a fixed restaurant message; it does not demonstrate an actual availability search or booking.

The tool's docstring describes every argument because ElevenLabs requires parameter descriptions. Additional examples show German-language settings, a selected voice, speech-delivery controls and an audio profile with 24 kHz input and output.

For direct models, agent.realtime('elevenlabs:eleven_realtime_v1_mini') demonstrates model selection. A settings example selects a voice, English, a 1,800-second session limit and high turn-detection sensitivity. None of these examples was executed.

Assessment & evidence

Important operational limits

Both routes reject images and are unavailable through the Pydantic AI Gateway. Direct Eleven Realtime rejects output_modality='text'. It uses mono PCM16 audio, normally at 24 kHz; the input rate is configurable, while output stays at 24 kHz. The API's G.711 option is not exposed by this integration.

Hosted agents cannot seed conversation history, restore a dropped session, provide push-to-talk or accept explicit interruption through interrupt(). Audio formats are fixed on the agent and checked against the supplied profile; the default is 16 kHz PCM16. Telephony agents using ulaw_8000 are unsupported. Hosted sessions default to a 600-second maximum and can be configured up to 7,200 seconds.

Direct sessions also default to 600 seconds, with a configurable limit from 60 to 7,200 seconds. A reconnect policy can continue the conversation in a new session using replayed history. Semantic turn detection is supported; OpenAI ServerVAD and several other inherited OpenAI settings are unsupported or ignored.

Hosted client tools use a restricted schema dialect. Parameter descriptions are required; synchronization rejects unsupported unions and recursive references. Numeric bounds and additionalProperties cannot be represented, and required nullable parameters are advertised as non-null. Hosted MCP tools requiring ElevenLabs-side approval are denied; webhook and system-tool calls are absent from local history.

Direct models can abandon a tool call when answering new user input. The tool continues running and its result is recorded locally, but the model never receives it; a recoverable tool_calls_abandoned event identifies the calls. The max model may also finish a spoken preamble before issuing a separate tool call, so the first turn-completion event may arrive before the substantive answer.

How to weigh the tradeoffs

A practical inference from the documented behavior is that direct Eleven Realtime suits applications that need Python-owned instructions, manual turns and recovery through local history. That choice still requires handling lost in-flight media, missing usage measurements and tool calls whose results may be abandoned.

Hosted ElevenLabs Agents suits applications that depend on platform-managed knowledge, workflows or a chosen pipeline language model. In exchange, configuration is split across Python and the hosted agent, tool synchronization can change shared state, and connection loss ends the session. Requirements for cost enforcement, complete tool auditing or resumable conversations deserve particular attention.

Alternatives established by the page

The supported comparison is between the direct Eleven Realtime route and the hosted ElevenLabs Agents route. Within the hosted route, Custom voice mode provides a configurable cascaded pipeline, while Realtime voice mode uses an ElevenLabs-selected language model and speech-synthesis model.

Within the direct route, mini and max offer documented differences in intended price, latency and quality priorities. The page supplies no measured comparison with each other or with other providers.

For tools needing approval, the page recommends supplying them through a Pydantic AI MCP toolset instead of an ElevenLabs-hosted approval flow. The linked toolset documentation and other provider alternatives are outside the selected page.

Evidence and confidence

The evidence is the complete selected ElevenLabs page in Pydantic AI's documentation at [https://pydantic.dev/docs/ai/realtime/elevenlabs/index.md]. It includes installation commands, configuration examples, feature tables and descriptions of errors and edge cases.

These findings describe documented behavior. No installation, code example, API request, browser connection or audio conversation was executed. Performance, interoperability and reliability remain untested. Linked API references, quickstarts, pricing information and ElevenLabs documentation provide no additional evidence here because their contents were not supplied.

Access & freshness

Costs and usage visibility

Exact prices, subscription requirements and per-conversation costs are unknown from this page. It says the max direct model costs more per token than mini, but gives no rates or measured cost comparison.

Hosted agents report language-model context consumption only when context_usage is enabled. This contributes input_tokens at session level without attribution to an individual response. usage.cost remains None, and a Pydantic AI cost_limit cannot be enforced. After a conversation, GET /v1/convai/conversations/{conversation_id} provides cost in credits through metadata.cost, duration through metadata.call_duration_secs and charging details through metadata.charging.

Direct Eleven Realtime reports no usage. Recorded token counts are zero, responses increment unmeasured_requests, and usage.cost is None. These zero counts represent missing measurements. The page does not establish an alternative live spending-control mechanism for this route.

Licensing and data terms

The selected page does not state licensing terms for its text, code examples or the relevant packages. It also does not establish commercial voice rights, output ownership or permission to redistribute provider assets. Those rights remain unknown from this evidence.

Regional connection hosts are documented, and hosted-agent privacy settings remain on the ElevenLabs platform. The page does not establish retention periods, training-data use, deletion guarantees or contractual compliance terms. A regional endpoint alone does not establish those permissions or guarantees.

Date and version limits

The supplied page was captured on 15 November 2026 at 11:55:50 UTC. It does not establish a package release number, minimum compatible release or page modification date.

Model availability, regional restrictions, feature support and pricing may change. The capture establishes what the documentation said at that time; current service behavior and later changes are unknown.

Suggested next steps

Choose the route based on where the agent should be configured and whether reconnection is required. Before implementation, establish compatible package versions, current model availability, provider prices and applicable service and voice terms.

For a hosted agent, verify override permissions, context_usage events, audio formats and tool definitions. Review synchronization changes in a development agent before applying them to an agent shared by live conversations.

For either route, build a small end-to-end voice demonstration that checks audio playback, transcripts, interruption, tool results and session closure. For direct models, include connection recovery, input arriving during a tool call and the max model's preamble behavior. Compare actual provider charges with application records. These are recommended validation steps; no such results are available.

Evidence for this report

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