# Pydantic AI

> A Python kit for agents. It gives back answers as checked, typed data.

**Field:** Software Development  
**Category:** AI Engineering  
**Also known as:** PydanticAI, pydantic-ai

## Think of it like

It is like a form with boxes. The answer must fit each box, or it goes back.

## Definition

Pydantic AI is a Python agent framework from the team behind Pydantic. Pydantic is a well-known library that checks data. You make an agent from a model name, and changing providers means changing that name. You can ask for the answer as a typed Pydantic model. Pydantic then checks it, so the run gives back that type or fails clearly. It also has a test model that runs with no real AI.

## Example

Emma needs each invoice's date, total and seller as fields. She sets the output type to an Invoice model, so bad data fails at once instead of later.

## Example code

```python
from pydantic_ai import Agent

agent = Agent("openai:gpt-6.1-sol")
result = agent.run_sync("Say hello.")
print(result.output)
```

The model is a name with the provider first. result.output holds the answer.

## Why it matters

Apps need data they can trust, not loose text. Typed output catches a wrong shape at the edge of your code.

## Common mistake

Trusting a typed answer to be a true answer. Pydantic checks the shape of the data, not whether the facts in it are right.

## Three principles

- **Typed output.** Answers fit a Pydantic model.
- **Model as a name.** Provider and model in one string.
- **A test model.** Runs without a real AI.

## Related terms

- [LLM Framework](https://learn.benibix.com/term/development/llm-framework)
- [Structured Output (LLM)](https://learn.benibix.com/term/ai/structured-output)
- [JSON Schema](https://learn.benibix.com/term/development/json-schema)
- [FastAPI](https://learn.benibix.com/term/development/fastapi)
- [Python](https://learn.benibix.com/term/development/python)
- [OpenAI Agents SDK](https://learn.benibix.com/term/development/openai-agents-sdk)
- [DSPy](https://learn.benibix.com/term/development/dspy)

![A table of five frameworks, with columns for framework, language and what each is built around. Vercel AI SDK, TypeScript, streaming chat screens. OpenAI Agents SDK, Python and TypeScript, agents handing work to each other. CrewAI, Python, a crew of agents, each with a role. Pydantic AI, Python, answers as typed, checked data. DSPy, Python, tuning prompts from examples. A strip along the bottom says all of them call model APIs underneath.](https://learn.benibix.com/diagrams/dev6-agent-frameworks.svg)

---

Source: https://learn.benibix.com/term/development/pydantic-ai
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-20
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
