Installation ↗
noOriginal Documentation
Pydantic AI is available on PyPI as pydantic-ai so installation is as simple as:
pip install pydantic-aiuv add pydantic-ai(Requires Python 3.10+)
This installs the pydantic_ai package, core dependencies, and libraries required to use all the models included in Pydantic AI. If you want to install only those dependencies required to use a specific model, you can install the “slim” version of Pydantic AI.
Use with Pydantic Logfire#
Pydantic AI has an excellent (but completely optional) integration with Pydantic Logfire to help you view and understand agent runs.
Logfire comes included with pydantic-ai (but not the “slim” version), so you can typically start using it immediately by following the Logfire setup docs.
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 OpenAIChatModel, you would run:
pip install "pydantic-ai-slim[openai]"uv add "pydantic-ai-slim[openai]"pydantic-ai-slim has the following optional groups:
logfire— installs Pydantic Logfire dependencylogfirePyPI ↗evals— installs Pydantic Evals dependencypydantic-evalsPyPI ↗openai— installs OpenAI Model dependencyopenaiPyPI ↗vertexai— installsGoogleVertexProviderdependenciesgoogle-authPyPI ↗ andrequestsPyPI ↗google— installs Google Model dependencygoogle-genaiPyPI ↗anthropic— installs Anthropic Model dependencyanthropicPyPI ↗groq— installs Groq Model dependencygroqPyPI ↗mistral— installs Mistral Model dependencymistralaiPyPI ↗cohere- installs Cohere Model dependencycoherePyPI ↗bedrock- installs Bedrock Model dependencyboto3PyPI ↗huggingface- installs Hugging Face Model dependencyhuggingface-hubPyPI ↗outlines-transformers- installs Outlines Model dependencyoutlines[transformers]PyPI ↗outlines-llamacpp- installs Outlines Model dependencyoutlines[llamacpp]PyPI ↗outlines-mlxlm- installs Outlines Model dependencyoutlines[mlxlm]PyPI ↗outlines-sglang- installs Outlines Model dependencyoutlines[sglang]PyPI ↗outlines-vllm-offline- installs Outlines Model dependenciesoutlinesPyPI ↗ andvllmPyPI ↗duckduckgo- installs DuckDuckGo Search Tool dependencyddgsPyPI ↗tavily- installs Tavily Search Tool dependencytavily-pythonPyPI ↗exa- installs Exa Search Tool dependencyexa-pyPyPI ↗cli- installs CLI dependenciesrichPyPI ↗,prompt-toolkitPyPI ↗, andargcompletePyPI ↗mcp- installs MCP dependencymcpPyPI ↗fastmcp- installs FastMCP dependencyfastmcpPyPI ↗a2a- installs A2A dependencyfasta2aPyPI ↗ui- installs UI Event Streams dependencystarlettePyPI ↗ag-ui- installs AG-UI Event Stream Protocol dependenciesag-ui-protocolPyPI ↗ andstarlettePyPI ↗dbos- installs DBOS Durable Execution dependencydbosPyPI ↗prefect- installs Prefect Durable Execution dependencyprefectPyPI ↗
You can also install dependencies for multiple models and use cases, for example:
pip install "pydantic-ai-slim[openai,google,logfire]"uv add "pydantic-ai-slim[openai,google,logfire]"