# PydanticAI

> Canonical: https://skillalmanac.com/glossary/pydantic-ai | Last verified: 2026-11-24 | Index status: not offered to search engines

PydanticAI is an open-source Python library from the Pydantic team for building AI agents. It describes itself as a typed agent loop that can switch between model providers by changing a string, and it validates tool arguments and outputs.

Also called: Pydantic AI, pydantic ai agent, pydantic agents, Pydantic AI framework.

## In plain language

PydanticAI is a toolkit for programmers who want to write an AI agent in Python. An agent here is a program that asks a language model what to do, runs the tools the model picks, and repeats until the job is done. The toolkit handles that loop and checks that the data going in and out has the shape you declared, for example that a field meant to hold a number really holds one. It is code, not an app: you need to write Python to use it. It does not make a model more accurate, and a validated answer can still be wrong. An agent that can call tools can change real systems, so test it on sample data first.

## Technical definition

PydanticAI is a Python library whose documentation describes a typed, extensible agent loop. An agent is configured with a model named by a string, instructions, tools, and an output type; tool arguments are validated before your code runs, and structured outputs are validated against the declared type. The docs list dependency injection, fallback models, capabilities that bundle tools, instructions and hooks, durable execution through engines such as Temporal, DBOS and Prefect, OpenTelemetry-based observability, and Pydantic Evals and Pydantic Graph as companion pieces. The GitHub repository lists an MIT licence.

## How it shows up when you use agents

PydanticAI sits in the code you write, not in your coding tool. A developer uses it to build an agent that a product or script runs, and a coding agent such as Claude Code may help write that code. The library belongs to the family of [AI agent frameworks](/glossary/ai-agent-framework): it supplies the loop, and you supply instructions, tools and an output type. Its tools use the same idea as [tool calling](/glossary/tool-calling), and its docs say arguments are validated before your code runs. The README also says the same agent can run behind a web frontend, in a terminal or on a background queue.

What breaks when it is misunderstood: people read "typed" and "validated" as "correct". Validation checks shape, such as a number where a number is expected. It does not check that the content is true, so a [hallucination](/glossary/hallucination) can pass. Another trap is treating a string model name as permanent: the docs describe swapping providers, but prompts that work on one model may need retesting on another.

A next action: read the [How to Build an AI Agent](/learn/build-an-ai-agent) guide to see the bare loop, then decide whether you need a library. Run the first version on sample data, log every tool call, and keep a person approving any step that sends or deletes something.

## Common confusions

- **Pydantic versus PydanticAI.** Pydantic is a Python data validation library. PydanticAI is a separate library, built by the same team, for agents.
- **Framework versus model.** PydanticAI calls models from other providers. It is not a model and does not include one.
- **Validated versus true.** A reply that matches the declared type has the right shape. Its facts still need checking.
- **Myth.** A framework makes an agent safe. Safety depends on which tools the agent can reach and who approves its actions.

## Worked examples in this catalogue

### [How to Build an AI Agent: A Minimal Tool Loop](https://skillalmanac.com/learn/build-an-ai-agent)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: A minimal AI agent built in Python as a tool-use loop, with a check that it works and notes on where it breaks.

Why it exercises the concept: It shows by hand the loop that a library such as PydanticAI packages: the model asks for a tool, code runs it, the result goes back to the model.

### [llm-json-output-validator](https://skillalmanac.com/skills/skill-almanac/llm-json-output-validator)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: A validator that checks LLM replies against a JSON Schema subset and tallies failures by class and field.

Why it exercises the concept: PydanticAI validates model output against a declared type. This skill checks the same kind of promise with a different tool, so it is adjacent, and it does not use PydanticAI.

### [Open-source AI agents: criteria for comparing them](https://skillalmanac.com/learn/open-source-ai-agents-what-to-compare)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: A checklist of what to compare before adopting an open-source AI agent project.

Why it exercises the concept: PydanticAI is an open-source project, so the same questions about maintenance, licence and fit apply before you build on it.

## Related terms

- [AI agent framework](https://skillalmanac.com/glossary/ai-agent-framework.md)
- [AI agent](https://skillalmanac.com/glossary/ai-agent.md)
- [Tool calling (function calling)](https://skillalmanac.com/glossary/tool-calling.md)
- [Model Context Protocol (MCP)](https://skillalmanac.com/glossary/model-context-protocol.md)
- [Agent harness](https://skillalmanac.com/glossary/agent-harness.md)
- [AI observability (LLM observability)](https://skillalmanac.com/glossary/observability.md)

## Sources

- [Pydantic AI overview](https://pydantic.dev/docs/ai/overview/), Pydantic (accessed 2026-11-24)
- [pydantic/pydantic-ai (README)](https://github.com/pydantic/pydantic-ai), GitHub (Pydantic) (accessed 2026-11-24)
- [What are AI agents?](https://www.ibm.com/think/topics/ai-agents), IBM (accessed 2026-11-24)

Definitions are written by Skill Almanac from the sources above and checked against them on 2026-11-24. [Glossary index](https://skillalmanac.com/glossary.md).
