Pydantic AI is a Python agent framework built around a typed, extensible agent loop. You give an agent a model string, instructions, tools, and an output type, and every run comes back validated against that type, so your IDE, type checker, and the model agree on what the agent returns. Tool signatures and docstrings become the tool schema, arguments are validated before your code runs, and dependencies reach tools through a typed run context.
Models are swapped by changing a string, across OpenAI, Anthropic, Google, Bedrock, Azure AI Foundry, Groq, Mistral, xAI, Ollama, and other providers. The same agent definition runs as a plain object, a CLI, a built-in web chat, a realtime voice session, an editor agent over ACP, a headless job in GitHub Actions, or behind your own frontend through AG-UI or Vercel AI event streams. Image generation and embeddings come in the same package.
The central building block is the capability, which bundles tools, instructions, hooks, and model settings into a reusable unit. The core ships fundamentals such as MCP and web search, and Pydantic AI Harness adds memory, guardrails, sub-agents, planning, context management, and persistence, up to a complete terminal coding agent. Agents can also be defined without code as YAML or JSON specs.
Related packages cover the rest of the stack: Pydantic Graph for typed graph control flow, Pydantic Evals for testing agent behavior the way pytest tests code, Logfire for OpenTelemetry-based tracing and cost tracking, the Pydantic AI Gateway for one key across providers, and Monty, a sandboxed Python interpreter for model-written code.
Features
- Structured output: runs return validated, typed results, including typed image output
- Typed tools and dependencies: function signatures become tool schemas, and a typed run context injects databases, clients, and user data
- Model choice: OpenAI, Anthropic, Google, Bedrock, Azure AI Foundry, Groq, Mistral, xAI, Ollama, and more, swappable with a string
- Capabilities: reusable bundles of tools, instructions, hooks, and model settings, which can load on demand during a conversation
- Durable execution: eight engines (Temporal, DBOS, Prefect, Restate, AWS Lambda, Kitaru, Airflow, and Absurd) turn model and tool calls into durable steps that survive restarts, with human-in-the-loop approval
- Realtime voice: the same agent and tools on OpenAI Realtime, Gemini Live, Azure, and xAI Grok Voice sessions
- Interfaces: CLI, built-in web chat, ACP editor agent, GitHub Agentic Workflows, and AG-UI or Vercel AI event streams for custom frontends
- Observability: OpenTelemetry instrumentation that works with any OTel backend, with one-line Logfire setup
- Evals and graphs: Pydantic Evals for testing agent behavior and Pydantic Graph for typed graph workflows, as separate packages
- Coding agent: the Harness Coder capability combines workspace file access, an allowlisted shell, repo context, sub-agents, and context management



