Skip to content

PydanticAI

The 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

Terminal window
pip install pydantic-ai

Version

v2.43.0 · September 2026 · Python 3.10+ Each page carries its own “verified against” stamp: the newest deep dives are on 2.43.0, the class reference on 2.33.0, and some older topic pages still sit on the 1.10x line.

Best for

Typed APIs, structured output, validated data pipelines, evals-driven agents.

Condensed version history (superseded the previous per-volume changelog — full historical detail lives in git history and the Revision history table below).

VersionDateHighlight
1.14.xNov 2025Initial guide: durable execution, graphs, integrations
1.84.0–1.85.xApr 2026Evals framework, graph support; embeddings API; AG UI adapter; ApprovalRequiredToolset HITL; DeferredLoadingToolset; UrlContextTool deprecated
1.86.0–1.87.0Apr 2026Capabilities system introduced (Hooks, AbstractCapability, ModelProfile) and expanded with 9 more capability classes
1.88.0–1.96.0Apr–May 2026DeferredToolCalls deprecated → DeferredToolRequests; TestModel moved out of top-level; AgentRun/AgentRunResultEvent; ConcurrencyLimiter
1.98.0–1.99.0May 2026pydantic_ai.ag_ui deprecated → pydantic_ai.ui.ag_ui; common_tools module added
1.100.0–1.105.0May–Jun 2026Hooks, embeddings, AgentSpec, MCPToolset, UI adapters, native tool suite (WebSearch/WebFetch/CodeExecution/Memory), AgentStream, full FunctionToolset — first source-verified “class deep dive” reference material begins here
1.106.0–1.107.0Jun 2026Agent graph nodes promoted to public API; tool_timeout/max_concurrency; full Capabilities subsystem; Bedrock + expanded provider ecosystem; pydantic_graph GraphBuilder; SSRF-hardened safe_download
2.0.0Jun 2026Major version: Agent.to_web/to_cli/run_stream_events; ToolManager parallel execution modes; Temporal/DBOS/Prefect durable execution; NativeOrLocalTool capability family
2.2.0–2.5.1Jul 2026FallbackModel response handlers, Embedder, server-side compaction (AnthropicCompaction/OpenAICompaction), OnlineEvaluation, Z.AI/Vercel providers, pydantic_graph Path/PathBuilder, agentic evaluators
2.6.0–2.10.0Jul 2026Hooks+HookTimeoutError, MCP capability, built-in search capabilities (WebSearch/WebFetch/XSearch/ImageGeneration/Thinking), streaming event protocol, AgentSpec YAML/JSON
2.13.0–2.22.0Jul–Aug 2026Fine-grained AgentRun control, SelectModel/ResolveModelId routing, RaiseContentFilterError, MCP prefer_tasks durable calls, RunContext.is_tool_available
2.27.0Aug 2026RunUsage.cost + CancellationToken/RunCancelled; ReinjectSystemPrompt/ProcessHistory hardened for untrusted history
2.31.0Aug 2026AgentSpec YAML/JSON specs stabilised, SelectModel, native tool suite (Advisor/XSearch/ImageGeneration/WebFetch) complete
2.33.0Aug 2026Consolidated Class & API Reference added to the comprehensive guide — 44 sprawling deep-dive volumes folded into 16 organised sections; guide version currency refreshed end-to-end
2.36.0Aug 2026New 10-class deep-dive page (v2.36.0)AgentRun, AgentRunResult, StreamedRunResult, ModelSettings, Tool, ToolDefinition, RunUsage/RequestUsage, ConcurrencyLimiter/ConcurrencyLimit, MCPToolset, ApprovalRequiredToolset/DynamicToolset.
2.40.0Sep 2026New 10-class deep-dive page (v2.40.0)RealtimeSession, RealtimeModelSettings/TurnDetection, AgentRealtime, Capability, Hooks, TemplateStr, ExternalToolset, RetryConfig/HTTPX2TenacityTransport, DuckDuckGoSearchTool, ImageGenerationSubagentTool — all source-verified with runnable examples.
2.43.0Sep 2026Current. New 10-class deep-dive page (v2.43.0)ToolFailed, RunCancelled, ToolSelector, ToolOrOutput, ServiceTier/ThinkingLevel, AgentStream/StreamedRunResult, SkipModelRequest/SkipToolValidation/SkipToolExecution, ToolDefinition.sequential, OutputContext, ApprovalRequired/DeferredToolRequests — all source-verified with runnable examples.
from pydantic import BaseModel
from 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 →


