OpenAI Agents SDK

Trace OpenAI Agent calls

Openai-agents is an AI agent framework developed by OpenAI, designed for easy agent orchestration and tool use. You can view two examples below!

Example
Links

Tracing

Full Cookbook

Install

pip install openinference-instrumentation-openai-agents openai-agents arize-otel

Set up Tracing

Add your OpenAI API key as an environment variable:

export OPENAI_API_KEY=[your_key_here]

Use the register function to connect your application to Arize:

from arize.otel import register

tracer_provider = register(
    space_id = "your-space-id", # in app space settings page
    api_key = "your-api-key", # in app space settings page
    project_name="agents"
)

from openinference.instrumentation.openai_agents import OpenAIAgentsInstrumentor
OpenAIAgentsInstrumentor().instrument(tracer_provider=tracer_provider)

Create your agent

Run your agentscode.

from agents import Agent, Runner

agent = Agent(name="Assistant", instructions="You are a helpful assistant")
result = Runner.run_sync(agent, "Write a haiku about recursion in programming.")
print(result.final_output)

Observe

Once you've started your instrumentation, all invocations and steps of your Agent will be sent to the Arize platform!

Last updated

Was this helpful?