Skip to main content
Records PydanticAI agent runs. PydanticAI instruments itself, so the in-code sample turns that on and adds OpenInference’s span processor. Also verified: pydantic-ai 1.25.1 with instrumentor 0.1.27. The extra no longer installs that older instrumentor. See supported frameworks for how verification works.

In code

Call tracing.init(), attach the framework instrumentor to the provider it returns, and wrap the work in tracing.turn() and tracing.agent().
The install line uses PydanticAI 2.57, which needs Python 3.11 or newer and no other pins.
On Python 3.10, use the tested PydanticAI 1.25 instead. It needs OpenTelemetry 1.39 and genai-prices older than 0.1 to record token counts, because PydanticAI before 2.17 records none with genai-prices 0.1.0 or newer, and the trace would then show zero cost. In code, pass version=3 to InstrumentationSettings on PydanticAI 1.x and version=5 on 2.x.
terminal
1

Install

terminal
2

Add the code

app.py
3

Run

terminal
Needs BOTGAUGE_API_KEY, OPENAI_BASE_URL, OPENAI_API_KEY, OPENAI_MODEL.

Zero-code

Leave your app unchanged and start it with botgauge instrument. The sample still wraps the work in tracing.turn() and tracing.agent() so spans carry session and agent ids.
The install line uses PydanticAI 2.57, which needs Python 3.11 or newer and no other pins.
On Python 3.10, use the tested PydanticAI 1.25 instead. It needs OpenTelemetry 1.39 and genai-prices older than 0.1 to record token counts, because PydanticAI before 2.17 records none with genai-prices 0.1.0 or newer, and the trace would then show zero cost. botgauge instrument picks the right instrumentation version for you.
terminal
1

Install

terminal
2

Add the code

app.py
3

Run

terminal
Needs BOTGAUGE_API_KEY, OPENAI_BASE_URL, OPENAI_API_KEY, OPENAI_MODEL.

View PydanticAI spans live

Watch your PydanticAI agent runs with token counts appear in BotGauge.

Try BotGauge →
See versions not verified if you run a different version, capture and redaction to control exported content, and troubleshooting if spans are missing.