Self-hosted personal AI agent framework in Python with a browser WebUI, terminal client, chat app channels, tools, memory and MCP support.
pydantic/pydantic-ai
Python AI SDK for building typed agents that run across models, web frontends, CLI, voice, and durable background workflows.
Open-source alternative to:LangChain
- Stars
- 20,750
- Forks
- 2,968
- Open issues
- 1,472
- Last commit
- 5 hours ago
What is it?
Pydantic AI is a Python SDK for building AI agents with typed inputs, outputs, and dependencies. Models from providers such as OpenAI, Anthropic, Google, and Groq can be swapped with a string change, and the same agent can be exposed through a CLI, a built-in web chat, realtime voice sessions, or UI event streams for frontend integration.
Agents can return validated structured output and call typed function tools that receive injected dependencies. The project also includes durable execution integrations for Temporal, DBOS, Prefect, and others, so long-running runs can survive restarts. Image generation and embeddings are available through the same package.
The ecosystem around it includes Pydantic AI Harness, a library of reusable capabilities such as memory, guardrails, sub-agents, and a complete coding agent; Pydantic Evals for grading outputs and tool-call trajectories; and Pydantic Graph for typed graph-based control flow. Instrumentation uses OpenTelemetry, so it works with any compatible backend.
Key features
- 01Swap between many model providers using a model string.
- 02Structured, validated outputs and typed function tools with dependency injection.
- 03Run the same agent as a CLI, web chat, realtime voice session, or UI event stream.
- 04Durable execution on engines such as Temporal, DBOS, and Prefect.
- 05OpenTelemetry-based instrumentation for tracing model and tool calls.
- 06Image generation and embeddings in the same package.
Use cases
- Building a typed data extraction pipeline that returns validated Pydantic models from LLM output.
- Creating a long-running research agent that must survive restarts via Temporal or DBOS.
- Adding a voice assistant that calls internal tools during a live conversation.
- Evaluating agent answers and tool-call behavior against a test dataset.
Quick start
- 1
Install the package with uv
uv add pydantic-ai - 2
Create a Python file with an Agent and call agent.run_sync(...) to get a typed result
Things to know
- Running the examples against hosted models requires that provider's API key, which the README does not explain in detail.
- Durable execution, realtime voice and other advanced features need extra installs and a separate backend such as Temporal.
Topics
FAQ
- What is pydantic-ai?
- Python AI SDK for building typed agents that run across models, web frontends, CLI, voice, and durable background workflows. Pydantic AI is a Python SDK for building AI agents with typed inputs, outputs, and dependencies. Models from providers such as OpenAI, Anthropic, Google, and Groq can be swapped with a string change, and the same agent can be exposed through a CLI, a built-in web chat, realtime voice sessions, or UI event streams for frontend integration.
- Is pydantic-ai free to use? What license does it have?
- pydantic-ai is open source under the MIT license. Check the license terms before using it in commercial products.
- Is pydantic-ai still maintained?
- Actively maintained. The last commit to pydantic-ai was on Oct 20, 2026.
- What can I use pydantic-ai for?
- Building a typed data extraction pipeline that returns validated Pydantic models from LLM output. Creating a long-running research agent that must survive restarts via Temporal or DBOS. Adding a voice assistant that calls internal tools during a live conversation. Evaluating agent answers and tool-call behavior against a test dataset.
- How do I install pydantic-ai?
- Install the package with uv: uv add pydantic-ai Create a Python file with an Agent and call agent.run_sync(...) to get a typed result
- Where can I get pydantic-ai?
- The source code and installation instructions are on GitHub: https://github.com/pydantic/pydantic-ai
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A Python framework and runtime for building, serving, and managing AI agent platforms, with a web UI for administration.
A lightweight knowledge-graph RAG framework and server that indexes documents into entities and relations for retrieval-augmented LLM answers.
A lightweight Python framework for building multi-agent workflows with tools, handoffs, guardrails, sessions and tracing, provider-agnostic across OpenAI and 100+ LLMs.
Open-source Python framework for building production-ready LLM applications with modular pipelines and agent workflows for RAG, search and agents.
Code-first Python framework from Google for building, evaluating, and deploying AI agents, optimized for Gemini but model-agnostic.