Pydantic AI
by Pydantic Services Inc.
Build agents in ordinary typed Python, with the validation library you already trust
Pydantic AI is an open-source Python agent framework from the team behind the Pydantic validation library. It treats agents as ordinary typed Python — typed dependencies, plain functions as tools, and a Pydantic model as the guaranteed output shape — and works across effectively every model provider, with OpenTelemetry observability built in.
Pydantic AI is an open-source Python agent framework from Pydantic Services, the company Samuel Colvin built around the Pydantic validation library that Meta, NVIDIA, Netflix, Google, OpenAI and Salesforce already depend on. Its premise is that agent code should be ordinary, statically typed Python rather than a bespoke chain DSL: agents are declared with typed dependencies and a Pydantic output model, tools are plain functions whose signatures are validated, and the framework enforces the schema on every model response, retrying with the validation error attached when the model gets it wrong. It is model-agnostic across OpenAI, Anthropic, Gemini, DeepSeek, Grok, Cohere, Mistral, Perplexity, Groq, Azure AI Foundry, Amazon Bedrock, Ollama, LiteLLM, OpenRouter, Together AI and Fireworks, with a documented interface for custom providers. The repository is a uv workspace of several packages — pydantic-ai-slim for the agent runtime, pydantic-graph for type-hinted state machines that express complex control flow, pydantic-evals for evaluation, and clai, a CLI with an optional web UI. Beyond the basics it ships durable execution for surviving transient failures, streamed structured outputs validated as they arrive, human-in-the-loop tool approval, MCP support, and native realtime voice agents. Observability is OpenTelemetry-based and integrates tightly with Pydantic Logfire for tracing, cost tracking and evaluation-driven monitoring, which is also the commercial model — the framework itself is MIT-licensed and free, and Logfire is what Pydantic sells. Development is fast-moving: the project carries roughly 19,300 GitHub stars and shipped v2.29.0 on 12 August 2026, adding FastMCP 4 and MCP SDK v2 support, after v2.28.0 introduced speech-to-speech agents via Agent.realtime() and patched a high-severity flaw in the development chat UI.
The Python engineering team already standardised on Pydantic that wants agents to be reviewable, statically typed application code rather than an opaque chain abstraction.
Model output is validated against a Pydantic schema on every call and automatically retried with the validation error, so downstream code can rely on the shape instead of defensively parsing free text.
At a Glance
- Category
- Agent Development
- Pricing
- Free, Freemium, Subscription, Usage-based
- Target Market
- CTOs, Enterprise Developers, Data Scientists, ML Engineers
- Deployment
- Open-source, Self-hosted, API-based
- Founded
- 2022
- Headquarters
- United Kingdom
- Team Size
- 11-50
Key Features
- ✓Schema-enforced structured output
Responses are validated against a Pydantic model and automatically retried with the validation error attached, so malformed output never reaches downstream code.
- ✓Model-agnostic provider layer
One agent definition runs against OpenAI, Anthropic, Gemini, Bedrock, Azure AI Foundry, Groq, Ollama and many more, with a documented interface for custom providers.
- ✓Type-safe tools with dependency injection
Tools are plain Python functions whose signatures generate the schema, and typed dependencies are injected per run so tests can substitute fakes cleanly.
- ✓pydantic-graph state machines
Complex control flow is expressed as type-hinted graphs rather than implicit chains, which keeps branching and looping logic readable and statically checkable.
- ✓pydantic-evals evaluation framework
Evaluation is a first-class package in the same workspace, so regression testing agent behaviour does not require bolting on a separate harness.
- ✓OpenTelemetry observability with Logfire
Instrumentation is standard OpenTelemetry, giving real-time tracing, cost tracking and behaviour monitoring without locking you to one backend.
- ✓Durable execution and human-in-the-loop approval
Runs survive transient failures, and tool calls can be gated behind explicit human approval before they execute against real systems.
- ✓Realtime voice and MCP support
Agent.realtime() provides speech-to-speech agents on native models, and MCP servers plug in as tool sources alongside FastMCP 4 and MCP SDK v2.
Capabilities
Use Cases
- •Structured extraction from unstructured documents
Pull typed records out of contracts, tickets or emails with the output schema enforced and invalid responses retried automatically.
- •Multi-step agents with explicit control flow
Model branching workflows as pydantic-graph state machines so the execution path is reviewable in code rather than inferred at runtime.
- •Provider-portable LLM services
Ship a service that can switch between a hosted frontier model and a local Ollama deployment without touching agent logic.
- •Evaluated and observable production agents
Instrument agents with OpenTelemetry and run pydantic-evals suites so behaviour regressions are caught before they reach users.
- •Voice agents on native realtime models
Build speech-to-speech assistants through Agent.realtime() with browser WebRTC support, sharing tool definitions with the text agent.
Ideal For
Best For
- ✓Production Python services that need structured, schema-validated LLM output rather than free text parsed downstream
- ✓Teams that want to stay model-agnostic and swap between OpenAI, Anthropic, Gemini, Bedrock or a local Ollama model without rewriting agent code
- ✓Engineering organisations already invested in Pydantic and FastAPI, where the typing idiom and IDE support carry straight over
- ✓Agent workflows needing explicit control flow, expressed as type-hinted state machines with pydantic-graph rather than implicit chains
- ✓Teams that want OpenTelemetry tracing, cost tracking and evaluation baked in from the start via pydantic-evals and Logfire
Not Ideal For
- ✗Teams needing runtime security controls out of the box — researchers testing eleven agent frameworks found none, including this one, shipped injection detection or PII masking by default
- ✗Non-Python shops, or teams wanting a visual no-code agent builder; this is a code-first library with no drag-and-drop surface
- ✗Projects that cannot absorb frequent API churn. Maintainers report deleting entire middleware abstraction layers when v1.71+ shipped equivalent capabilities, and the project has moved through two major versions quickly
- ✗Organisations wanting a single vendor to supply the agent runtime, hosting and orchestration; Pydantic AI is a library, and durable execution generally means pairing it with Temporal, DBOS or Celery
Integrations
Deployment
Market Analysis
Pros
- ✓Type safety is the standout: practitioners describe it as ergonomic and well suited to 'building production, type-safe AI applications', a direct contrast with LangChain's opacity
- ✓Model neutrality is real, spanning sixteen-plus providers plus local Ollama and LiteLLM, which HN commenters cite explicitly as a way to avoid vendor lock-in
- ✓Strong pedigree and adoption signal — roughly 19,300 GitHub stars, MIT licensed, and built by the team whose validation library Meta, NVIDIA, Netflix, Google, OpenAI and Salesforce already use
- ✓Evaluation, graph-based control flow and OpenTelemetry observability are in the same workspace rather than bolted on from third parties
- ✓Sequoia-backed with $17.2M raised and a clear commercial model in Logfire, so the framework is not an unfunded side project
Cons
- ✗API churn is real. Teams maintaining libraries on Pydantic AI report deleting entire middleware abstraction layers when v1.71+ shipped equivalent capabilities, and the project has moved to a v2 line quickly
- ✗No built-in runtime security — a study of eleven agent frameworks found none shipped injection detection or PII masking out of the box, this one included
- ✗It is a library, not a platform: practitioners pair it with DBOS, Temporal or Celery for durability, and report needing extra infrastructure for streaming event handling and user-facing integrations
- ✗Recent releases have patched real security issues, including a high-severity flaw in the development web chat UI in v2.28.0 where the chat endpoint did not check request content type, risking cross-origin tool execution
- ✗Some practitioners note the commercial pressure on the project — 'Pydantic has VC money and needs to grow fast now' — as a reason to watch the open-source/commercial boundary
- ✗Python-only, so polyglot teams need a second framework for non-Python services
Pricing
Pydantic AI (open source)
$0
- ✓MIT licensed
- ✓All packages: pydantic-ai-slim, pydantic-graph, pydantic-evals, clai
- ✓Every model provider
- ✓No usage limits beyond your own LLM API spend
Logfire Personal
$0
- ✓1 admin seat, 2 read-only guests, 3 projects
- ✓10M records included
- ✓30-day retention
- ✓No credit card required
Logfire Team
From $49/mo
- ✓Up to 12 seats (5 included, $25 each extra)
- ✓10 guests, 5 projects
- ✓10M records then $2 per additional million
- ✓First-month money-back guarantee
Logfire Growth
From $249/mo
- ✓Unlimited seats, guests and projects
- ✓Up to 90-day retention
- ✓Priority support
- ✓Public API at 5,000 daily requests
Logfire Enterprise
Contact for pricing
- ✓Cloud, dedicated GCP or self-hosted deployment
- ✓Custom or unlimited retention
- ✓SSO, audit logging, custom SLA
The framework itself is MIT-licensed and costs nothing — you pay only your own model provider bills. Revenue comes from Pydantic Logfire, the observability platform, which is metered by records (logs, spans and metrics, budgeted at about 5KB per span averaged over usage): Personal is free with 10M records and 30-day retention, Team is $49/month for up to 12 seats with overage at $2 per additional million records, Growth is $249/month for unlimited seats and 90-day retention, and Enterprise is quote-only and the only tier with SSO, audit logging, a custom SLA and self-hosted or dedicated GCP deployment. All plans include $20/month of credits.
Security & Compliance
Connect
Sources
This page was written from 6 sources, 4 on domains other than github.com.
Stay Ahead of the Curve
Weekly enterprise AI insights for technology leaders. No spam, no vendor pitches—unsubscribe anytime.
SubscribeRelated Products
Kitesurf
An agent-first browser that runs in V8 isolates on Cloudflare Workers
Natural
Payments infrastructure that lets AI agents hold, send and collect money
AgentPrizm
Governed, persistent memory and reusable skills for AI agents — over REST API and MCP
Bespoke Labs
Reinforcement-learning environments that train reliable, production-ready AI agents