Skip to main content
AgentBasis supports Pydantic AI with built-in OpenTelemetry instrumentation.

Setup

Basic Usage

Once instrumented, all Pydantic AI agents are automatically traced:

Privacy Controls

Control what data is captured in traces:
ParameterDefaultDescription
include_contentTrueLog prompts and completions
include_binary_contentFalseInclude images and other binary data

Per-Agent Instrumentation

If you need different settings for different agents, use get_instrumentation_settings():

User Context Integration

Using create_traced_agent

The easiest way to create an agent with context support:

Using get_metadata_callback

For more control, use the metadata callback directly:

Async Usage

All methods work with async agents:

Captured Data

The integration automatically records:
FieldDescription
gen_ai.systemLLM provider (e.g., openai)
gen_ai.request.modelModel name
gen_ai.promptInput messages (if include_content=True)
gen_ai.completionResponse (if include_content=True)
user_idUser ID from context
session_idSession ID from context
durationRequest latency