Favicon of Pydantic AI

Pydantic AI

An open source Python AI agent SDK with validated outputs, Ollama support and an optional self-hosted model gateway, licensed under MIT.

Screenshot of Pydantic AI website

Pydantic AI is a Python SDK for developers building agents into their applications. It uses Pydantic validation to give application code structured results and check the arguments agents pass to tools.

  • Validated data and tools: Agents can extract typed data, call Python functions and connect to tools through MCP.
  • Model choice: The same agent API supports Ollama alongside OpenAI, Anthropic and Google, so applications can use local models or external providers.
  • Long-running agents: The separate Pydantic AI Harness adds memory, planning, guardrails and sub-agents, including a coding agent with file and shell access.
  • Workflows that survive interruptions: Integrations with Temporal, DBOS and Prefect let agents resume work after restarts or failures and include human approval steps.
  • Chat, voice and media: Agents can run in terminal or web interfaces; live voice uses services such as OpenAI Realtime or Gemini Live, while image generation and embeddings depend on the selected model backend.

The MIT-licensed SDK runs in your Python application, including on a server you control. Model requests go to the backend you choose. The optional Pydantic AI Gateway can be self-hosted, and tracing works with any OpenTelemetry backend. A built-in test model runs entirely offline without calling an LLM; it's for exercising tools and outputs rather than generating real model responses.

Similar to Pydantic AI