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
| Field | Description |
|---|---|
| Model | The AI model used |
| Temperature | Temperature parameter |
| Tools | List of available tools/functions |
| Tool Calls | Which tools were invoked |
| Prompt Hash | Hash of the agent instructions |
| Response Time | Time for agent execution |
| Token Usage | Input/output tokens |
| Cost | Estimated API cost |
Verify
Check your Decyra dashboard to see agent runs in the traces view. Each run includes tool calls and model interactions.