pydantic-ai 1.75.0


pip install pydantic-ai

  Latest version

Released: Apr 01, 2026


Meta
Author: Samuel Colvin, Marcelo Trylesinski, David Montague, Alex Hall, Douwe Maan
Requires Python: >=3.10

Classifiers

Development Status
  • 5 - Production/Stable

Framework
  • Pydantic
  • Pydantic :: 2

Intended Audience
  • Developers
  • Information Technology

Operating System
  • OS Independent

Programming Language
  • Python
  • Python :: 3
  • Python :: 3 :: Only
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13
  • Python :: 3.14

Topic
  • Internet
  • Scientific/Engineering :: Artificial Intelligence
  • Software Development :: Libraries :: Python Modules

GenAI Agent Framework, the Pydantic way

CI Coverage PyPI versions license Join Slack

Documentation: ai.pydantic.dev


Pydantic AI is a Python agent framework designed to help you quickly, confidently, and painlessly build production grade applications and workflows with Generative AI.

FastAPI revolutionized web development by offering an innovative and ergonomic design, built on the foundation of Pydantic Validation and modern Python features like type hints.

Yet despite virtually every Python agent framework and LLM library using Pydantic Validation, when we began to use LLMs in Pydantic Logfire, we couldn't find anything that gave us the same feeling.

We built Pydantic AI with one simple aim: to bring that FastAPI feeling to GenAI app and agent development.

Why use Pydantic AI

  1. Built by the Pydantic Team: Pydantic Validation is the validation layer of the OpenAI SDK, the Google ADK, the Anthropic SDK, LangChain, LlamaIndex, AutoGPT, Transformers, CrewAI, Instructor and many more. Why use the derivative when you can go straight to the source? :smiley:

  2. Model-agnostic: Supports virtually every model and provider: OpenAI, Anthropic, Gemini, DeepSeek, Grok, Cohere, Mistral, and Perplexity; Azure AI Foundry, Amazon Bedrock, Google Vertex AI, Ollama, LiteLLM, Groq, OpenRouter, Together AI, Fireworks AI, Cerebras, Hugging Face, GitHub, Heroku, Vercel, Nebius, OVHcloud, Alibaba Cloud, SambaNova, and Outlines. If your favorite model or provider is not listed, you can easily implement a custom model.

  3. Seamless Observability: Tightly integrates with Pydantic Logfire, our general-purpose OpenTelemetry observability platform, for real-time debugging, evals-based performance monitoring, and behavior, tracing, and cost tracking. If you already have an observability platform that supports OTel, you can use that too.

  4. Fully Type-safe: Designed to give your IDE or AI coding agent as much context as possible for auto-completion and type checking, moving entire classes of errors from runtime to write-time for a bit of that Rust "if it compiles, it works" feel.

  5. Powerful Evals: Enables you to systematically test and evaluate the performance and accuracy of the agentic systems you build, and monitor the performance over time in Pydantic Logfire.

  6. Extensible by Design: Build agents from composable capabilities that bundle tools, hooks, instructions, and model settings into reusable units. Use built-in capabilities for web search, thinking, and MCP, build your own, or install third-party capability packages. Define agents entirely in YAML/JSON — no code required.

  7. MCP, A2A, and UI: Integrates the Model Context Protocol, Agent2Agent, and various UI event stream standards to give your agent access to external tools and data, let it interoperate with other agents, and build interactive applications with streaming event-based communication.

  8. Human-in-the-Loop Tool Approval: Easily lets you flag that certain tool calls require approval before they can proceed, possibly depending on tool call arguments, conversation history, or user preferences.

  9. Durable Execution: Enables you to build durable agents that can preserve their progress across transient API failures and application errors or restarts, and handle long-running, asynchronous, and human-in-the-loop workflows with production-grade reliability.

  10. Streamed Outputs: Provides the ability to stream structured output continuously, with immediate validation, ensuring real time access to generated data.

  11. Graph Support: Provides a powerful way to define graphs using type hints, for use in complex applications where standard control flow can degrade to spaghetti code.

Realistically though, no list is going to be as convincing as giving it a try and seeing how it makes you feel!

Hello World Example

Here's a minimal example of Pydantic AI:

from pydantic_ai import Agent

# Define a very simple agent including the model to use, you can also set the model when running the agent.
agent = Agent(
    'anthropic:claude-sonnet-4-6',
    # Register static instructions using a keyword argument to the agent.
    # For more complex dynamically-generated instructions, see the example below.
    instructions='Be concise, reply with one sentence.',
)

# Run the agent synchronously, conducting a conversation with the LLM.
result = agent.run_sync('Where does "hello world" come from?')
print(result.output)
"""
The first known use of "hello, world" was in a 1974 textbook about the C programming language.
"""

