> ## Documentation Index
> Fetch the complete documentation index at: https://phaseo.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# PydanticAI

> Build typed Python agents with PydanticAI and Phaseo.

Use PydanticAI when you want Python agents with typed outputs, validation, and a compact OpenAI-compatible model setup.

## Install

```bash theme={null}
pip install "pydantic-ai-slim[openai]"
```

## Configure the model

```python theme={null}
import os
from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIChatModel
from pydantic_ai.providers.openai import OpenAIProvider

model = OpenAIChatModel(
    "openai/gpt-5-nano",
    provider=OpenAIProvider(
        api_key=os.environ["PHASEO_API_KEY"],
        base_url="https://api.phaseo.ai/v1",
    ),
)

agent = Agent(model, system_prompt="Answer concisely.")
result = agent.run_sync("Reply with only: ok")
print(result.output)
```

## Notes

* PydanticAI's OpenAI-compatible path uses OpenAI-style chat behavior.
* Use direct Phaseo Responses calls for Responses-only features such as `phaseo:apply_patch`.
* Keep structured output schemas small enough for the selected model's context window.

## Related

* [Structured Outputs](../structured-outputs.mdx)
* [OpenAI SDK](./openai-sdk.mdx)
* [Models](../../api-reference/endpoint/models.mdx)
