# Installation

Pydantic AI is available on PyPI as [`pydantic-ai`](https://pypi.org/project/pydantic-ai/) so installation is as simple as:

-   [pip](#tab-panel-86)
-   [uv](#tab-panel-87)

Terminal

```bash
pip install pydantic-ai
```

Terminal

```bash
uv 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"](#slim-install) version of Pydantic AI.

## Use with Pydantic Logfire

Pydantic AI has an excellent (but completely optional) integration with [Pydantic Logfire](https://pydantic.dev/logfire) to help you view and understand agent runs.

Logfire comes included with `pydantic-ai` (but not the ["slim" version](#slim-install)), so you can typically start using it immediately by following the [Logfire setup docs](/docs/ai/integrations/logfire#using-logfire).

## Running Examples

We distribute the [`pydantic_ai_examples`](https://github.com/pydantic/pydantic-ai/tree/main/examples/pydantic_ai_examples) directory as a separate PyPI package ([`pydantic-ai-examples`](https://pypi.org/project/pydantic-ai-examples/)) to make examples extremely easy to customize and run.

To install examples, use the `examples` optional group:

-   [pip](#tab-panel-88)
-   [uv](#tab-panel-89)

Terminal

```bash
pip install "pydantic-ai[examples]"
```

Terminal

```bash
uv add "pydantic-ai[examples]"
```

To run the examples, follow instructions in the [examples docs](/docs/ai/examples/setup).

## 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`](https://pypi.org/project/pydantic-ai-slim/) package. For example, if you're using just [`OpenAIChatModel`](/docs/ai/api/models/openai/#pydantic_ai.models.openai.OpenAIChatModel), you would run:

-   [pip](#tab-panel-90)
-   [uv](#tab-panel-91)

Terminal

```bash
pip install "pydantic-ai-slim[openai]"
```

Terminal

```bash
uv add "pydantic-ai-slim[openai]"
```

`pydantic-ai-slim` has the following optional groups:

-   `logfire` -- installs [Pydantic Logfire](/docs/ai/integrations/logfire) dependency `logfire` [PyPI ↗](https://pypi.org/project/logfire)
-   `evals` -- installs [Pydantic Evals](/docs/ai/evals/) dependency `pydantic-evals` [PyPI ↗](https://pypi.org/project/pydantic-evals)
-   `openai` -- installs [OpenAI Model](/docs/ai/models/openai) dependency `openai` [PyPI ↗](https://pypi.org/project/openai)
-   `vertexai` -- installs `GoogleVertexProvider` dependencies `google-auth` [PyPI ↗](https://pypi.org/project/google-auth) and `requests` [PyPI ↗](https://pypi.org/project/requests)
-   `google` -- installs [Google Model](/docs/ai/models/google) dependency `google-genai` [PyPI ↗](https://pypi.org/project/google-genai)
-   `anthropic` -- installs [Anthropic Model](/docs/ai/models/anthropic) dependency `anthropic` [PyPI ↗](https://pypi.org/project/anthropic)
-   `groq` -- installs [Groq Model](/docs/ai/models/groq) dependency `groq` [PyPI ↗](https://pypi.org/project/groq)
-   `mistral` -- installs [Mistral Model](/docs/ai/models/mistral) dependency `mistralai` [PyPI ↗](https://pypi.org/project/mistralai)
-   `cohere` - installs [Cohere Model](/docs/ai/models/cohere) dependency `cohere` [PyPI ↗](https://pypi.org/project/cohere)
-   `bedrock` - installs [Bedrock Model](/docs/ai/models/bedrock) dependency `boto3` [PyPI ↗](https://pypi.org/project/boto3)
-   `huggingface` - installs [Hugging Face Model](/docs/ai/models/huggingface) dependency `huggingface-hub` [PyPI ↗](https://pypi.org/project/huggingface-hub)
-   `sentence-transformers` - installs [Sentence Transformers Embedding Model](/docs/ai/guides/embeddings#sentence-transformers-local) dependency `sentence-transformers` [PyPI ↗](https://pypi.org/project/sentence-transformers)
-   `voyageai` - installs [VoyageAI Embedding Model](/docs/ai/guides/embeddings#voyageai) dependency `voyageai` [PyPI ↗](https://pypi.org/project/voyageai)
-   `outlines-transformers` - (deprecated, will be removed in v2) installs [Outlines Model](/docs/ai/models/outlines) dependency `outlines[transformers]` [PyPI ↗](https://pypi.org/project/outlines)
-   `outlines-llamacpp` - (deprecated, will be removed in v2) installs [Outlines Model](/docs/ai/models/outlines) dependency `outlines[llamacpp]` [PyPI ↗](https://pypi.org/project/outlines)
-   `outlines-mlxlm` - (deprecated, will be removed in v2) installs [Outlines Model](/docs/ai/models/outlines) dependency `outlines[mlxlm]` [PyPI ↗](https://pypi.org/project/outlines)
-   `outlines-sglang` - (deprecated, will be removed in v2) installs [Outlines Model](/docs/ai/models/outlines) dependency `outlines[sglang]` [PyPI ↗](https://pypi.org/project/outlines)
-   `outlines-vllm-offline` - (deprecated, will be removed in v2) installs [Outlines Model](/docs/ai/models/outlines) dependencies `outlines` [PyPI ↗](https://pypi.org/project/outlines) and `vllm` [PyPI ↗](https://pypi.org/project/vllm)
-   `duckduckgo` - installs [DuckDuckGo Search Tool](/docs/ai/tools-toolsets/common-tools#duckduckgo-search-tool) dependency `ddgs` [PyPI ↗](https://pypi.org/project/ddgs)
-   `tavily` - installs [Tavily Search Tool](/docs/ai/tools-toolsets/common-tools#tavily-search-tool) dependency `tavily-python` [PyPI ↗](https://pypi.org/project/tavily-python)
-   `exa` - installs [Exa Search Tool](/docs/ai/tools-toolsets/common-tools#exa-search-tool) dependency `exa-py` [PyPI ↗](https://pypi.org/project/exa-py)
-   `web-fetch` - installs [Web Fetch Tool](/docs/ai/tools-toolsets/common-tools#web-fetch-tool) dependency `markdownify` [PyPI ↗](https://pypi.org/project/markdownify)
-   `cli` - installs [CLI](/docs/ai/integrations/cli) dependencies `rich` [PyPI ↗](https://pypi.org/project/rich), `prompt-toolkit` [PyPI ↗](https://pypi.org/project/prompt-toolkit), and `argcomplete` [PyPI ↗](https://pypi.org/project/argcomplete)
-   `mcp` - installs [MCP](/docs/ai/mcp/client) dependency `mcp` [PyPI ↗](https://pypi.org/project/mcp)
-   `fastmcp` - installs [FastMCP](/docs/ai/mcp/fastmcp-client) dependency `fastmcp` [PyPI ↗](https://pypi.org/project/fastmcp)
-   `a2a` - (deprecated, will be removed in v2) installs [A2A](/docs/ai/integrations/a2a) dependency `fasta2a` [PyPI ↗](https://pypi.org/project/fasta2a). Prefer installing `fasta2a[pydantic-ai]>=0.6.1` directly and using `from fasta2a.pydantic_ai import agent_to_a2a`.
-   `ui` - installs [UI Event Streams](/docs/ai/integrations/ui/overview) dependency `starlette` [PyPI ↗](https://pypi.org/project/starlette)
-   `ag-ui` - installs [AG-UI Event Stream Protocol](/docs/ai/integrations/ui/ag-ui) dependencies `ag-ui-protocol` [PyPI ↗](https://pypi.org/project/ag-ui-protocol) and `starlette` [PyPI ↗](https://pypi.org/project/starlette)
-   `dbos` - installs [DBOS Durable Execution](/docs/ai/integrations/durable_execution/dbos) dependency `dbos` [PyPI ↗](https://pypi.org/project/dbos)
-   `prefect` - installs [Prefect Durable Execution](/docs/ai/integrations/durable_execution/prefect) dependency `prefect` [PyPI ↗](https://pypi.org/project/prefect)

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

-   [pip](#tab-panel-92)
-   [uv](#tab-panel-93)

Terminal

```bash
pip install "pydantic-ai-slim[openai,google,logfire]"
```

Terminal

```bash
uv add "pydantic-ai-slim[openai,google,logfire]"
```