What is PydanticAI?
PydanticAI is a Python agent framework by the creators of Pydantic that emphasizes type safety, structured outputs, and production reliability — using Pydantic models to define agent inputs, outputs, and tool interfaces with full type checking.
WHY IT MATTERS
Most agent frameworks treat inputs and outputs as unstructured text. PydanticAI brings the rigor of Pydantic's data validation to agent development — every tool input is validated, every output is typed, and type errors are caught at development time rather than runtime.
The framework supports multiple LLM providers (OpenAI, Anthropic, Google, Groq), has built-in dependency injection for testing, and provides structured result types that integrate naturally with Python type checkers and IDEs.
For financial agents, type safety is particularly valuable. A tool that accepts a payment amount should reject negative numbers, strings, or values exceeding limits — at the type level, before any business logic runs.
HOW POLICYLAYER USES THIS
PolicyLayer integrates with PydanticAI through typed tool definitions. Spending policy checks are expressed as Pydantic-validated tool calls, ensuring type-safe policy enforcement alongside type-safe agent logic.