For a complete example, see the Pydantic AI
example
on GitHub.
Prerequisites
- Python 3.8+
- OpenAI API key (or other supported LLM)
- Gentrace API key
Installation
Configuration
Simply initialize Gentrace before using Pydantic AI:pydantic_ai_simple.py
Environment Variables
.env
How It Works
Pydantic AI automatically generates OpenTelemetry traces for:- Agent invocations
- Model calls
- Tool usage
- Retries and validation
Supported Models
Pydantic AI supports multiple models through different providers:- OpenAI (GPT-4, GPT-3.5)
- Anthropic (Claude)
- Google (Gemini)
- Groq
- Mistral