Pydantic AI is a Python agent framework from the team behind Pydantic. It gives you a typed, extensible agent loop where the model is a string you swap — OpenAI, Anthropic, Google, Bedrock, Azure AI Foundry, Groq, Mistral, xAI, Ollama, and others — and the same agent definition runs as a plain object you call run() on, a command-line interface, a web chat, a realtime voice session, or a durable background job.
Typing runs end to end: give an agent an output type and every run comes back validated, dependency injection and tools are typed, and Pydantic Graph applies the same typing to graph-based control flow. Structured outputs, image generation, and embeddings are part of the same package.
Behaviour is composed from capabilities — reusable units that bundle tools, instructions, hooks, and model settings. The core package ships fundamentals such as Model Context Protocol support and web search; a companion harness package adds memory, sub-agents, context compaction, a filesystem and shell, repo orientation, and planning, and composes them into complete agents such as a coder and a researcher. Agents can also be declared in YAML or JSON specs instead of code.
Durable execution is supported first-party on Temporal, DBOS, Prefect, and Restate, with external SDK integrations for Kitaru and Airflow: model and tool calls become durable activities, so a run survives restarts and long waits, and human-in-the-loop tool approval is built in. Instrumentation is OpenTelemetry-native and works with any OTel backend, and Pydantic Evals tests agent behaviour the way pytest tests code.
Frontend integration covers the AG-UI protocol and the Vercel AI Data Stream Protocol for streaming text, tool calls, and reasoning to a UI, plus an experimental Agent Client Protocol mode that serves an agent to an editor. A built-in test model lets you start without an API key.
Features
- Model-agnostic: swap providers with a string, or route through a gateway with one key, failover, and cost monitoring
- Typed end to end: structured outputs, typed dependency injection, and typed tools, checked by your type checker
- Capabilities: reusable units bundling tools, instructions, hooks, and model settings, composable into complete agents
- Harness package: memory, sub-agents, context compaction, filesystem, shell, repo context, and planning
- MCP and web search: Model Context Protocol servers and web search ship in the core package
- Durable execution: first-party support for Temporal, DBOS, Prefect, and Restate, with human-in-the-loop approval
- Every interface: the same agent runs as a library call, CLI, web chat, realtime voice session, or editor agent
- UI event streams: AG-UI and Vercel AI Data Stream Protocol support for streaming to your own frontend
- Observability: OpenTelemetry-native instrumentation that works with any OTel backend
- Evaluation: Pydantic Evals scores any Python function, agents included
- Graph control flow: Pydantic Graph brings the same typing to graph-based workflows
- Agent specs: declare an agent in YAML or JSON instead of Python
Built with this
Integrated by
Agent Memory
neo4j-labs/agent-memory gives agents three memory layers in one graph: conversation histo...
CascadeFlow
Cascading runtime for AI agents. Optimize cost, latency, quality, and policy decisions inside the agent loop.
DeepEval
Open-source framework for unit-testing and evaluating LLM apps with ready-made metrics that run locally
Hindsight
Agent memory system that stores and retrieves long-term memories so agents learn across sessions, not just recall history