Back to Guides

OpenAI Agents SDK

Build production-ready AI agents with OpenAI's official SDK

TypeScripteasy

The OpenAI Agents SDK provides tools for building AI agents with function calling and tool use. Decyra captures all agent interactions, tool calls, and model responses for complete observability.

Prerequisites

  • Decyra account with API key
  • Node.js 18+ installed
  • OpenAI Agents SDK installed

Installation

npm install @openai/agents @decyra/sdk openai

Integration

Wrap the OpenAI client with Decyra:

import OpenAI from 'openai';
import { wrapOpenAI } from '@decyra/sdk';
import { wrapOpenAI as wrapOpenAIAgent } from '@openai/agents';

const openai = new OpenAI({
  baseURL: 'https://proxy.decyra.com/v1',
  apiKey: process.env.DECYRA_API_KEY,
  defaultHeaders: {
    'X-Decyra-API-Key': process.env.DECYRA_API_KEY!,
  },
});

const decyraClient = wrapOpenAI(openai);
const agentClient = wrapOpenAIAgent(decyraClient);

Create and use an agent:

import { Agent } from '@openai/agents';

const agent = new Agent({
  client: agentClient,
  model: 'gpt-4',
  instructions: 'You are a helpful coding assistant.',
});

const response = await agent.run('Write a function to sort an array');
console.log(response.content);

What Gets Captured

FieldDescription
ModelThe AI model used
TemperatureTemperature parameter
ToolsList of available tools/functions
Tool CallsWhich tools were invoked
Prompt HashHash of the agent instructions
Response TimeTime for agent execution
Token UsageInput/output tokens
CostEstimated API cost

Verify

Check your Decyra dashboard to see agent runs in the traces view. Each run includes tool calls and model interactions.

Next Steps