docs/install.md
Pydantic AI is available on PyPI as pydantic-ai so installation is as simple as:
pip/uv-add pydantic-ai
(Requires Python 3.10+)
This installs the pydantic_ai package, core dependencies, and libraries required to use the OpenAI, Anthropic, and Google models, plus the CLI, MCP, Evals, Web UI, Retries, and Logfire integrations.
To use any other models or integrations, add the relevant extras to your install command, e.g. pydantic-ai[bedrock,temporal]. Alternatively, you can install the pydantic-ai-slim package with only the extras you need.
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.
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/uv-add "pydantic-ai[examples]"
To run the examples, follow instructions in the examples docs.
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][pydantic_ai.models.openai.OpenAIChatModel], you would run:
pip/uv-add "pydantic-ai-slim[openai]"
pydantic-ai-slim has the following optional groups:
logfire — installs Pydantic Logfire dependency logfire PyPI ↗{:target="_blank"}evals — installs Pydantic Evals dependency pydantic-evals PyPI ↗{:target="_blank"}openai — installs OpenAI Model dependency openai PyPI ↗{:target="_blank"}google — installs Google Model dependency google-genai PyPI ↗{:target="_blank"}anthropic — installs Anthropic Model dependency anthropic PyPI ↗{:target="_blank"}groq — installs Groq Model dependency groq PyPI ↗{:target="_blank"}mistral — installs Mistral Model dependency mistralai PyPI ↗{:target="_blank"}cohere - installs Cohere Model dependency cohere PyPI ↗{:target="_blank"}bedrock - installs Bedrock Model dependency boto3 PyPI ↗{:target="_blank"}xai - installs xAI Model dependency xai-sdk PyPI ↗{:target="_blank"}openrouter - installs the OpenRouter dependency openai PyPI ↗{:target="_blank"}huggingface - installs Hugging Face Model dependency huggingface-hub PyPI ↗{:target="_blank"}sentence-transformers - installs Sentence Transformers Embedding Model dependency sentence-transformers PyPI ↗{:target="_blank"}voyageai - installs VoyageAI Embedding Model dependency voyageai PyPI ↗{:target="_blank"}duckduckgo - installs DuckDuckGo Search Tool dependency ddgs PyPI ↗{:target="_blank"}tavily - installs Tavily Search Tool dependency tavily-python PyPI ↗{:target="_blank"}exa - installs Exa Search Tool dependency exa-py PyPI ↗{:target="_blank"}web-fetch - installs Web Fetch Tool dependency markdownify PyPI ↗{:target="_blank"}cli - installs CLI dependencies rich PyPI ↗{:target="_blank"}, prompt-toolkit PyPI ↗{:target="_blank"}, and argcomplete PyPI ↗{:target="_blank"}mcp - installs MCP dependency fastmcp-slim[client] PyPI ↗{:target="_blank"}ui - installs UI Event Streams dependency starlette PyPI ↗{:target="_blank"}web - installs Web UI dependencies starlette PyPI ↗{:target="_blank"}, httpx PyPI ↗{:target="_blank"}, and uvicorn PyPI ↗{:target="_blank"}ag-ui - installs AG-UI Event Stream Protocol dependencies ag-ui-protocol PyPI ↗{:target="_blank"} and starlette PyPI ↗{:target="_blank"}retries - installs HTTP Retries dependency tenacity PyPI ↗{:target="_blank"}temporal - installs Temporal Durable Execution dependency temporalio PyPI ↗{:target="_blank"}dbos - installs DBOS Durable Execution dependency dbos PyPI ↗{:target="_blank"}prefect - installs Prefect Durable Execution dependency prefect PyPI ↗{:target="_blank"}spec - installs AgentSpec dependencies pyyaml PyPI ↗{:target="_blank"} and pydantic-handlebars PyPI ↗{:target="_blank"}You can also install dependencies for multiple models and use cases, for example:
pip/uv-add "pydantic-ai-slim[openai,google,logfire]"