SDK
SDK: installation and quick start
The official TypeScript/JavaScript client. Isomorphic (Node 18+ and the browser), zero runtime dependencies, built on native fetch.
Installation
npm
npm install @aist-packages/aist-agent-sdk
Quick start
index.ts
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
new AistAgentClientstores thebaseUrland the JWT — the token is sent asAuthorization: Bearerwith every request.createTaskqueues the task and returns itsuuidright away.waitForTaskpolls the status until it lands instopOnand returns the finalTask.
The textInput, fileInput and voiceInput helpers build input
items with the right type.
Which assistants are available
No need to ask anyone for assistant_id and llm_model_id — the API returns them itself (since 0.4.0):
const assistants = await client.listAssistants(); // [{ id, slug, title, … }] const writer = await client.getAssistant('writer'); // { …, models: [{ id, label, is_default }] } const me = await client.getMe(); // token expiry, limits, active tasks
The list matches the catalog on the website: hidden assistants aren’t in it — their IDs come from your administrator. More in Assistants.
Features
- Strict typing of the wire format:
Task,Turn,InputItemand so on. - Isomorphic — the same code for Node 18+ and the browser, native
fetch/FormData. - Client tools —
runTaskwalks through the interrupt cycle for you. - Typed errors — a subclass for every HTTP status.