Pydantic AI

Typed Python agent framework from the Pydantic team for building AI agents with structured outputs across any model provider.

Works with AI agents:llms.txt
Ask your AI about this, with this page as the source:ChatGPT ↗Claude ↗Perplexity ↗

Pydantic AI is an open-source Python agent framework from the team behind the Pydantic validation library. It brings the same type-checked style to LLM code: tool arguments and agent outputs are defined as typed Python and validated, instead of parsed out of model text by hand.

You create an Agent with a model string such as anthropic:<model> or openai:<model>, instructions, tools (decorated Python functions whose signatures become the tool schema), and an output type, often a Pydantic model. Dependency injection passes typed services such as a database connection into tools and instructions, and lets tests swap them out. You run an agent with run, run_sync or streaming. It needs Python 3.10 or later, and pydantic-ai-slim installs only the provider extras you use.

Switching providers is a string change across OpenAI, Anthropic, Google, Bedrock, Vertex, Azure, OpenAI-compatible services and local servers. Instrumentation emits standard OpenTelemetry, so traces go to Pydantic Logfire or any OTLP backend. Durable execution integrates with Temporal, DBOS, Prefect and Restate so a run survives crashes, adapters stream to frontends built on the Vercel AI SDK or AG-UI, and TestModel lets unit tests run without real model calls. It runs in your own process; the optional Pydantic AI Gateway is hosted or self-hosted.

It is Python only. It deliberately leaves storage to you: saving a conversation means serializing the message history into your own database. Cross-conversation memory, guardrails and coding-agent tools sit in a separate Pydantic AI Harness package.

Where it fits

How Pydantic AI itself is built

5 tools, from its own code, website and Product Hunt page.

Who uses it

No maker's live product on record yet, and 35 open-source projects that declare it in their code.

We haven't found a maker's live product that uses Pydantic AI yet — only the open-source projects below, which declare it in their code.

blueking-paas蓝鲸智云 PaaS 平台是一个开放式的开发平台,让开发者可以方便快捷地创建、开发、部署和管理 SaaS 应用。它提供了完善的前后台开发框架、服务总线(ESB)、API Gate…AI SDK & Agent FrameworkIn its code · source ↗

Open source: a project that declares Pydantic AI as a dependency in its public code — verifiable, but not necessarily a live product.

Loved and watch-outs

Themes that recur in makers' words and Hacker News comments, each linked to what it summarises.

Most loved
  • Handles the agent and tool-calling loop for you and makes switching between model providers easy. HNHN 2HN 3HN 4
  • Lighter and less abstracted than LangChain or Google ADK, and familiar to anyone already using Pydantic. HNHN 2HN 3
  • Durable execution through DBOS or Temporal and OpenTelemetry-based observability are supported. HNHN 2HN 3
  • Capabilities and hooks make it a solid base for other libraries and custom harnesses. HNHN 2HN 3HN 4

Reliability and open issues

Most wanted on GitHubOpen on 2026-10-04 in pydantic/pydantic-ai, with activity in the last year — issues and feature requests by 👍.

Alternatives to Pydantic AI

All alternatives by situation →

Questions makers ask about Pydantic AI

Which model providers does it support?

You pick a provider with a <provider>:<model> string: OpenAI, Anthropic, Google, AWS Bedrock, Vertex AI, Azure and others, plus OpenAI-compatible services and local model servers. Each has a setup guide covering its options. source ↗

Do I have to use Logfire for observability?

No. Instrumentation emits standard OpenTelemetry spans for every model and tool call, and any OTLP backend works. Logfire is the easiest option, not a requirement. source ↗

How do I save a chat and continue it later?

Serialize the message history to JSON with ModelMessagesTypeAdapter and store it in your own database, for example in a jsonb column. The framework leaves the schema to you. source ↗

Can a run survive a crash or restart?

Yes, with durable execution. Integrations are co-maintained for Temporal, DBOS, Prefect, Restate and AWS Lambda, and a builder lets you connect another engine. source ↗

Can I use it behind a frontend built with the Vercel AI SDK?

Yes. VercelAIAdapter speaks the AI SDK data stream protocol that useChat expects; with FastAPI or another Starlette app, one call handles the request and streams the response. source ↗

How do I test agents without calling an LLM?

Swap in TestModel or FunctionModel with Agent.override, and set ALLOW_MODEL_REQUESTS=False so tests can't hit a real model by accident. source ↗

Which Python versions are supported?

Python 3.10 and later. The pydantic-ai-slim package lets you install only the extras for the providers you use. source ↗

Is Pydantic AI free?

Yes — it is free, open-source software.

Is Pydantic AI open source or self-hostable?

Open source, and you can self-host it. source ↗

Can AI coding agents work with Pydantic AI?

It serves an llms.txt docs index.

Who uses Pydantic AI?

No maker's live product we track yet; 35 open-source projects declare it in their code. source ↗