Skip to main content
Pydantic AI brings the design philosophy of FastAPI and Pydantic into agentic AI development. It offers first-class type safety, automatic validation, and structured output parsing.

Setup

Install the pydantic-ai library:

Model Configuration

Use OpenAIChatModel paired with OpenAIProvider configured with the Neosantara gateway base URL and your API key.

Structured Outputs with Pydantic Models

Enforce strict output formats by passing a Pydantic BaseModel to the result_type parameter:

Agents with Tool Calling

Attach tools to your agent with the @agent.tool decorator:

Next Steps