Skip to main content

OpenInference PydanticAI

pypi

Python auto-instrumentation library for PydanticAI. These traces are fully OpenTelemetry compatible and can be sent to an OpenTelemetry collector for viewing, such as Arize Phoenix or Arize AX.

Installation

pip install openinference-instrumentation-pydantic-ai

Requires Pydantic AI 2.24.0 or newer.

Quickstart

This quickstart shows you how to instrument your PydanticAI agents.

Install required packages.

pip install "pydantic-ai>=2.24.0" arize-phoenix opentelemetry-sdk opentelemetry-exporter-otlp

Start Phoenix in the background as a collector. By default, it listens on http://localhost:6006. You can visit the app via a browser at the same address. (Phoenix does not send data over the internet. It only operates locally on your machine.)

phoenix serve

Here's a simple example that demonstrates how to use PydanticAI with OpenInference instrumentation:

import os
from pydantic import BaseModel
from pydantic_ai import Agent
from pydantic_ai.models.instrumented import InstrumentationSettings
from pydantic_ai.models.openai import OpenAIModel
from pydantic_ai.providers.openai import OpenAIProvider
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from openinference.instrumentation.pydantic_ai import OpenInferenceSpanProcessor
from opentelemetry.sdk.trace.export import SimpleSpanProcessor

# Set your OpenAI API key
os.environ["OPENAI_API_KEY"] = "YOUR_OPENAI_API_KEY"

# Set up the tracer provider
tracer_provider = TracerProvider()
trace.set_tracer_provider(tracer_provider)

# Add the OpenInference span processor
endpoint = "http://127.0.0.1:6006/v1/traces"
exporter = OTLPSpanExporter(endpoint=endpoint)
tracer_provider.add_span_processor(OpenInferenceSpanProcessor())
tracer_provider.add_span_processor(SimpleSpanProcessor(exporter))


# Define your Pydantic model
class LocationModel(BaseModel):
    city: str
    country: str

instrumentation = InstrumentationSettings(version=2)

# Create and configure the agent
model = OpenAIModel("gpt-4", provider=OpenAIProvider())
agent = Agent(model, output_type=LocationModel, instrument=instrumentation)

# Run the agent
result = agent.run_sync("The windy city in the US of A.")
print(result)

This example:

  1. Sets up OpenTelemetry tracing with Phoenix
  2. Defines a simple Pydantic model for location data
  3. Creates a PydanticAI agent with instrumentation enabled
  4. Runs a query and gets structured output

The traces will be visible in the Phoenix UI at http://localhost:6006.

More Info

Metadata

Release files for openinference-instrumentation-pydantic-ai 0.1.36

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openinference-instrumentation-pydantic-ai 0.1.36
File Size Uploaded Provenance Actions
openinference_instrumentation_pydantic_ai-0.1.36.tar.gz 26.5 kB With provenance Details for openinference_instrumentation_pydantic_ai-0.1.36.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for openinference-instrumentation-pydantic-ai 0.1.36
File Interpreter ABI Platform Actions
openinference_instrumentation_pydantic_ai-0.1.36-py3-none-any.whl Python 3 none any Details for openinference_instrumentation_pydantic_ai-0.1.36-py3-none-any.whl

Total release size: 44.0 kB

Release files / openinference_instrumentation_pydantic_ai-0.1.36.tar.gz

Download URL openinference_instrumentation_pydantic_ai-0.1.36.tar.gz
Size 26.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2c34f84bde49148ac51b43e146ef466c4ff1325af42c3e1f69a0f17928091577
BLAKE2b-256 checksum
How to use checksums
d468962e235d739d71587bf4ec0389803fdf1620bd792c35ec1324b4a0b7a3da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / openinference_instrumentation_pydantic_ai-0.1.36-py3-none-any.whl

Download URL openinference_instrumentation_pydantic_ai-0.1.36-py3-none-any.whl
Size 17.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a9be8246cef00eb2914bf47b4787571a8cdfd70d581da382570eea6cb24f8c2f
BLAKE2b-256 checksum
How to use checksums
9ba6de322f683bd93256dd1c3400710df47c7b496d27a1379e267cb498344e70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Security for openinference-instrumentation-pydantic-ai 0.1.36

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for openinference_instrumentation_pydantic_ai-0.1.36.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.36 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page