The Respan JavaScript exporter for the OpenAI Agents SDK enables tracing of multi-agent workflows in Node.js and TypeScript applications. Capture agent runs, tool calls, handoffs, and guardrails as hierarchical traces.
The integration supports metadata tagging, function calling with Zod schemas, and multi-agent handoff patterns. Custom properties can be attached to traces for enhanced tracking and filtering.
Install @openai/agents, @keywordsai/exporter-openai-agents, and zod. Set your OPENAI_API_KEY, KEYWORDSAI_API_KEY, and KEYWORDSAI_BASE_URL environment variables.
Initialize the KeywordsAIOpenAIAgentsTracingExporter with a BatchTraceProcessor. The exporter captures all agent events and sends them to the Respan platform.
Run your agents with the withTrace() function to attach metadata. All examples use npx tsx for execution and integrate the exporter consistently.
typescript
import { Agent, run } from "@openai/agents";
import { KeywordsAIOpenAIAgentsTracingExporter } from "@keywordsai/exporter-openai-agents";
import { BatchTraceProcessor } from "@openai/agents/tracing";
const exporter = new KeywordsAIOpenAIAgentsTracingExporter({
apiKey: process.env.KEYWORDSAI_API_KEY!,
baseUrl: process.env.KEYWORDSAI_BASE_URL!,
});
const processor = new BatchTraceProcessor(exporter);
const agent = new Agent({
name: "Assistant",
instructions: "You are a helpful assistant.",
model: "gpt-4o-mini",
});
const result = await run(agent, "Hello!");
console.log(result.finalOutput);