Need more detail? Connect your coding agent to the full docs.

Skip to Content
AMIRILDocs

Send traces from the OpenAI Agents SDK

Convert the OpenAI Agents SDK's own traces to OpenTelemetry with OpenInference and send every agent run to Amiril, in Python or TypeScript.

The OpenAI Agents SDK records traces in its own format. OpenInference is Arize's open-source set of OpenTelemetry instrumentations. Its instrumentation for this SDK turns those traces into OpenTelemetry spans, and Amiril reads each agent run from those.

Install

pip install openinference-instrumentation-openai-agents opentelemetry-sdk opentelemetry-exporter-otlp-proto-http

Turn on trace export

Run these lines once when your agent starts, before its first run.

tracing.py
from openinference.instrumentation.openai_agents import OpenAIAgentsInstrumentor
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor

provider = TracerProvider()
provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter()))
trace.set_tracer_provider(provider)
OpenAIAgentsInstrumentor().instrument(tracer_provider=provider)

Set the endpoint and key

In Amiril, create an API key and copy the endpoint:

  1. Switch to the environment your runs belong to, with the menu at the top of the page.
  2. Open Data and select Set up a new installation. It opens a panel that connects an agent to Amiril.
  3. In the panel, enter a Key name under Create a new key and select Create key.
  4. Copy the key and the OpenTelemetry traces endpoint.

Then set these variables where your agent runs:

export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="<OpenTelemetry traces endpoint>"
export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL="http/protobuf"
export OTEL_EXPORTER_OTLP_TRACES_HEADERS="Authorization=Bearer <your API key>"

Check that traces arrived

Run the agent and open Traces. The run takes its agent name from the name you passed to Agent. Open it to see each tool call with its arguments and result, and each model call.

A new run shows a Scoring badge until Amiril has ranked it. If no run appears, read what the exporter logged.

Next steps

Last updated on