Pydantic AI Documentation
by Pydantic
Type-safe Python agents from the team whose validation layer sits under every major LLM SDK.
Overview
Pydantic AI is a Python agent framework from the Pydantic team — the same people whose validation library underpins the OpenAI SDK, the Anthropic SDK, Google's ADK, LangChain, LlamaIndex, CrewAI and Instructor — and the documentation is written for engineers shipping production agents rather than demos. It reached v1 in September 2025, and the repository carries roughly 19,300 GitHub stars under an MIT licence with commits landing daily. The docs are organised around the framework's distinguishing choices. Type safety is the through-line: agents are generic over their dependency type and output type, so a static checker and your IDE catch a mismatched tool signature before runtime. A dependency-injection system passes database handles, HTTP clients and configuration into tools and system prompts without globals. Outputs are Pydantic models validated as they stream, so structured results arrive incrementally rather than only after the final token. Beyond that the reference covers durable agents that preserve progress across transient failures, human-in-the-loop tool approval gated on arguments or context, a graph package for explicit control flow, MCP client and server support, built-in web search, web fetch and image generation tools, speech-to-speech agents on native realtime models, and an evals package for systematic scoring. Observability is via OpenTelemetry with first-party Pydantic Logfire integration. The model layer is deliberately broad — OpenAI, Anthropic, Gemini, DeepSeek, Grok, Cohere, Mistral, Bedrock, Ollama, Groq, OpenRouter and many more behind one interface.
At a Glance
- Topic
- Frameworks
- Level
- Intermediate
- Format
- Documentation
- Cost
- Free
- Duration
- Reference docs; ~2-4 hours for the core agents, tools and output guides
- Provider
- Pydantic
- Hands-on
- Yes — code/exercises
- Certificate
- None
What You’ll Learn
- ✓Define agents that are generic over their dependency and output types
- ✓Use dependency injection to pass clients and configuration into tools
- ✓Stream structured Pydantic outputs that are validated while still arriving
- ✓Swap between OpenAI, Anthropic, Gemini and Bedrock behind one interface
- ✓Build durable agents that preserve progress across transient runtime failures
- ✓Gate risky tool calls behind human-in-the-loop approval on their arguments
- ✓Connect agents to MCP servers and expose your agents as servers
- ✓Instrument runs with OpenTelemetry and score them with the evals package
Highlights
- •Written by the Pydantic team, whose validation layer already sits under the OpenAI, Anthropic and LangChain SDKs
- •Type safety is real rather than decorative — agents are generic, so type checkers catch tool signature errors
- •Martin Fowler's site published a full walkthrough of building a CLI coding agent on it, which drew 197 points on Hacker News
- •Durable execution and human-in-the-loop approval are documented framework features, not patterns you assemble yourself
- •MIT licensed with roughly 19,300 GitHub stars and commits landing daily
Who It’s For
Best For
- ✓Python engineers who want static type checking across an entire agent
- ✓Teams already standardised on Pydantic and FastAPI
- ✓Developers building agents that must survive failure mid-run
- ✓Anyone wanting one interface across many model providers
Prerequisites
- •Solid Python including type hints and async/await
- •Familiarity with Pydantic models and validation
- •An API key for at least one supported model provider
FAQ
What is Pydantic AI Documentation?
The official documentation for Pydantic AI, a type-safe Python agent framework from the Pydantic team that reached v1 in September 2025 and carries roughly 19,300 GitHub stars. It covers agents, tools, dependency injection, streamed and validated structured outputs, durable execution, MCP, graphs, evals and Logfire observability across two dozen model providers. Read it and you can build an agent that type-checks in your IDE and survives production failures.
Is Pydantic AI Documentation free?
Pydantic AI Documentation is free to access.
What level is Pydantic AI Documentation for?
Pydantic AI Documentation is aimed at a intermediate audience. Recommended background: Solid Python including type hints and async/await, Familiarity with Pydantic models and validation, An API key for at least one supported model provider.
How long does Pydantic AI Documentation take?
Expect roughly Reference docs; ~2-4 hours for the core agents, tools and output guides. Most learners work through it at their own pace.
What will I learn from Pydantic AI Documentation?
You'll learn: Define agents that are generic over their dependency and output types; Use dependency injection to pass clients and configuration into tools; Stream structured Pydantic outputs that are validated while still arriving; Swap between OpenAI, Anthropic, Gemini and Bedrock behind one interface; Build durable agents that preserve progress across transient runtime failures; Gate risky tool calls behind human-in-the-loop approval on their arguments; Connect agents to MCP servers and expose your agents as servers; Instrument runs with OpenTelemetry and score them with the evals package.
Topics
Sources
This page was written from 3 sources, 2 on domains other than pydantic.dev.