Skip to content

Installation

PydanticAI is available on PyPI as pydantic-ai so installation is as simple as:

pip install pydantic-ai
uv add pydantic-ai

(Requires Python 3.9+)

This installs the pydantic_ai package, core dependencies, and libraries required to use all the models included in PydanticAI. If you want to use a specific model, you can install the "slim" version of PydanticAI.

Use with Pydantic Logfire

PydanticAI has an excellent (but completely optional) integration with Pydantic Logfire to help you view and understand agent runs.

To use Logfire with PydanticAI, install pydantic-ai or pydantic-ai-slim with the logfire optional group:

pip install 'pydantic-ai[logfire]'
uv add 'pydantic-ai[logfire]'

From there, follow the Logfire setup docs to configure Logfire.

Running Examples

We distribute the pydantic_ai_examples directory as a separate PyPI package (pydantic-ai-examples) to make examples extremely easy to customize and run.

To install examples, use the examples optional group:

pip install 'pydantic-ai[examples]'
uv add 'pydantic-ai[examples]'

To run the examples, follow instructions in the examples docs.

Slim Install

If you know which model you're going to use and want to avoid installing superfluous packages, you can use the pydantic-ai-slim package. For example, if you're using just OpenAIModel, you would run:

pip install 'pydantic-ai-slim[openai]'
uv add 'pydantic-ai-slim[openai]'

See the models documentation for information on which optional dependencies are required for each model.

You can also install dependencies for multiple models and use cases, for example:

pip install 'pydantic-ai-slim[openai,vertexai,logfire]'
uv add 'pydantic-ai-slim[openai,vertexai,logfire]'