(This example is complete, it can be run "as is", assuming you've installed the pydantic_ai package)

The exchange will be very short: Pydantic AI will send the instructions and the user prompt to the LLM, and the model will return a text response.

Not very interesting yet, but we can easily add tools, dynamic instructions, structured outputs, or composable capabilities to build more powerful agents.

Here's the same agent with thinking and web search capabilities:

from pydantic_ai import Agent
from pydantic_ai.capabilities import Thinking, WebSearch

agent = Agent(
    'anthropic:claude-sonnet-4-6',
    instructions='Be concise, reply with one sentence.',
    capabilities=[Thinking(), WebSearch()],
)

result = agent.run_sync('What was the mass of the largest meteorite found this year?')
print(result.output)

Tools & Dependency Injection Example

Here is a concise example using Pydantic AI to build a support agent for a bank:

(Better documented example in the docs)

from dataclasses import dataclass

from pydantic import BaseModel, Field
from pydantic_ai import Agent, RunContext

from bank_database import DatabaseConn


# SupportDependencies is used to pass data, connections, and logic into the model that will be needed when running
# instructions and tool functions. Dependency injection provides a type-safe way to customise the behavior of your agents.
@dataclass
class SupportDependencies:
    customer_id: int
    db: DatabaseConn


# This Pydantic model defines the structure of the output returned by the agent.
class SupportOutput(BaseModel):
    support_advice: str = Field(description='Advice returned to the customer')
    block_card: bool = Field(description="Whether to block the customer's card")
    risk: int = Field(description='Risk level of query', ge=0, le=10)


# This agent will act as first-tier support in a bank.
# Agents are generic in the type of dependencies they accept and the type of output they return.
# In this case, the support agent has type `Agent[SupportDependencies, SupportOutput]`.
support_agent = Agent(
    'openai:gpt-5.2',
    deps_type=SupportDependencies,
    # The response from the agent will, be guaranteed to be a SupportOutput,
    # if validation fails the agent is prompted to try again.
    output_type=SupportOutput,
    instructions=(
        'You are a support agent in our bank, give the '
        'customer support and judge the risk level of their query.'
    ),
)


# Dynamic instructions can make use of dependency injection.
# Dependencies are carried via the `RunContext` argument, which is parameterized with the `deps_type` from above.
# If the type annotation here is wrong, static type checkers will catch it.
@support_agent.instructions
async def add_customer_name(ctx: RunContext[SupportDependencies]) -> str:
    customer_name = await ctx.deps.db.customer_name(id=ctx.deps.customer_id)
    return f"The customer's name is {customer_name!r}"


# The `tool` decorator let you register functions which the LLM may call while responding to a user.
# Again, dependencies are carried via `RunContext`, any other arguments become the tool schema passed to the LLM.
# Pydantic is used to validate these arguments, and errors are passed back to the LLM so it can retry.
@support_agent.tool
async def customer_balance(
        ctx: RunContext[SupportDependencies], include_pending: bool
) -> float:
    """Returns the customer's current account balance."""
    # The docstring of a tool is also passed to the LLM as the description of the tool.
    # Parameter descriptions are extracted from the docstring and added to the parameter schema sent to the LLM.
    balance = await ctx.deps.db.customer_balance(
        id=ctx.deps.customer_id,
        include_pending=include_pending,
    )
    return balance


...  # In a real use case, you'd add more tools and a longer system prompt


async def main():
    deps = SupportDependencies(customer_id=123, db=DatabaseConn())
    # Run the agent asynchronously, conducting a conversation with the LLM until a final response is reached.
    # Even in this fairly simple case, the agent will exchange multiple messages with the LLM as tools are called to retrieve an output.
    result = await support_agent.run('What is my balance?', deps=deps)
    # The `result.output` will be validated with Pydantic to guarantee it is a `SupportOutput`. Since the agent is generic,
    # it'll also be typed as a `SupportOutput` to aid with static type checking.
    print(result.output)
    """
    support_advice='Hello John, your current account balance, including pending transactions, is $123.45.' block_card=False risk=1
    """

    result = await support_agent.run('I just lost my card!', deps=deps)
    print(result.output)
    """
    support_advice="I'm sorry to hear that, John. We are temporarily blocking your card to prevent unauthorized transactions." block_card=True risk=8
    """

Next Steps

To try Pydantic AI for yourself, install it and follow the instructions in the examples.

Read the docs to learn more about building applications with Pydantic AI.

Read the API Reference to understand Pydantic AI's interface.

Join Slack or file an issue on GitHub if you have any questions.

1.75.0 Apr 01, 2026
1.74.0 Mar 31, 2026
1.73.0 Mar 27, 2026
1.72.0 Mar 26, 2026
1.71.0 Mar 24, 2026
1.70.0 Mar 18, 2026
1.69.0 Mar 17, 2026
1.68.0 Mar 13, 2026
1.67.0 Mar 06, 2026
1.66.0 Mar 05, 2026
1.65.0 Mar 03, 2026
1.64.0 Mar 02, 2026
1.63.0 Feb 23, 2026
1.62.0 Feb 19, 2026
1.61.0 Feb 18, 2026
1.60.0 Feb 17, 2026
1.59.0 Feb 14, 2026
1.58.0 Feb 11, 2026
1.57.0 Feb 10, 2026
1.56.0 Feb 06, 2026
1.55.0 Feb 05, 2026
1.54.0 Feb 04, 2026
1.53.0 Feb 04, 2026
1.52.0 Feb 03, 2026
1.51.0 Jan 31, 2026
1.50.0 Jan 30, 2026
1.49.0 Jan 29, 2026
1.48.0 Jan 28, 2026
1.47.0 Jan 24, 2026
1.46.0 Jan 23, 2026
1.44.0 Jan 17, 2026
1.43.0 Jan 16, 2026
1.42.0 Jan 14, 2026
1.41.0 Jan 10, 2026
1.40.0 Jan 07, 2026
1.39.1 Jan 06, 2026
1.39.0 Dec 24, 2025
1.38.0 Dec 23, 2025
1.37.0 Dec 20, 2025
1.36.0 Dec 19, 2025
1.35.0 Dec 18, 2025
1.34.0 Dec 17, 2025
1.33.0 Dec 16, 2025
1.32.0 Dec 13, 2025
1.31.0 Dec 12, 2025
1.30.1 Dec 11, 2025
1.30.0 Dec 11, 2025
1.29.0 Dec 10, 2025
1.28.0 Dec 09, 2025
1.27.0 Dec 05, 2025
1.26.0 Dec 03, 2025
1.25.1 Nov 28, 2025
1.25.0 Nov 28, 2025
1.24.0 Nov 27, 2025
1.23.0 Nov 26, 2025
1.22.0 Nov 22, 2025
1.21.0 Nov 21, 2025
1.20.0 Nov 19, 2025
1.19.0 Nov 18, 2025
1.18.0 Nov 15, 2025
1.17.0 Nov 14, 2025
1.16.0 Nov 13, 2025
1.15.0 Nov 13, 2025
1.14.1 Nov 12, 2025
1.14.0 Nov 10, 2025
1.13.0 Nov 10, 2025
1.12.0 Nov 07, 2025
1.11.1 Nov 06, 2025
1.11.0 Nov 05, 2025
1.10.0 Nov 04, 2025
1.9.1 Oct 31, 2025
1.9.0 Oct 29, 2025
1.8.0 Oct 29, 2025
1.7.0 Oct 28, 2025
1.6.0 Oct 24, 2025
1.5.0 Oct 24, 2025
1.4.0 Oct 24, 2025
1.3.0 Oct 23, 2025
1.2.1 Oct 20, 2025
1.2.0 Oct 20, 2025
1.1.0 Oct 15, 2025
1.0.18 Oct 13, 2025
1.0.17 Oct 09, 2025
1.0.16 Oct 08, 2025
1.0.15 Oct 03, 2025
1.0.14 Oct 03, 2025
1.0.13 Oct 02, 2025
1.0.12 Oct 01, 2025
1.0.11 Sep 30, 2025
1.0.10 Sep 20, 2025
1.0.9 Sep 18, 2025
1.0.8 Sep 17, 2025
1.0.7 Sep 15, 2025
1.0.6 Sep 12, 2025
1.0.5 Sep 12, 2025
1.0.4 Sep 11, 2025
1.0.3 Sep 11, 2025
1.0.2 Sep 09, 2025
1.0.1 Sep 05, 2025
1.0.0 Sep 05, 2025
1.0.0b1 Aug 30, 2025
0.8.1 Aug 29, 2025
0.8.0 Aug 26, 2025
0.7.6 Aug 26, 2025
0.7.5 Aug 25, 2025
0.7.4 Aug 20, 2025
0.7.3 Aug 19, 2025
0.7.2 Aug 14, 2025
0.7.1 Aug 13, 2025
0.7.0 Aug 12, 2025
0.6.2 Aug 07, 2025
0.6.1 Aug 07, 2025
0.6.0 Aug 06, 2025
0.5.1 Aug 06, 2025
0.5.0 Aug 04, 2025
0.4.11 Aug 02, 2025
0.4.10 Jul 30, 2025
0.4.9 Jul 28, 2025
0.4.8 Jul 28, 2025
0.4.7 Jul 24, 2025
0.4.6 Jul 23, 2025
0.4.5 Jul 22, 2025
0.4.4 Jul 18, 2025
0.4.3 Jul 16, 2025
0.4.2 Jul 10, 2025
0.4.1 Jul 10, 2025
0.4.0 Jul 08, 2025
0.3.7 Jul 07, 2025
0.3.6 Jul 04, 2025
0.3.5 Jun 30, 2025
0.3.4 Jun 26, 2025
0.3.3 Jun 24, 2025
0.3.2 Jun 21, 2025
0.3.1 Jun 18, 2025
0.3.0 Jun 18, 2025
0.2.20 Jun 18, 2025
0.2.19 Jun 17, 2025
0.2.18 Jun 13, 2025
0.2.17 Jun 12, 2025
0.2.16 Jun 08, 2025
0.2.15 Jun 05, 2025
0.2.14 Jun 03, 2025
0.2.13 Jun 03, 2025
0.2.12 May 29, 2025
0.2.11 May 28, 2025
0.2.10 May 27, 2025
0.2.9 May 26, 2025
0.2.8 May 25, 2025
0.2.7 May 24, 2025
0.2.6 May 21, 2025
0.2.5 May 20, 2025
0.2.4 May 14, 2025
0.2.3 May 13, 2025
0.2.2 May 13, 2025
0.2.1 May 13, 2025
0.2.0 May 12, 2025
0.1.12 May 12, 2025
0.1.11 May 10, 2025
0.1.10 May 06, 2025
0.1.9 May 02, 2025
0.1.8 Apr 28, 2025
0.1.7 Apr 28, 2025
0.1.6 Apr 25, 2025
0.1.5 Apr 25, 2025
0.1.4 Apr 24, 2025
0.1.3 Apr 18, 2025
0.1.2 Apr 17, 2025
0.1.1 Apr 16, 2025
0.1.0 Apr 15, 2025
0.0.55 Apr 09, 2025
0.0.54 Apr 09, 2025
0.0.53 Apr 07, 2025
0.0.52 Apr 03, 2025
0.0.51 Apr 03, 2025
0.0.50 Apr 03, 2025
0.0.49 Apr 01, 2025
0.0.48 Mar 31, 2025
0.0.47 Mar 31, 2025
0.0.46 Mar 26, 2025
0.0.45 Mar 26, 2025
0.0.44 Mar 25, 2025
0.0.43 Mar 21, 2025
0.0.42 Mar 19, 2025
0.0.41 Mar 17, 2025
0.0.40 Mar 15, 2025
0.0.39 Mar 13, 2025
0.0.38 Mar 13, 2025
0.0.37 Mar 12, 2025
0.0.36 Mar 07, 2025
0.0.35 Mar 05, 2025
0.0.34 Mar 05, 2025
0.0.33 Mar 05, 2025
0.0.32 Mar 04, 2025
0.0.31 Mar 03, 2025
0.0.30 Feb 28, 2025
0.0.29 Feb 27, 2025
0.0.28 Feb 27, 2025
0.0.27 Feb 26, 2025
0.0.26 Feb 25, 2025
0.0.25 Feb 24, 2025
0.0.24 Feb 12, 2025
0.0.23 Feb 07, 2025
0.0.22 Feb 04, 2025
0.0.21 Jan 30, 2025
0.0.20 Jan 24, 2025
0.0.19 Jan 15, 2025
0.0.18 Jan 07, 2025
0.0.17 Jan 03, 2025
0.0.16 Dec 30, 2024
0.0.15 Dec 23, 2024
0.0.14 Dec 19, 2024
0.0.13 Dec 16, 2024
0.0.12 Dec 09, 2024
0.0.11 Dec 06, 2024
0.0.10 Dec 06, 2024
0.0.9 Dec 04, 2024
0.0.8 Dec 02, 2024
0.0.7 Nov 29, 2024
0.0.6 Nov 25, 2024
0.0.6a4 Nov 25, 2024
0.0.6a3 Nov 25, 2024
0.0.6a2 Nov 25, 2024
0.0.6a1 Nov 25, 2024
0.0.5 Nov 20, 2024
0.0.4 Nov 19, 2024
0.0.3 Nov 19, 2024
0.0.2 Oct 30, 2024
0.0.1 Oct 29, 2024
0.0.0 May 20, 2024

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras:
Dependencies:
pydantic-ai-slim[bedrock,cli,evals,fastmcp,anthropic,logfire,google,cohere,mistral,ui,xai,huggingface,ag-ui,groq,temporal,mcp,spec,openai,vertexai,retries] (==1.75.0)