Pydantic AI

Framework · Last verified 2026-09-30

TL;DR

Pydantic AI is the Pydantic team's MIT-licensed Python agent framework: a typed agent loop with validated structured output, dependency injection and a model string for most providers. Multi-agent work uses delegation through tools, hand-offs in code, or the separate pydantic-graph package. It suits Python teams that want type-checked agents.

Key facts

Pydantic AI key facts. Data as of 2026-09-30.
Type Framework
Languages / SDKs Python
License MIT
Pricing model Open core
Orchestration pattern Supervisor
GitHub stars 20,278 (as of 2026-09-30)
GitHub forks 2,828
Last push 2026-09-30
Latest release v1.107.7
Repository pydantic/pydantic-ai
Website pydantic.dev
Documentation pydantic.dev
Last verified 2026-09-30

Key features

  • Agent with an output_type: runs return validated, typed results, and tool arguments are validated before your code runs. (source)
  • Typed dependency injection: tools and instructions receive a RunContext carrying your own dependencies. (source)
  • Capabilities: reusable bundles of tools, instructions, hooks and model settings attached to an agent. (source)
  • Multi-agent options: delegation through tools, programmatic hand-off, graph-based control flow and deep agents. (source)
  • Deferred tools: calls that need human approval or run outside the process, resolved inline or by the caller. (source)
  • Durable execution on Temporal, DBOS, Prefect, Restate, AWS Lambda and other engines. (source)
  • MCP client over Streamable HTTP, SSE or stdio, plus provider-native MCP tools. (source)
  • UI adapters for AG-UI and the Vercel AI SDK event stream protocols. (source)

Architecture and orchestration pattern

Pattern: Supervisor

The core object is an Agent: a model (chosen with a provider-prefixed string such as openai:...), instructions, tools, an output type and a dependencies type. A run loops between the model and tools until it can return a validated output. Capabilities package tools, instructions and hooks so they can be reused across agents, and toolsets bring in external tools, including MCP servers.

The multi-agent guide describes increasing levels: agent delegation (a tool on one agent runs another agent and control returns to the caller, optionally via the Harness SubAgents capability), programmatic hand-off (application code decides which agent runs next), graph-based control flow with the separate pydantic-graph package, and deep agents with planning and sandboxed execution. Agents are stateless and meant to be defined once at module level.

Conversation state is not stored by the framework: the docs recommend serializing message history to your own database, with StepPersistence in Pydantic AI Harness as a ready-made option. Durable execution integrations checkpoint model and tool calls so a run survives restarts.

Human in the loop

Human approval goes through deferred tools. A tool registered with requires_approval=True (or one that raises ApprovalRequired) is not executed immediately. Either a HandleDeferredToolCalls capability resolves the pending calls inside the run with your handler, or the run ends with a DeferredToolRequests output; the caller then collects approvals or denials and starts a new run with the previous message history and DeferredToolResults. The same mechanism hands a tool call to a frontend or background worker for external execution. The AG-UI adapter can surface tool approvals in a frontend, and the durable execution guide covers long human waits.

Protocols

MCP, A2A and AG-UI support for Pydantic AI. See the full matrix.
ProtocolSupportNote
MCP Yes evidence
checked 2026-09-30
Client: agents connect to MCP servers over Streamable HTTP, SSE or stdio and can use provider-native MCP tools; the docs also show agents used inside your own MCP server's tools.
A2A Partial evidence
checked 2026-09-30
Only through the separate fasta2a package (github.com/datalayer/fasta2a); V2 removed Agent.to_a2a() and the a2a extra.
AG-UI Yes evidence
checked 2026-09-30
Server side: pydantic_ai.ui.ag_ui.AGUIAdapter (pydantic-ai-slim[ag-ui]) streams agent events to CopilotKit and other AG-UI frontends; the AG-UI README lists Pydantic AI as 1st party.

