Installation
Pydantic AI is available on PyPI as pydantic-ai so installation is as simple as:
pip install pydantic-ai
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, 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’s own HTTP requests, and those of providers migrated to httpx2, verify TLS certificates against the operating system trust store rather than shipping a certifi bundle.
Minimal container images and corporate proxies that rely on a private CA therefore need those certificates installed in the image (for example the ca-certificates package, plus your proxy’s root CA).
Alternatively, pass such a provider an httpx2.AsyncClient you configured yourself through its http_client argument — see the provider docs for the client each one accepts.
Providers whose SDKs still use legacy httpx (such as Anthropic and Cohere) keep its certifi-based verification and take a legacy httpx.AsyncClient instead.
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 install "pydantic-ai[examples]"
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, 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 ↗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 ↗bedrock-mantle- installs Bedrock Mantle Model dependenciesopenaiPyPI ↗ andbotocorePyPI ↗xai- installs xAI Model dependencyxai-sdkPyPI ↗openrouter- installs the OpenRouter dependencyopenaiPyPI ↗zai- installs the Z.AI dependencyopenaiPyPI ↗snowflake- installs the Snowflake Cortex dependencyopenaiPyPI ↗crusoe- installs the Crusoe dependencyopenaiPyPI ↗cerebras- installs the Cerebras dependencyopenaiPyPI ↗huggingface- installs Hugging Face Model dependencyhuggingface-hubPyPI ↗sentence-transformers- installs Sentence Transformers Embedding Model dependencysentence-transformersPyPI ↗voyageai- installs VoyageAI Embedding Model dependencyvoyageaiPyPI ↗duckduckgo- installs DuckDuckGo Search Tool dependencyddgsPyPI ↗tavily- installs Tavily Search Tool dependencytavily-pythonPyPI ↗exa- installs Exa Search Tool dependencyexa-pyPyPI ↗web-fetch- installs Web Fetch Tool dependencymarkdownifyPyPI ↗cli- installs CLI dependenciesrichPyPI ↗,prompt-toolkitPyPI ↗, andargcompletePyPI ↗mcp- installs MCP dependencyfastmcp-slim[client]PyPI ↗ui- installs UI Event Streams dependencystarlettePyPI ↗web- installs Web UI dependenciesstarlettePyPI ↗ anduvicornPyPI ↗ag-ui- installs AG-UI Event Stream Protocol dependenciesag-ui-protocolPyPI ↗ andstarlettePyPI ↗retries- installs HTTP Retries dependencytenacityPyPI ↗, plus legacyhttpxPyPI ↗ support until Pydantic AI v3temporal- installs Temporal Durable Execution dependencytemporalioPyPI ↗dbos- installs DBOS Durable Execution dependencydbosPyPI ↗prefect- installs Prefect Durable Execution dependencyprefectPyPI ↗spec- installs AgentSpec dependenciespyyamlPyPI ↗ andpydantic-handlebarsPyPI ↗
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]"