This repository contains practical examples of using PydanticAI for building LLM-powered applications. PydanticAI is a powerful framework that combines Pydantic's type safety with LLM capabilities.
- Clone this repository:
git clone https://github.com/cloutprotocol/pydantic-ai.git
cd pydantic-ai
- Install dependencies:
pip install -r requirements.txt
- Set up your environment variables:
cp .env.example .env
# Edit .env with your OpenAI API key
- Recipe Generator: Demonstrates using PydanticAI for structured recipe generation
- Customer Support Agent: Shows how to build a support agent with structured responses
- Data Analyzer: Example of using PydanticAI for structured data analysis
Each example is self-contained in its own directory under examples/
.
Each example can be run directly:
python examples/recipe_generator.py
python examples/customer_support.py
python examples/data_analyzer.py
- Type Safety: All examples use Pydantic models for type-safe inputs and outputs
- Structured Outputs: Show how to get structured, predictable responses from LLMs
- Error Handling: Examples include proper error handling and validation
- Real-world Use Cases: Practical applications that can be adapted for production use
For more information about PydanticAI, visit the official documentation.