Install
pip install pydantic-aiThe Pydantic way for Generative AI. Type-safe agents with validated inputs/outputs, FastAPI-inspired dependency injection, and — new in 2025 — durable execution, graph-based workflows, and a first-class evals framework.
Install
pip install pydantic-aiVersion
v1.90.0 · May 2026 · Python 3.10+
Best for
Typed APIs, structured output, validated data pipelines, evals-driven agents.
DeferredToolCalls class in pydantic_ai.output marked @deprecated — use DeferredToolRequests (already the recommended API since v1.87.x).pydantic_ai.capabilities: WrapperCapability (base for decorating capabilities), ReinjectSystemPrompt (guards against system prompt being truncated away), ProcessHistory (composable history transformation), ProcessEventStream (custom event handling), HandleDeferredToolCalls (inline deferred tool resolution), IncludeToolReturnSchemas (per-tool return schema injection), PrefixTools (capability-level tool prefixing), PrepareTools (capability-level tool preparation), SetToolMetadata (capability-level metadata tagging). New type aliases: RawToolArgs, ValidatedToolArgs, CapabilityRef, CapabilityPosition, CapabilityOrdering. CAPABILITY_TYPES registry for dynamic capability construction.capabilities parameter on Agent; Hooks with decorator registration; ModelProfile/DEFAULT_PROFILE; pydantic_ai.ui module (UIAdapter, UIEventStream, MessagesBuilder).ApprovalRequiredToolset HITL, DeferredLoadingToolset. UrlContextTool deprecated — use WebFetchTool.from pydantic import BaseModelfrom pydantic_ai import Agent
class Answer(BaseModel): value: int reasoning: str
agent = Agent('openai:gpt-4o', output_type=Answer)
result = agent.run_sync("What is 15 + 27?")print(result.data) # Answer(value=42, reasoning='...')Ready? Start Zero → Hero Step 1 →
| Date | Framework version (installed) | Summary of changes | Reviewer |
|---|---|---|---|
| 2026-05-05 | pydantic-ai 1.90.0 | Version bumped 1.89.1 → 1.90.0; “What’s new” updated (DeferredToolCalls deprecated in favour of DeferredToolRequests); comprehensive guide header updated; revision history entry added. Agent, TestModel, FunctionToolset, DeferredToolRequests, HandleDeferredToolCalls, ImageGenerationTool, MemoryTool, XSearchTool, RenamedToolset, WrapperToolset, IncludeReturnSchemasToolset, SetMetadataToolset, PreparedToolset imports verified against installed 1.90.0 (.routine-envs/check-0505). | Claude routine |
| 2026-05-02 | pydantic-ai 1.89.1 | Version bumped 1.89.0 → 1.89.1; “What’s new” heading updated; comprehensive guide header updated; revision history entry added. Agent, OpenAIModel imports verified against installed 1.89.1 (.routine-envs/check-pydantic-0502). | Claude routine |
| 2026-05-01 | pydantic-ai 1.89.0 | Version bumped 1.88.0 → 1.89.0; “What’s new” heading updated; comprehensive guide header updated; revision history entry added. Agent, OpenAIModel imports verified against installed 1.89.0 (.routine-envs/check-pydantic-0501). | Claude routine |
| 2026-04-29 | pydantic-ai 1.88.0 | Version bumped 1.87.0 → 1.88.0; “What’s new” heading updated; comprehensive guide header updated; revision history entry added. Agent, OpenAIModel imports verified against installed 1.88.0 (.routine-envs/main-py-0429). | Claude routine |
| 2026-04-25 | pydantic-ai 1.87.0 | Version bumped 1.86.1 → 1.87.0; “What’s new” updated for v1.87.0 (9 new capability classes); new Capabilities API (v1.87.x) section added to comprehensive guide documenting WrapperCapability, ReinjectSystemPrompt, ProcessHistory, ProcessEventStream, HandleDeferredToolCalls, IncludeToolReturnSchemas, PrefixTools, PrepareTools, SetToolMetadata. All symbols verified against installed 1.87.0. | Claude routine |
| 2026-04-24 | pydantic-ai 1.86.1 | Version bumped 1.85.1 → 1.86.1; “What’s new” updated for v1.86.x (Capabilities API, Hooks, ModelProfile, UI module); Capabilities API section added to comprehensive guide with verified snippets. | Claude routine |
| 2026-04-22 | pydantic-ai 1.85.1 | Added 7 new deep-dive pages, all verified against installed 1.85.1 source: Output types & validators (ToolOutput / NativeOutput / PromptedOutput / TextOutput / StructuredDict + output_validator), Message history (ModelMessagesTypeAdapter, HistoryProcessor, capture_run_messages), Testing (TestModel, FunctionModel, Agent.override), Model providers & fallback (every prefix in providers/__init__.py, FallbackModel with custom handlers, gateway), Streaming (run_stream, run_stream_events, iter, AgentStream), Toolsets (FunctionToolset, Combined/Prefixed/Filtered/Prepared/Approval/Deferred/External), Built-in tools (WebSearch, WebFetch, CodeExecution, ImageGeneration, FileSearch, Memory, MCPServer, XSearch). Index re-ordered into an 18-step Zero → Hero reading order; Jump-to-topic and Reference grids re-indexed. | Claude routine |
| 2026-04-22 | pydantic-ai 1.85.1 | Version bumped 1.85.0 → 1.85.1; “What’s new” section updated for v1.85.x (8 built-in tools, embeddings API, AG UI adapter, ApprovalRequiredToolset HITL, DeferredLoadingToolset); fabricated pydantic_ai.common_tools imports replaced with correct pydantic_ai.builtin_tools API; UrlContextTool deprecation noted. Snippets verified against installed 1.85.1. | Claude routine |
| 2026-04-21 | pydantic-ai 1.84.1 | Index redesigned with Zero → Hero + Jump-to-topic grid. | — |
| 2026-04-18 | pydantic-ai 1.84.1 | Patch; bug fixes. | — |
| 2026-04-17 | pydantic-ai 1.84.0 | Evals framework; graph support improvements. | — |
| November 2025 | pydantic-ai 1.14.x | Initial 2025 guide with durable execution, graphs, integrations. | — |