Skip to main content
← Frameworks

Pydantic AI

Pydantic
Python Open source MIT Coding framework General-purpose harness Type-safe MCP A2A durable-execution Persistence State management Graph execution Subagents Multi-agent eval HITL human-in-the-loop Sandbox Integration ecosystem 8 axes checked Active Checked 2026-10-23

Read the two badges separately: the first is whether this page is backed by evidence, the second is whether the product is still maintained. An archived product can have complete evidence; complete evidence does not mean the product is active.

30-second check: should it make your shortlist?

In one line

Pydantic AI is the type-safe Python agent loop — official README: "Pydantic AI is the…

How you use it

Local / self-hosted · Framework / SDK

Licence / commercial use

Open licence

Read the original licence before commercial use
Mainland China

Direct in mainland · Not in filing list

These four cards help you rule things out, not decide for you. The real differences are in the eight questions and sources below.

Information not confirmed

  • The default file-access boundary of the core SDK without Harness (not stated officially; overview and harness pages checked)
  • Whether the core SDK has process/network-level sandboxing and built-in permission boundaries (not stated officially; sandboxing sits in Harness / Monty)
  • The default trimming strategy and thresholds of Harness compaction (not stated officially)
  • Billing details of the Pydantic AI Gateway (not itemized on the official pricing page; rates not recorded per D9)
  • Feature alignment across the eight durable engines (not stated officially)
  • Full behavioral equivalence across providers (the official docs already state it "depends on the model and API you select")
  • The official 2.0 replacement path after A2A removal (the official docs point to datalayer/fasta2a)

Pydantic AI is the Python agent library from Pydantic. Its selling point is type safety. The official self-description puts two keywords together: "Pydantic AI is the Python AI SDK: a typed, extensible agent loop with every model a string swap away." "Typed" is its worldview: Pydantic runs natively from the data layer all the way to agent output. "Agent loop" is its shape: it hands you primitives, not a finished product. It sits in the same bracket as the OpenAI Agents SDK, but goes noticeably deeper on two points — type safety and durable execution.

When to use it, when not to

A fit when: you are a Python team that wants type-safe structured output plus dependency injection for your agents; you need to turn an agent run durable, using an engine you already operate; you are doing multi-agent work (delegation / hand-off / graph); you want first-class MCP support and want MCP running locally so you keep control of credentials; you want a thin agent loop and also want the official ready-made Harness (Coder / Researcher / memory / guardrails). Not a fit when: you are on TypeScript / Node (see Mastra); you want the smallest possible dependency set and do not want to bring in Pydantic; you want to avoid every commercial component (Logfire and Gateway are official recommendations but optional); you need process-level sandboxing and network policy built into the framework — the sandbox lives in the Harness / Monty, not in the core SDK.

China availability domestic / direct access / CAC filing · snapshot 2026-10-23

