← all repositories
pydantic/pydantic-ai

FastAPI’s cousin enters the agent fray

The Pydantic team built this agent framework because existing options didn’t feel ergonomic enough for their own LLM products.

18.7k stars Python AgentsApp Builders
pydantic-ai
Velocity · 7d
+26
★ / day
Trend
cooling
star history

What it does

Pydantic AI is a Python framework for orchestrating LLM agents. It wraps model calls in a strictly typed layer where outputs are validated by Pydantic, tools are registered via decorators, and dependencies are injected through generics like Agent[Deps, Output]. It supports a laundry list of providers—OpenAI, Anthropic, Gemini, Ollama, and many more—and can run agents defined entirely in YAML or JSON.

The interesting bit

The framework treats type hints as the primary API surface. Agents are generic over their dependencies and return types, so static analysis catches errors before runtime. It also bakes in durable execution, letting agents survive crashes and restarts without losing context—something still rare in lightweight agent libraries.

Key highlights

  • Generic Agent[Dependencies, Output] type means mypy and pyright understand your agent’s contract.
  • Validation failures on structured outputs are passed back to the LLM automatically for retry.
  • Composable “capabilities” bundle tools, hooks, and instructions into reusable units.
  • Supports MCP, A2A, and UI event streaming for interoperability with external tools and other agents.
  • Durable execution preserves progress across transient failures and application restarts.
  • Deep Logfire integration for tracing and evals, though standard OpenTelemetry backends work too.

Verdict

Worth evaluating if you want production-grade Python agents with compile-time guarantees on structured outputs. Probably overkill if you just need a thin wrapper around chat completions.

Frequently asked

What is pydantic/pydantic-ai?
The Pydantic team built this agent framework because existing options didn’t feel ergonomic enough for their own LLM products.
Is pydantic-ai open source?
Yes — pydantic/pydantic-ai is open source, released under the MIT license.
What language is pydantic-ai written in?
pydantic/pydantic-ai is primarily written in Python.
How popular is pydantic-ai?
pydantic/pydantic-ai has 18.7k stars on GitHub and is currently cooling off.
Where can I find pydantic-ai?
pydantic/pydantic-ai is on GitHub at https://github.com/pydantic/pydantic-ai.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.