Pydantic AI
Pydantic AI is the Python AI SDK from the Pydantic team: a typed, extensible agent loop for building large language model (LLM) agents with Pydantic-validated inputs and outputs, structured output support, tool calling, and broad model provider support, where swapping the underlying model is a one-string change. Realtime voice, image generation, and embeddings ship in the same package.
The core abstraction is an agent that coordinates instructions, type-checked structured outputs, and function tools. Developers define tools from normal Python functions with type hints, and the framework includes a lightweight dependency injection system for passing runtime services such as HTTP clients or database connections into prompts, tools, and validators. Tools, instructions, hooks, and model settings can also be bundled into a reusable capability and attached to an agent, and the same agent definition runs behind a web frontend, in the terminal, on a voice call, on a durable background queue, or as a plain Python object.
The project integrates with Pydantic Logfire for OpenTelemetry-based tracing and monitoring, ships a companion Pydantic Evals package for code-first evaluation, and adds memory, sub-agents, and context management through a Pydantic AI Harness package. First-party durable execution on Temporal, DBOS, or Prefect, with integrations for Restate, Kitaru, and Airflow, keeps long-running agents alive across restarts. An optional Pydantic AI Gateway provides unified access to multiple model providers, real-time cost controls, and LLM observability while keeping each request in the provider’s native format.
Official website: pydantic.dev/docs/ai
Related Resources
Tutorial
Pydantic AI: Build Type-Safe LLM Agents in Python
Learn how to use Pydantic AI to build type-safe LLM agents in Python with structured outputs, function calling, and dependency injection patterns.
For additional information on related topics, take a look at the following resources: