Pydantic AI
Learn how to trace Pydantic AI agents with Openlayer
Pydantic AI is a Python framework for building production-ready applications powered by generative AI. Created by the team behind Pydantic, it offers type-safe agents with structured outputs, built-in dependency injection, and native support for leading LLM providers like OpenAI, Anthropic, and Gemini.
This guide shows how to trace Pydantic AI agents with Openlayer.
Configuration
The integration works by sending trace data to Openlayer’s OpenTelemetry endpoint.
The full code used in this guide is available here.
To set it up, you need to:
Set the environment variables
Set the following environment variables:
Configure Logfire
Configure Logfire in your application:
Use Agents as usual
Once instrumentation is set up, you can run your Agents as usual. Trace data will be automatically captured and exported to Openlayer, where you can begin testing and analyzing it.
For example: