Use this file to discover all available pages before exploring further.
The OpenAI Agents SDK is OpenAI’s framework for building agentic workflows. Braintrust instruments OpenAI Agents runs so you can inspect agent spans, tool calls, guardrails, nested model calls, and final outputs as a single trace in Braintrust.
To instrument OpenAI Agents SDK runs, add Braintrust’s OpenAIAgentsTraceProcessor.
import { initLogger } from "braintrust";import { OpenAIAgentsTraceProcessor } from "@braintrust/openai-agents";import { Agent, addTraceProcessor, run } from "@openai/agents";const logger = initLogger({ projectName: "openai-agents-example", // Replace with your project name apiKey: process.env.BRAINTRUST_API_KEY,});addTraceProcessor(new OpenAIAgentsTraceProcessor({ logger }));async function main() { const agent = new Agent({ name: "Assistant", model: "gpt-5-mini", instructions: "You answer in one sentence.", }); const result = await run(agent, "What is the capital of France?"); console.log(result.finalOutput);}main().catch(console.error);
If you omit logger, the processor uses the current Braintrust span, experiment, or logger when one is active.
To automatically trace OpenAI Agents SDK runs alongside Braintrust’s other Python integrations, call braintrust.auto_instrument().
import asyncioimport osimport braintrustbraintrust.auto_instrument()braintrust.init_logger( api_key=os.environ["BRAINTRUST_API_KEY"], project="openai-agents-example", # Replace with your project name)from agents import Agent, Runnerasync def main(): agent = Agent( name="Assistant", model="gpt-5-mini", instructions="You answer in one sentence.", ) result = await Runner.run(agent, "What is the capital of France?") print(result.final_output)if __name__ == "__main__": asyncio.run(main())
To instrument only the OpenAI Agents SDK without enabling Braintrust’s other integrations, use setup_openai_agents() instead of braintrust.auto_instrument().
import asynciofrom agents import Agent, Runnerfrom braintrust.integrations.openai_agents import setup_openai_agentssetup_openai_agents(project_name="openai-agents-example")async def main(): agent = Agent( name="Assistant", model="gpt-5-mini", instructions="You answer in one sentence.", ) result = await Runner.run(agent, "What is the capital of France?") print(result.final_output)if __name__ == "__main__": asyncio.run(main())