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

v1.90.0 · May 2026 · Python 3.10+

Best for

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

  • v1.90.0 (May 5) — Patch release; maintenance and dependency updates. DeferredToolCalls class in pydantic_ai.output marked @deprecated — use DeferredToolRequests (already the recommended API since v1.87.x).
  • v1.89.1 (May 2) — Patch release; maintenance and dependency updates.
  • v1.89.0 (May 1) — Patch release; maintenance and dependency updates.
  • v1.88.0 (April 29) — Patch release; maintenance and dependency updates.
  • v1.87.0 — Expanded Capabilities API — 9 new capability classes added to 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.
  • Prior (v1.86.x): capabilities parameter on Agent; Hooks with decorator registration; ModelProfile/DEFAULT_PROFILE; pydantic_ai.ui module (UIAdapter, UIEventStream, MessagesBuilder).
  • Prior (v1.85.x): 8 built-in tools, embeddings API, AG UI adapter, ApprovalRequiredToolset HITL, DeferredLoadingToolset. UrlContextTool deprecated — use WebFetchTool.
  • Prior (v1.84.x): durable execution, graph support, evals framework, Logfire/OpenTelemetry.
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 →


DateFramework version (installed)Summary of changesReviewer
2026-05-05pydantic-ai 1.90.0Version 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-02pydantic-ai 1.89.1Version 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-01pydantic-ai 1.89.0Version 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-29pydantic-ai 1.88.0Version 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-25pydantic-ai 1.87.0Version 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-24pydantic-ai 1.86.1Version 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-22pydantic-ai 1.85.1Added 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-22pydantic-ai 1.85.1Version 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-21pydantic-ai 1.84.1Index redesigned with Zero → Hero + Jump-to-topic grid.
2026-04-18pydantic-ai 1.84.1Patch; bug fixes.
2026-04-17pydantic-ai 1.84.0Evals framework; graph support improvements.
November 2025pydantic-ai 1.14.xInitial 2025 guide with durable execution, graphs, integrations.