Integrations
OpenAI Agents SDK for TypeScript
The OpenAI Agents SDK for TypeScript builds agents that use tools, hand off to each other and stream their answers. Set its default OpenAI client to DEVUP AI once, and every agent runs on DEVUP AI models.
Working in Python? See the OpenAI Agents SDK guide.
Requirements
- Node.js 22 or later. The examples are .mts files, which Node.js 24 runs directly.
- a DEVUP AI API key from https://devupai.com/dashboard/api-keys. Create a dedicated key for your agents so you can revoke it on its own.
Install the SDK
npm install @openai/agents @openai/agents-core openai zod@openai/agents-core provides the handoff helper used below.
Set your API key
The configuration reads the key from DEVUP_API_KEY. Set it in the terminal where you run your agents:
PowerShell
$env:DEVUP_API_KEY = "YOUR_DEVUP_API_KEY"Bash
export DEVUP_API_KEY="YOUR_DEVUP_API_KEY"Connect the SDK to DEVUP AI
Save this as devup-config.mts next to your agents. Every example on this page imports it first, so all agents use the DEVUP AI client.
devup-config.mts
import OpenAI from 'openai';
import { setDefaultOpenAIClient, setTracingDisabled } from '@openai/agents';
const apiKey = process.env.DEVUP_API_KEY;
if (!apiKey) {
throw new Error('Set DEVUP_API_KEY before running your agents.');
}
setDefaultOpenAIClient(
new OpenAI({
apiKey,
baseURL: 'https://api.devupai.com/v1',
}),
);
setTracingDisabled(true);Settings
| Setting | Value | What it does |
|---|---|---|
| baseURL | https://api.devupai.com/v1 | Sends every request to DEVUP AI. |
| apiKey | DEVUP_API_KEY | Your DEVUP AI key, read from the environment. |
| setDefaultOpenAIClient | the client above | Every agent in the process uses it. |
| setTracingDisabled | true | Turns off the SDK's trace export to OpenAI. |
| model | a catalog model ID | Written exactly as in the catalog, such as deepseek-ai/DeepSeek-V4-Pro or openai/gpt-5.4-mini. |
Run your first agent
basic.mts
import './devup-config.mts';
import { Agent, run } from '@openai/agents';
const agent = new Agent({
name: 'Assistant',
instructions: 'Reply with exactly: Salam DEVUP',
model: 'deepseek-ai/DeepSeek-V4-Pro',
});
const result = await run(agent, 'Say hello.');
console.log(result.finalOutput);node basic.mtsIt prints Salam DEVUP.
Stream the answer
Pass { stream: true } to run() and read the text as it is written:
streaming.mts
import './devup-config.mts';
import { Agent, run } from '@openai/agents';
const agent = new Agent({
name: 'Assistant',
instructions: 'Answer briefly.',
model: 'deepseek-ai/DeepSeek-V4-Pro',
});
const stream = await run(agent, 'Count from 1 to 5, separated by commas.', { stream: true });
for await (const text of stream.toTextStream()) {
process.stdout.write(text);
}
await stream.completed;
console.log();Give the agent tools
Define a tool with tool() and a zod schema, then list it in tools:
tools.mts
import './devup-config.mts';
import { Agent, run, tool } from '@openai/agents';
import { z } from 'zod';
const getOrderStatus = tool({
name: 'get_order_status',
description: 'Look up the shipping status and tracking number of an order.',
parameters: z.object({ orderId: z.string() }),
execute: async ({ orderId }) => 'Order ' + orderId + ': shipped, tracking number DZ-4471.',
});
const agent = new Agent({
name: 'Support agent',
instructions: 'Use get_order_status to look up orders before you answer.',
model: 'deepseek-ai/DeepSeek-V4-Pro',
tools: [getOrderStatus],
});
const result = await run(agent, 'What is the tracking number for order A-1001?');
console.log(result.finalOutput);The agent calls get_order_status and answers with the tracking number DZ-4471.
Get structured output
Set a zod schema as outputType, and finalOutput comes back as a typed object:
structured.mts
import './devup-config.mts';
import { Agent, run } from '@openai/agents';
import { z } from 'zod';
const City = z.object({
city: z.string(),
country: z.string(),
});
const agent = new Agent({
name: 'Geography agent',
instructions: 'Answer with the city and its country.',
model: 'deepseek-ai/DeepSeek-V4-Pro',
outputType: City,
});
const result = await run(agent, 'What is the capital of Algeria?');
console.log(result.finalOutput);It prints { city: 'Algiers', country: 'Algeria' }.
Hand off between agents
A triage agent hands billing questions to a Billing agent. promptWithHandoffInstructions adds the SDK's recommended handoff instructions:
handoff.mts
import './devup-config.mts';
import { Agent, run } from '@openai/agents';
import { promptWithHandoffInstructions } from '@openai/agents-core/extensions';
const billingAgent = new Agent({
name: 'Billing agent',
handoffDescription: 'Handles billing and payment questions.',
instructions: promptWithHandoffInstructions('You answer billing and payment questions.'),
model: 'deepseek-ai/DeepSeek-V4-Pro',
});
const triageAgent = Agent.create({
name: 'Triage agent',
instructions: promptWithHandoffInstructions('Hand off billing and payment questions to the Billing agent.'),
model: 'deepseek-ai/DeepSeek-V4-Pro',
handoffs: [billingAgent],
});
const result = await run(triageAgent, 'I was charged twice for order A-1001. Can you check?');
console.log(result.lastAgent?.name);
console.log(result.finalOutput);The run ends on the Billing agent, so lastAgent.name prints Billing agent, followed by its reply.
Use any catalog model
Change model to any ID from the catalog. The same tool runs on openai/gpt-5.4-mini:
model-switch.mts
import './devup-config.mts';
import { Agent, run, tool } from '@openai/agents';
import { z } from 'zod';
const getOrderStatus = tool({
name: 'get_order_status',
description: 'Look up the shipping status and tracking number of an order.',
parameters: z.object({ orderId: z.string() }),
execute: async ({ orderId }) => 'Order ' + orderId + ': shipped, tracking number DZ-4471.',
});
const agent = new Agent({
name: 'Support agent',
instructions: 'Use get_order_status to look up orders before you answer.',
model: 'openai/gpt-5.4-mini',
tools: [getOrderStatus],
});
const result = await run(agent, 'What is the tracking number for order A-1001?');
console.log(result.finalOutput);Troubleshooting
- "Set DEVUP_API_KEY before running your agents."devup-config.mts stops with this message when the key is not set. Set DEVUP_API_KEY in the same terminal that runs node.
- Trace export messagesKeep setTracingDisabled(true) in devup-config.mts so the SDK does not send traces to OpenAI.
FAQ
Does the OpenAI Agents SDK for TypeScript work with DEVUP AI?
Yes. Set a default OpenAI client with baseURL https://api.devupai.com/v1 and your DEVUP AI key. Agents, tools, handoffs, streaming and structured output then run on DEVUP AI models.
Which API does the SDK use with DEVUP AI?
The Responses API, POST /v1/responses, which is the SDK's default. No extra setting is needed.
Which models can my agents use?
Any model ID from the DEVUP AI catalog, written exactly as listed, such as deepseek-ai/DeepSeek-V4-Pro or openai/gpt-5.4-mini.
Do I need a model provider or prefix settings?
No. The TypeScript SDK sends the model ID exactly as written, so setDefaultOpenAIClient is the only connection setting.
How do I stop the SDK from sending traces to OpenAI?
Call setTracingDisabled(true) once at startup, as devup-config.mts does.
Is there a Python version of this guide?
Yes. The OpenAI Agents SDK guide covers the Python SDK with the same examples.
Related integrations
- OpenAI Agents SDK: Agents with tools, handoffs and streaming on DEVUP AI models.
- Mastra: Build Mastra agents in TypeScript on DEVUP AI with @ai-sdk/openai-compatible.
- TanStack AI: Use TanStack AI with DEVUP AI through its openaiCompatible adapter.
- Vercel AI SDK: Use the devupai provider with generateText and streamText in Next.js and React apps.