SDK

TypeScript SDK

Full reference for the TypeScript/Node.js SDK.

TypeScript SDK

The TypeScript SDK is fully typed and works in Node.js 18+ and edge runtimes like Cloudflare Workers and Vercel Edge.

Creating a Client

Import AgentClient from @ai-agent/sdk and initialize it with your API key. The client is thread-safe and can be shared across requests.

Running an Agent

Call client.agents.run() with your agent ID and input. The method returns a typed result object including the final output and a full trace of steps taken.

Type Safety

Tool inputs, outputs, and agent configs are all represented as TypeScript types. Use Zod schemas to define tool parameter types with automatic validation.

Installation

npm install @queue/sdk

Requires Node.js 18+. The package ships with full TypeScript types — no @types package needed.

Initializing the client

import { QueueClient } from ‘@queue/sdk’; const client = new QueueClient({ apiKey: process.env.QUEUE_API_KEY, });

If apiKey is omitted, the client reads QUEUE_API_KEY from the environment. Initialize the client once and share it — it is safe to reuse across concurrent requests.

Running an agent

const result = await client.agents.run({ agent: ‘refactor-agent’, goal: ‘Add JSDoc comments to all exported functions in src/utils’, context: [ { type: ‘file’, path: ‘src/utils/index.ts’ }, ], }); console.log(result.output); console.log(`Completed in ${result.steps} steps`);

Streaming output

const stream = await client.agents.stream({ agent: ‘refactor-agent’, goal: ‘Write unit tests for the payments module’, }); for await (const event of stream) { if (event.type === ‘token’) process.stdout.write(event.data); if (event.type === ‘done’) console.log(‘\nDone:’, event.result); }

Defining custom tools

import { tool } from ‘@queue/sdk’; import { z } from ‘zod’; const getTicket = tool({ name: ‘get_linear_ticket’, description: ‘Fetch a Linear ticket by ID and return its title and description.’, input: z.object({ id: z.string().describe(‘The Linear ticket ID, e.g. ENG-1234’) }), execute: async ({ id }) => { return await linearClient.issue(id); }, });

TypeScript config

The SDK requires moduleResolution: bundler or node16 in your tsconfig.json. If you see import resolution errors, check that your tsconfig targets ES2020 or later.

On this page

Create a free website with Framer, the website builder loved by startups, designers and agencies.