What it is
Pydantic AI is an open-source Python agent framework from the team behind Pydantic, the validation library much of the AI ecosystem already uses. It aims to give agent code the same feel Pydantic gave FastAPI: a typed loop where tool arguments and final outputs are validated Pydantic models, dependencies are injected, and the model can be swapped with a string. V1 shipped in September 2025; V2 (June 2026) reorganized everything around "capabilities", one composable unit that bundles tools, hooks, instructions and model settings, plus an optional "Harness" library of ready-made capabilities.
How it works
You create an Agent with a model, instructions, tools and an output type, then call run(). The agent loops between the model and your tools, validating every tool call and the final result against your types, and passes your dependencies (database clients, user info) to tools through a RunContext. When one loop is not enough you can use pydantic-graph for typed control flow, wrap runs in a durable-execution engine such as Temporal, DBOS or Prefect so they survive restarts, and trace everything with OpenTelemetry (Pydantic Logfire or any OTel backend).
Key concepts
- Agent
- The core object configured with a model, instructions, tools and an output type, then run with run().
- Capabilities
- V2's reusable units that bundle tools, instructions, hooks and model settings into one composable piece.
- Dependencies / RunContext
- Dependency injection - RunContext carries your services and data into tools and instructions.
- Structured output (output_type)
- The run returns a validated, typed result such as a Pydantic model instead of free text.
- Durable execution
- Running an agent inside an engine like Temporal, DBOS or Prefect so long runs survive crashes and restarts.
- Pydantic Evals
- A library for grading agent outputs and tool-call trajectories on datasets or live traffic.
Use it when
- You write Python, like type hints, and want validated tool inputs and structured outputs by default.
- You want to switch between many model providers without rewriting agent code.
- You need production features (evals, OpenTelemetry tracing, durable execution) without adopting a heavy framework.
Look elsewhere when
- You are not in Python; there is no official TypeScript version.
- You copy older examples - V2 changed the recommended pattern to capabilities, and many tutorials and coding assistants still show V1 code.
Who uses it
- SentinelOne
Builds its Purple AI agents on Pydantic AI and tests them with Pydantic Evals in CI.
Evidence: pydantic.dev
- MindsDB
Migrated its AI data-analyst agents from LangChain to Pydantic AI for more control and performance.
Evidence: pydantic.dev
- Walmart
Built Code Puppy, an internal terminal coding agent, on Pydantic AI.
Evidence: pydantic.dev
Milestones
- Pydantic AI V2 stable, with capabilities as the core primitive and the Pydantic AI Harness (github.com)
- Pydantic AI V1.0.0 released (github.com)
Start learning
pydantic.dev
github.com
pydantic.dev