TypeScript · Isomorphic · Zero dependencies

Agent SDK for
TypeScript and JavaScript

The official client for the AIST Agent gateway. Create tasks, poll for results, run the client tool interrupt loop automatically and upload files — on native fetch, in Node 18+ and the browser.

npm @aist-packages/aist-agent-sdk
$ npm install @aist-packages/aist-agent-sdk

Strictly typed

Full types for the wire format: Task, Turn, InputItem and more. Autocomplete out of the box.

Isomorphic

The same code for Node 18+ and the browser. Native fetch and FormData, no runtime dependencies.

Client tools

runTask handles the interrupt loop for you: the model calls a tool — the SDK runs your handler and carries on.

Typed errors

A subclass for every HTTP status: Unauthorized, RateLimit, Validation and others.

Quick start

Create a client, send a task and wait for the result — just a few lines.

index.ts Create a task and wait for the result
import { AistAgentClient, textInput } from '@aist-packages/aist-agent-sdk';
const client = new AistAgentClient({
  baseUrl: 'https://agent.aist-ai.com',
  token: process.env.AIST_AGENT_TOKEN!, // JWT (RS256)
});
const { uuid } = await client.createTask({
  assistant_id: 1,
  input: [textInput('Hi! Who are you?')],
});
// Poll until a terminal status
const task = await client.waitForTask(uuid, {
  stopOn: ['completed', 'failed'],
});
console.log(task.turn?.output);

What’s going on here

  • 1 new AistAgentClient keeps the baseUrl and the JWT — the token is sent as Authorization: Bearer with every request.
  • 2 createTask queues the task and returns its uuid instantly.
  • 3 waitForTask polls the status until it hits one of stopOn and returns the final Task.
The textInput, fileInput and voiceInput helpers build input array items with the right type.

SDK docs

Client tools, file uploads, the full method reference and error handling — in depth, with examples.

Open the SDK docs

Development

The package is built with tsup into ESM, CJS and .d.ts. Tests run on vitest with a mocked fetch, no network.

$ npm install
$ npm run type-check # strict typing
$ npm test # vitest, no network
$ npm run build # tsup → dist/

For an end-to-end run against a live server, see the examples/ directory (npx tsx examples/client-tools.ts). License — MIT.

Integrating without the SDK?

The REST API is described on the home page, and machine-readable docs live in llms.txt — feed it to your coding assistant and it will generate an integration in any language.