Skip to main content
For a complete example, see the Pydantic AI example on GitHub.
Pydantic AI uses OpenTelemetry internally, which Gentrace automatically captures when initialized, providing seamless tracing without additional configuration.

Prerequisites

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
Since Gentrace is OpenTelemetry-compatible, it automatically captures all these traces without requiring any additional instrumentation.

Supported Models

Pydantic AI supports multiple models through different providers:
  • OpenAI (GPT-4, GPT-3.5)
  • Anthropic (Claude)
  • Google (Gemini)
  • Groq
  • Mistral