← Back to all projects

Pydantic AI
Type-safe agents from the team behind Pydantic
OfficialMIT
What is Pydantic AI?
Brings the validation model that Python developers already trust to agent output, so a malformed response fails where you can see it rather than three layers downstream. Deliberately smaller in scope than the all-in-one frameworks; that is the point, and it is a good fit if your codebase is already typed throughout.
What can you do with Pydantic AI?
- Get a validated object back — Declaring
output_type=Sentimenton anAgentmakes every run return that Pydantic model, and a@agent.toolfunction's signature and docstring become the tool schema, so its arguments are validated before your code runs. - Swap models with a string — The model is an identifier like
openai:gpt-5.6-sol, covering OpenAI, Anthropic, Google, Bedrock, Groq, Mistral, xAI and Ollama; routing through the Pydantic AI Gateway instead puts one key, failover and cost tracking in front of all of them. - Reuse one agent across interfaces —
agent.to_cli_sync()drops the same definition into the terminal,agent.realtime(...).session()puts it on a live voice call with its tools intact, and AG-UI or Vercel AI event streams wire it to your own frontend. - Survive restarts on long runs — Adding
TemporalDurability()turns every model and tool call into a Temporal activity, so a queued run continues across restarts and long waits; DBOS and Prefect attach the same way. - Bundle tools into capabilities — A
Capabilitygroups tools, instructions, hooks and model settings into one reusable unit —MCP(url)andWebSearch()ship in core — anddefer_loading=Trueholds a bundle back until the model loads it mid-conversation.
Star history
15 Aug to 30 Oct · +1.6k
19.3k21k
Frequently asked questions
Is Pydantic AI free for commercial use?
Pydantic AI is released under the MIT licence — OSI-approved open source, which permits commercial use.
How can Pydantic AI be deployed?
Pydantic AI is available as Self-hosted / Runs locally.