This integration is only for Agent tracing. If you are looking for a general integration for OpenAI, please see the OpenAI integration.
Give us a star on GitHub!

The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows.

Keywords AI agent tracing with OpenAI Agents SDK.

Core concepts:

  1. Agents: LLMs configured with instructions, tools, guardrails, and handoffs
  2. Handoffs: Allow agents to transfer control to other agents for specific tasks
  3. Guardrails: Configurable safety checks for input and output validation
  4. Tracing: Built-in tracking of agent runs, allowing you to view, debug and optimize your workflows

Quickstart

When install OpenAI Agents SDK and Keywords AI tracing SDK, implement KeywordsProcessor in your code to send traces from the OpenAI Agents SDK to Keywords AI.

Prerequisites

npm install @openai/agents
yarn add @keywordsai/exporter-openai-agents
yarn install

Please use the specific endpoint for the OpenAI Agents SDK.

.env
KEYWORDSAI_API_KEY= "YOUR_KEYWORDSAI_API_KEY"
KEYWORDSAI_BASE_URL=https://api.keywordsai.co/api
If you are on the enterprise platform, please use the enterprise endpoint plus the suffix.

Hello World example

hello-world.tsx
import { Agent, BatchTraceProcessor, run, setTraceProcessors, withTrace } from '@openai/agents';
import { KeywordsAIOpenAIAgentsTracingExporter } from '@keywordsai/exporter-openai-agents';

setTraceProcessors([
  new BatchTraceProcessor(
    new KeywordsAIOpenAIAgentsTracingExporter(),
  ),
]);

async function main() {
  const agent = new Agent({
    name: 'Assistant',
    instructions: 'You only respond in haikus.',
  });

  const result = await withTrace('Hello World', async () => {
    return run(agent, 'Tell me about recursion in programming.');
  });
  console.log(result.finalOutput);

}

main().catch(console.error);