Condensed — one row per meaningfully distinct change to this index/guide pairing. Full historical detail for every prior volume lives in git history.

DateFramework versionSummary
2026-09-14pydantic-ai 2.43.0Added pydantic_ai_class_deep_dives_v2_43.md — 10 source-verified deep dives for 2.43.0 (ToolFailed, RunCancelled, ToolSelector, ToolOrOutput, ServiceTier/ThinkingLevel, AgentStream/StreamedRunResult, SkipModelRequest/SkipToolValidation/SkipToolExecution, ToolDefinition.sequential, OutputContext, ApprovalRequired/DeferredToolRequests). Sources read: pydantic_ai/exceptions.py, pydantic_ai/tools.py, pydantic_ai/settings.py, pydantic_ai/result.py, pydantic_ai/output.py, pydantic_ai/tool_manager.py. Version bumped from 2.40.0 → 2.43.0. Comprehensive guide addendum and v2.40.0 cross-link added.
2026-09-07pydantic-ai 2.40.0Added pydantic_ai_class_deep_dives_v2_40.md — 10 source-verified deep dives for 2.40.0 (RealtimeSession, RealtimeModelSettings/TurnDetection, AgentRealtime, Capability, Hooks, TemplateStr, ExternalToolset, RetryConfig/HTTPX2TenacityTransport, DuckDuckGoSearchTool, ImageGenerationSubagentTool). Sources read: pydantic_ai/realtime/_session.py, pydantic_ai/realtime/settings.py, pydantic_ai/agent/abstract.py, pydantic_ai/capabilities/capability.py, pydantic_ai/capabilities/hooks.py, pydantic_ai/template.py, pydantic_ai/toolsets/external.py, pydantic_ai/retries.py, pydantic_ai/common_tools/duckduckgo.py, pydantic_ai/common_tools/image_generation.py. Version bumped from 2.36.0 → 2.40.0.
2026-08-31pydantic-ai 2.36.0Added pydantic_ai_class_deep_dives_v2_36.md — 10 more source-verified deep dives with runnable code examples (AgentRun, AgentRunResult, StreamedRunResult, ModelSettings, Tool, ToolDefinition, RunUsage/RequestUsage, ConcurrencyLimiter/ConcurrencyLimit, MCPToolset, ApprovalRequiredToolset/DynamicToolset). Linked from the Reference grid. Sources read: pydantic_ai/run.py, pydantic_ai/result.py, pydantic_ai/settings.py, pydantic_ai/tools.py, pydantic_ai/usage.py, pydantic_ai/concurrency.py, pydantic_ai/mcp.py, pydantic_ai/toolsets/{approval_required,_dynamic}.py. Version bumped from 2.33.0 → 2.36.0.
2026-08-24pydantic-ai 2.33.0Added pydantic_ai_class_examples_2026_08.md — 10 source-verified deep dives with runnable code examples (Agent, RunContext, UsageLimits, ToolReturn, DeferredToolRequests/Results, CachePoint, PrefixedToolset/FilteredToolset/RenamedToolset, WebSearchTool, FunctionToolset, ModelRetry/UnexpectedModelBehavior/ModelHTTPError). Linked from the Reference grid. Sources read: pydantic_ai/agent/__init__.py, _run_context.py, usage.py, messages.py, _deferred.py, toolsets/{function,filtered,renamed,prefixed}.py, native_tools/__init__.py, exceptions.py.
2026-08-21pydantic-ai 2.33.0Consolidated the 44 pydantic_ai_class_deep_dives*.md / pydantic_ai_advanced_classes_part2.md / pydantic_ai_source_code_deep_dive.md volumes into one Class & API Reference section (16 subsections) inside the comprehensive guide; deleted the 44 source files; replaced the 44 individual LinkCards and the per-volume “What’s new” narrative with the single reference link and condensed changelog above; version badge and guide banners bumped to 2.33.0.
2026-07-20pydantic-ai 2.13.0AgentRun/AgentRunResult/AgentRunResultEvent fine-grained control; FunctionModel/AgentInfo; FallbackModel/ResponseRejected; tenacity HTTP retry; FilteredToolset/DeferredLoadingToolset/ToolSearchToolset; WrapperModel/CompletedStreamedResponse; WrapperCapability; MessagesBuilder/BuilderCheckpoint.
2026-07-15pydantic-ai 2.10.0UsageLimits/RunUsage/RequestUsage fixes; AgentSpec YAML/JSON; cross-provider ModelSettings reference; ConcurrencyLimiter; output-mode toolkit; two-round HITL ApprovalRequiredToolset flow.
2026-07-08 to 2026-07-14pydantic-ai 2.6.0–2.9.1Hooks+HookTimeoutError; ProcessHistory/ReinjectSystemPrompt; ApprovalRequiredToolset/ExternalToolset; Vercel AI SDK v5/v6 + AG-UI HITL adapters; new provider profiles (harmony/moonshotai/amazon); built-in search capabilities (WebSearch/WebFetch/XSearch/ImageGeneration/Thinking); streaming event protocol; DynamicToolset.
2026-06-25 to 2026-07-09pydantic-ai 2.0.0–2.5.1Major v2.0.0: Agent.to_web/to_cli/run_stream_events; ToolManager parallel execution modes; Temporal/DBOS/Prefect durable execution; NativeOrLocalTool capability family. Then: toolset composition (FallbackModel, Embedder), server-side compaction, OnlineEvaluation, Z.AI/Vercel providers, pydantic_graph Path/PathBuilder, agentic evaluators.
2026-06-12 to 2026-06-21pydantic-ai 1.106.0–1.107.0Agent graph nodes (UserPromptNode/ModelRequestNode/CallToolsNode) promoted to public API; tool_timeout/max_concurrency; full Capabilities subsystem (Hooks, Instrumentation, MCP, ToolSearch); AWS Bedrock + expanded provider ecosystem (Alibaba/OVHcloud/Heroku/gateway); pydantic_graph GraphBuilder; SSRF-hardened safe_download.
2026-05-22 to 2026-06-05pydantic-ai 1.101.0–1.105.0Tool/ModelSettings/Hooks/Thinking/WebSearch deep dives begin (source-verified against installed package); MCPToolset, UI adapters, native tool suite, AgentStream, full FunctionToolset; builtin_tools= migrated to capabilities=[NativeTool(...)].
2026-05-01 to 2026-05-20pydantic-ai 1.89.0–1.99.0DeferredToolCalls deprecated → DeferredToolRequests; TestModel moved out of top-level; new exports AgentRun/AgentRunResultEvent/AgentEventStream; ConcurrencyLimiter + limit_model_concurrency; pydantic_ai.ag_ui deprecated in favour of pydantic_ai.ui.ag_ui; common_tools module added.
2026-04-17 to 2026-04-29pydantic-ai 1.83.0–1.88.0Hard removal of result_*output_* renames; EvaluationReport API; pydantic-graph branching/looping; defer_loading; ThreadExecutor; OllamaModel; Capabilities API introduced and expanded (9 new capability classes).
2026-04-21 to 2026-04-22pydantic-ai 1.84.1–1.85.1Embeddings API; AG UI adapter; ApprovalRequiredToolset HITL; DeferredLoadingToolset; UrlContextTool deprecated; index redesigned with Zero → Hero + Jump-to-topic grid.
2025-11pydantic-ai 1.14.xInitial 2025 guide with durable execution, graphs, integrations.