Best for

  • Python services that need validated, typed outputs from LLM calls
  • Support or back-office agents with typed dependencies and approval-gated tools
  • Long-running agents on an existing Temporal, DBOS or Prefect setup
  • Research agents that delegate subtasks to specialist agents through tools

Not for

  • Projects that need built-in A2A serving; it now requires the separate fasta2a package
  • Teams that want a role-based crew abstraction instead of composing agents in code
  • Non-Python stacks

Quickstart

pip install pydantic-ai

Install not yet verified by this site. What this means

from pydantic_ai import Agent, RunContext, UsageLimits

researcher = Agent('openai:gpt-5.2', name='researcher',
                   instructions='Return three short facts about the topic.')
writer = Agent('openai:gpt-5.2', name='writer',
               instructions='Write a one-paragraph brief. Call research() first.')

@writer.tool
async def research(ctx: RunContext, topic: str) -> str:
    """Ask the research agent for facts about a topic."""
    result = await researcher.run(topic, usage=ctx.usage)  # share the usage budget
    return result.output

# needs OPENAI_API_KEY
result = writer.run_sync('The Agent2Agent protocol',
                         usage_limits=UsageLimits(request_limit=6))
print(result.output)
print(result.usage)

Common pitfalls

  • Requires Python 3.10+.
  • Model strings need a provider prefix (openai:...); in V2 the prefix-less form raises UserError. Set the provider key, for example OPENAI_API_KEY.
  • V2 (stable since 2026-06-23 per the upgrade guide) moved many Agent(...) arguments onto capabilities and removed Agent.to_a2a() and Agent.to_ag_ui(); the docs recommend upgrading through the latest V1 and clearing deprecation warnings first.
  • A bare pip install pydantic-ai no longer pulls extras such as ag-ui, temporal, groq or bedrock; add the ones you use, or install pydantic-ai-slim[...].
  • GitHub releases on 2026-09-30 include both v2.52.0 and v1.107.7; the repository's latest-release flag points at the V1 tag, so check which major you pin.

Official quickstart

Pros

  • Outputs and tool arguments are validated with Pydantic, so type checkers and IDEs see the real result types. (source)
  • Switching model providers is a change of model string across a long list of providers. (source)
  • Durable execution integrations exist for several engines, five of them co-maintained with the engine vendors. (source)
  • AG-UI support is part of the package, including shared state and tool approval. (source)
  • Instrumentation is plain OpenTelemetry, so any OTel backend works, not only Logfire. (source)

Cons

  • V2 is a breaking release: many Agent(...) arguments moved to capabilities and several V1 APIs were removed. (source)
  • A2A is no longer built in; Agent.to_a2a() was removed in favour of the external fasta2a package. (source)
  • Some V2 default behaviors changed without deprecation warnings, such as the default end_strategy becoming 'graceful'. (source)
  • Subagents, memory, planning and step persistence helpers live in the separate pydantic-ai-harness package. (source)
  • The framework does not store conversations for you; persistence means serializing message history yourself or adding Harness. (source)

Alternatives

FAQ

Does Pydantic AI support MCP?

Yes, as a client over Streamable HTTP, SSE or stdio, plus provider-native MCP tools. The docs also show calling agents inside tools of an MCP server you write.

Does Pydantic AI support A2A and AG-UI?

AG-UI is built in through AGUIAdapter. A2A only works through the separate fasta2a package, because V2 removed Agent.to_a2a().

Is Pydantic AI free?

The framework is MIT-licensed. Pydantic sells Logfire (observability, with a free tier) and enterprise support for Pydantic AI; neither is required.

Which version should I use?

The upgrade guide lists V2.0.0 as stable since 2026-06-23, and V2 releases continue alongside V1 patch releases. New projects can start on V2; V1 code should follow the migration map.

How does multi-agent work in Pydantic AI?

Mostly by delegation: a tool on one agent runs another agent and returns its output. Hand-offs in application code and typed graphs via pydantic-graph cover more structured flows.

Sources