Origin
foreign-made foreign entity (no matching filing entity in the CAC registry).
Direct access
direct OK official site measured 200 direct; PyPI measured reachable.
CAC filing
not in filing list:not in the CAC public registry (13 batch attachments searched 2026-10-20, https://www.cac.gov.cn/2024-04/02/c_1713729983803145.htm); the product does not serve the mainland public, so filing does not apply.

Filing status is quoted from the CAC public registry (updated batch by batch; this site copies the number and does not interpret it). "Direct access" is this site's own reachability measurement from a mainland network, not a vendor promise. GitHub-hosted sites fluctuated on the measurement day — the note says so.

8 questions, one table

8 questions, each comparable item by item with its peers.

Model & openness

The most model providers connectable, with a full official catalog; switching models is one string.

The official first selling point is model-agnostic. Official overview, verbatim:

Model-agnostic: Supports virtually every model and provider: OpenAI, Anthropic, Gemini, DeepSeek, Grok, Cohere, Mistral, and Perplexity; Azure AI Foundry, Amazon Bedrock, Google Cloud, Ollama, LiteLLM, Groq, OpenRouter, Together AI, Fireworks AI, Cerebras, Hugging Face, GitHub, Heroku, Vercel, Nebius, OVHcloud, Alibaba Cloud, and SambaNova.

The official docs add a line leaving a door for in-house models. Official wording:

Official wording: "If your favorite model or provider is not listed, you can easily implement a custom model."

The official catalog splits providers into four groups.

  • 9 model developers — OpenAI, Anthropic, Google(Gemini), DeepSeek, Mistral, plus Cohere / xAI / Moonshot(Kimi) / Z.AI
  • 6 cloud platforms — AWS Bedrock, Google Cloud(Vertex AI), Azure Foundry, Alibaba Cloud, Snowflake Cortex, Heroku
  • 3 local & self-hosted — Ollama (ollama:), vLLM (vLLM:), LiteLLM (litellm:)
  • 8 inference platforms & gateways — Groq, Cerebras, Hugging Face, Together, Fireworks, OpenRouter (six inference platforms) plus Vercel AI Gateway and Pydantic AI Gateway (two gateways)

Usage is a <provider>:<model> prefix string, e.g. Agent('openai:gpt-5.2'). The official models/overview page gives a provider catalog table. Each provider row carries its service type and selection syntax.

There are also a fallback model and ModelProfile. The latter marks capabilities like supports_tools, supports_json_schema_output.

⚠ One boundary the official docs draw themselves: capabilities are not guaranteed equivalent across providers.

Official wording: "Feature support depends on the model and API you select, even when two services use the same API format."

Full behavioral equivalence after switching providers is not guaranteed by the official docs. The official position: the same agent is portable, but per-vendor behavioral consistency needs testing.

Where it runs

A pure Python library, not a service — after install, you decide where it runs.

Install is uv add pydantic-ai (or the slim variant). It does not start a server. The official position is "the same agent runs everywhere". Official README, verbatim:

"The same agent runs everywhere you need it: behind a web frontend, in the terminal, on a voice call, on a durable background queue, in GitHub Actions, or as a plain object you call run() on."

The runtime surface is yours; the official docs give these entry points:

  • embedded in a web frontend (AG-UI / Vercel AI event streams)
  • the terminal (official CLI clai)
  • on-device voice sessions
  • a durable background queue (that path requires wiring an engine — see the background axis)

Who runs the agent loop: you. Two optional official components — the Pydantic AI Gateway (self-hostable) for model routing, and Logfire for observability. Both optional; neither changes the fact that "the library is run by you".

The official docs also provide GitHub Agentic Workflows, running headless on issues / PRs. There is also a built-in web chat entry. Both are built on the same library.

Local files

The core agent carries no file system; the official Harness provides a complete local-file kit.

A plain Agent has no workspace concept. File capability lives in the Pydantic AI Harness. Official README, verbatim (Coding agent section):

"A complete coding agent in your terminal: workspace-rooted file access, allowlisted shell, repo orientation, planning, and context management that survives long sessions."

The implementation is a set of separable capabilities:

  • FileSystem('.')
  • Shell(cwd='.')
  • RepoContext()
  • SubAgents(...)
  • ClearToolResults()
  • ToolOutputLimits()

The official docs stress Coder merely composes them. Official wording:

Official wording: "use it whole, or use the blocks it bundles directly; the two are equivalent"

The key boundaries are written explicitly: file access is workspace-rooted (scoped to the workspace), shell is allowlisted (whitelist).

There is also Monty, officially "a sandboxed Python interpreter that runs model-written code". It runs code written by the model.

Unknown: the default file-access boundary at the core-SDK level (without Harness) is not stated by the official docs Verified: overview and harness pages checked.

Tasks after shutdown

Its hardest differentiator: the official docs list eight durable-execution engines, and "every model and tool call becomes its own durable unit".

Official durable execution page, verbatim:

"Pydantic AI allows you to build durable agents that can preserve their progress across transient API failures and application errors or restarts, and handle long-running, asynchronous, and human-in-the-loop workflows with production-grade reliability."

Mechanism, official wording:

"Each engine wraps every model request and tool call as its own durable unit"

The official README lists the engines as Temporal, DBOS, Prefect, Restate, AWS Lambda, Kitaru, Airflow, Absurd, with "the first five co-maintained with the vendor teams". Third parties also have a durable execution backend builder to plug in their own engine.

Connection example: the TemporalDurability() capability + PydanticAIWorkflow; officially:

"a run working through a background queue survives restarts, failures, and long waits"

⚠ Read the boundary out loud: the official docs dedicate one line —

"Durability is not storage"

Meaning: the durable engine only guarantees one run survives crashes. It does not store your conversation threads — that is a separate Persistence module.

Two more limits: run_sync() / run_stream_sync() cannot be used inside tools; use async def. Each agent can attach only one durable engine; attaching a second throws UserError.

Tools & extensions

The tool surface has four layers: function tools + MCP + A2A + capability composition. MCP is a core capability.

Function tools register with @agent.tool. Official wording:

Official wording: "the rest of its signature and its docstring become the tool schema, arguments are validated before your code runs"

Argument errors are fed back to the LLM for retry.

MCP officially supports two directions (mcp/overview page):

  • ① the agent connects to an MCP server and uses its tools
  • ② the agent is placed inside an MCP server

The recommended approach is the MCP capability. Officially:

"It runs the MCP server locally by default — keeping credentials, hooks, and tracing under your control"

and a single native=True flag opts into the model provider's native MCP (falling back to local when unsupported). Low-level: MCPToolset (toolsets=[...]). "Local by default" matters for credential control.

⚠ A2A is being retired. The official integrations/a2a page states explicitly:

  • Agent.to_a2a() and pydantic-ai-slim[a2a] are "deprecated and will be removed in 2.0"
  • fasta2a has moved to datalayer/fasta2a, with a Pydantic AI bridge

UI/interfaces: AG-UI, Vercel AI event streams, CLI, built-in web chat, voice. There is also the capabilities composition mechanism. And YAML/JSON agent specs for defining agents without code.

Context & memory

It explicitly splits "persistence" from "durability" — the core framing of this dimension.

Official durable execution page, verbatim:

"Durability is not storage — A durable engine keeps one run alive across crashes and restarts. It does not store your chat threads: saving a conversation and picking it up later is a different problem ... laid out in Persistence."

i.e. the durable engine manages run survival. Persistence manages saving and resuming conversation threads — a separate module.

Harness additionally provides context management: the official capabilities list includes memory, context management (compaction), persistence. Official README, verbatim says Harness:

Official wording: "has everything an agent needs for complex, long-running work, snapped on as capabilities"

So our "state ≠ context" is split by the official docs into three: the durable run (engine), the chat thread (Persistence), context compaction.

Unknown: the concrete trimming strategy and thresholds of compaction — the official docs give no defaults Verified: README and durable page checked.

Permissions & limits

Human intervention is "tool-level approval"; sandboxing sits in Harness / Monty; credentials default to local.

HITL tool approval is item 8 of the official overview:

"Human-in-the-Loop Tool Approval: Easily lets you flag that certain tool calls require approval before they can proceed, possibly depending on tool call arguments, conversation history, or user preferences."

This line comes from the deferred tools page. Its level differs from other listed objects: it intercepts "may this tool call run", and can decide dynamically from arguments and history.

guardrails also ship with Harness (the official Harness capability list includes guardrails).

Sandbox: the official Monty is "a sandboxed Python interpreter that runs model-written code". Harness's Shell is allowlisted; FileSystem is workspace-rooted.

Credentials: MCP runs locally by default; officially "keeping credentials, hooks, and tracing under your control".

Unknown: whether the core SDK has process/network-level sandboxing and built-in auth/permission boundaries is not stated by the official docs Verified: overview, durable, and mcp pages checked. Enterprise-grade permissions and auditing are handled on the Logfire / Gateway side.

Best for

Fits: Python teams needing type safety, and anyone turning agent runs into durable ones.

  • Python teams building agents with "type-safe structured output + dependency injection"
  • You need agent runs to become durable (across restarts, long waits, HITL), and want to use engines you already have, like Temporal / DBOS / Prefect
  • Building multi-agent systems (agent delegation / hand-off / graph)
  • You need first-class MCP support and want MCP running locally to control credentials
  • You want both a thin agent loop and the official ready-made Harness (Coder / Researcher / memory / guardrails)
  • You want Pydantic validation to run end to end from the data layer to agent output

Does not fit: non-Python stacks, minimalists, and anyone needing a core-SDK-shipped sandbox.

  • TypeScript / Node teams (look at Mastra)
  • Chasing minimal dependencies, not wanting Pydantic and optional capability packages (its worldview is typed end to end)
  • Wanting to avoid any commercial component entirely — Logfire and Gateway are officially recommended but optional; the official docs state OTel and self-hosting are both supported
  • Needing framework-shipped process-level sandbox and network policy in the core — sandboxing sits in Harness / Monty, not the core SDK

Licence and terms of use

MIT

Top misconception

  • Assuming it is a purely thin harness — the official Pydantic AI Harness now bundles memory, guardrails, sub-agents and context management as capabilities, plus a complete Coder agent.
  • Reading "durability" as "conversation storage" — official docs state plainly that "Durability is not storage": the durable engine only keeps a run alive, while thread persistence is a separate module.
  • Assuming evals / observability require Pydantic Logfire — official docs state instrumentation is standard OpenTelemetry, so any OTLP backend works.
  • Assuming A2A is a long-term built-in — the official docs mark Agent.to_a2a() as deprecated in 1.x and removed in 2.0, with fasta2a moved to datalayer/fasta2a.

Evidence sources

Checked 2026-10-23,Content updated 2026-10-08。This is the date of the entry, not a claim that every field was rechecked that day.

TypeNameLink
repopydantic/pydantic-ai · repository (20,801★, MIT, Python, rolling verification 2026-10-23)https://github.com/pydantic/pydantic-ai
docsMain README ("Python AI SDK / typed agent loop", model-agnostic list, eight durable-execution engines, Harness, Coder)https://github.com/pydantic/pydantic-ai
docsOfficial docs · Overview (twelve "Why use Pydantic AI" items, type safety, MCP/A2A, HITL, durable execution)https://pydantic.dev/docs/ai/overview/
docsOfficial docs · Models and Providers (provider catalog table, <provider>:<model>, ModelProfile, fallback model, local/gateways)https://pydantic.dev/docs/ai/models/overview/
docsOfficial docs · Durable Execution (eight engines, every model/tool call a durable unit, "Durability is not storage")https://pydantic.dev/docs/ai/capabilities/durable_execution/overview/
docsOfficial docs · Graphs (pydantic-graph, usable independently of pydantic-ai; typed state machines)https://pydantic.dev/docs/ai/graph/graph/
docsOfficial docs · Pydantic Evals (code-first evaluation, datasets/cases/evaluators, trajectory evaluation)https://pydantic.dev/docs/ai/evals/evals/
docsOfficial docs · MCP (connect to MCP servers, be exposed as an MCP server, MCP capability local by default, native=True)https://pydantic.dev/docs/ai/mcp/overview/
docsOfficial docs · Dependencies (type-safe dependency injection, RunContext, overridable for testing)https://pydantic.dev/docs/ai/core-concepts/dependencies/
docsOfficial docs · Multi-agent Applications (five complexity tiers: single agent, delegation, hand-off, graph, Deep Agents)https://pydantic.dev/docs/ai/guides/multi-agent-applications/
docsOfficial docs · Agent2Agent (A2A) (to_a2a deprecated in 1.x, removed in 2.0; fasta2a moved to datalayer/fasta2a)https://pydantic.dev/docs/ai/integrations/a2a/
pricingOfficial pricing page (verified 2026-10-08: Pydantic libraries permanently MIT and free; Logfire free tier includes 10M spans/month, plus a Pro tier; quotes not stored per D9)https://pydantic.dev/pricing/
changelogReleases (v2.54.0 @ 2026-10-02)https://github.com/pydantic/pydantic-ai/releases

Test notes

This site has not completed measured runs. The test protocol is at protocols/framework/_protocol.md.

Suggested runs (tailored to coding-base + type-safety / durable dimensions):

#What to testWhy it is worth testing
1How many files and lines for a minimal hello agentquantifies the real onboarding cost of the "thin agent loop"
2Give it a Pydantic output model; verify the run must return that typethe official selling point is typed end to end — verify "the returned value is the type"
3Run an agent with tools and structured output on an Ollama local modelthe official catalog lists Ollama separately — verify real feasibility
4Run a long task with TemporalDurability, kill the process, then resumethe core of the official durable promise — must verify
5Code-volume comparison of agent delegation / hand-off / graph for multi-agentthe official docs give five complexity tiers — verify the selection advice
6Credential and behavior differences: MCP capability local-by-default vs native=Truethe official docs stress local-by-default keeps credentials under control — worth verifying

Versus the OpenAI Agents SDK: the table our readers most need to see

Both are "Python libraries that give you an agent loop", similar in style. The differences are concrete:

OpenAI Agents SDKPydantic AI
Type systemoptional dataclass / Pydantic outputPydantic-native: typed output + typed dependency injection + typed tools
Non-OpenAI modelslitellm / any-llm adaptersnative provider catalog: <provider>:<model> string switching, incl. local Ollama/vLLM
durable executionno dedicated engine (DIY)eight official engines (Temporal/DBOS/Prefect/Restate/AWS Lambda/Kitaru/Airflow/Absurd)
Upper capabilitiesprimitives-onlyplus Pydantic AI Harness (memory/guardrails/sub-agents/compaction + a ready Coder)
ObservabilityTraces report to the OpenAI backend by defaultstandard OpenTelemetry, any OTLP backend; Logfire optional

One-line rule: want Python's "type safety + durable" → Pydantic AI; want minimalism, built-in guardrails, and the OpenAI ecosystem → OpenAI Agents SDK.

Model-agnostic: the provider catalog is the official first selling point

Official overview, verbatim:

Model-agnostic: Supports virtually every model and provider: OpenAI, Anthropic, Gemini, DeepSeek, Grok, Cohere, Mistral, and Perplexity; Azure AI Foundry, Amazon Bedrock, Google Cloud, Ollama, LiteLLM, Groq, OpenRouter, Together AI, Fireworks AI, Cerebras, Hugging Face, GitHub, Heroku, Vercel, Nebius, OVHcloud, Alibaba Cloud, and SambaNova.

Usage is a prefix string Agent('openai:gpt-5.2'). Switching models is "a string swap away" — change one string.

The official models/overview page has the full provider catalog table. Local and self-hosted paths like Ollama / vLLM / LiteLLM are all in it.

⚠ One boundary the official docs draw themselves: capabilities are not guaranteed equivalent across providers.

"Feature support depends on the model and API you select, even when two services use the same API format."

Durable execution: eight official engines, and "every model and tool call becomes a durable unit"

This is what distinguishes it from the OpenAI Agents SDK. Official durable execution page, verbatim:

Pydantic AI allows you to build durable agents that can preserve their progress across transient API failures and application errors or restarts ... Each engine wraps every model request and tool call as its own durable unit.

Engine list (README, verbatim): Temporal, DBOS, Prefect, Restate, AWS Lambda, Kitaru, Airflow, Absurd. The first five are "co-maintained with the vendor teams". Third parties can also use the backend builder to plug in their own engine.

⚠ The boundary that must be read out loud: the official docs dedicate one line —

Durability is not storage. A durable engine keeps one run alive across crashes and restarts. It does not store your chat threads: saving a conversation and picking it up later is a different problem ... laid out in Persistence.

i.e. the durable run and conversation-thread persistence are two things — precisely an isomorphic expression of our "state ≠ context".

MCP: both directions supported, local by default to control credentials

The official mcp/overview page describes two directions:

  • ① the agent connects to an MCP server and uses its tools
  • ② the agent is placed inside an MCP server

The recommended approach is the MCP capability. Officially:

It runs the MCP server locally by default — keeping credentials, hooks, and tracing under your control — and lets you opt into the model provider's native MCP support with a single native=True flag.

Low-level: MCPToolset (toolsets=[...]). "Local by default" is valuable for credential control. Versus "handing credentials to the provider's native MCP", this is an optional trade-off.

A2A: officially being retired — mind the version timing

This must be written clearly, or it will be misjudged as a long-term built-in capability. The official integrations/a2a page headline reads:

Deprecated in 1.x, removed in 2.0
  • Agent.to_a2a() and pydantic-ai-slim[a2a] are deprecated, removed in 2.0.
  • fasta2a is now maintained by datalayer/fasta2a. Since v0.6.1 it ships a Pydantic AI bridge (agent_to_a2a).

So the sentence "Pydantic AI supports A2A" needs a version timestamp to be accurate.

Harness and Graph are two independent upper layers

  • Pydantic AI Harness: officially packages memory, guardrails, sub-agents, planning, context management (compaction), and persistence into capabilities, and ships ready-made Coder / Researcher complete agents.

The official docs also stress Coder is not a black box. Official wording: "use it whole, or use the blocks it bundles directly; the two are equivalent".

  • pydantic-graph: the official graphs page says it can be used independently of pydantic-ai — "it has no dependency on pydantic-ai and can be considered as a pure graph-based state machine library". The official docs also humorously note: a graph is a nail gun, not the right tool for every job.

Conclusion: both are optional layers grown off the core library — which is why we still file this under coding-base.

Verification notes

Basis for confidence: partial:

Why still partial: all eight axes are verified to conclusions from official pages. But several items remain that the official docs genuinely don't state, recordable only as "not stated officially":

  • the default file-access boundary of the core SDK without Harness
  • whether the core SDK has process/network-level sandboxing and built-in permission boundaries
  • the default trimming strategy of compaction
  • the Gateway's markup rates
  • the feature alignment across the eight durable engines

These are not "couldn't find it" — the official docs themselves don't give them, so it cannot rise to verified.

Official pages checked the 2026-10-08 check:

  • Repo README (positioning, model-agnostic list, eight durable engines, Harness, Coder example)
  • docs/ai/overview (twelve "Why use" items + bank support example)
  • docs/ai/models/overview (provider catalog table, ModelProfile, fallback)
  • docs/ai/capabilities/durable_execution/overview
  • docs/ai/graph/graph
  • docs/ai/evals/evals
  • docs/ai/mcp/overview
  • docs/ai/core-concepts/dependencies
  • docs/ai/guides/multi-agent-applications
  • docs/ai/integrations/a2a
  • the official pricing page pydantic.dev/pricing
  • releases (v2.54.0 @ 2026-10-02)

Verification method: WebFetch on each official page plus the GitHub API (repo metadata, releases).

Related entries

  • OpenAI Agents SDKThe pair most worth contrasting on our site: both are thin Python agent-loop libraries; Pydantic AI's differentiators are Pydantic-native type safety + eight official durable-execution engines.
  • MastraThe counterpart in another language: TypeScript's batteries-included full-stack framework vs Python's type-safe agent loop — their answers to the "first decision point" differ.
  • LangGraphOrchestration-layer contrast: LangGraph persists every superstep and modifies state via HITL; Pydantic AI's pydantic-graph is a typed state machine, and durable execution is delegated to external engines.
  • Deep AgentsThe official multi-agent page lists Deep Agents as the fifth (most autonomous) multi-agent form; Pydantic AI also has its own Harness — both sit on the "autonomy + files + subagents" side.
  • Filesystem MCP ServerOther layer · MCP tools

Same-category peers

Look at these three before reading further

Selected by overlap in jobs, not ranked. Compare where it runs, licence and status first; if one of the three fails, skip it.

ObjectWhereLicenceEvidence / statusWhat it is for
OpenAI Agents SDKLocal / self-hostedOpen licence8 questions checked
Active
"A primitives-only multi-agent harness" — the official description is "l
Claude Agent SDKLocal / self-hostedOpen licence8 questions checked
Active
The Python programming interface to Claude Code — a polished coding CLI
DSPyLocal / self-hostedOpen licence8 questions checked
Active
DSPy turns 'tuning prompts' into a programming problem (MIT, Stanford NL

This page is generated from the ai-handbook data layer (CC BY 4.0). For the judging criteria and method notes, see METHODOLOGY.md.