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.
Full types for the wire format: Task, Turn, InputItem and more. Autocomplete out of the box.
The same code for Node 18+ and the browser. Native fetch and FormData, no runtime dependencies.
runTask handles the interrupt loop for you: the model calls a tool — the SDK runs your handler and carries on.
A subclass for every HTTP status: Unauthorized, RateLimit, Validation and others.
Create a client, send a task and wait for the result — just a few lines.
new AistAgentClient keeps the baseUrl and the JWT — the token is sent as Authorization: Bearer with every request.
createTask queues the task and returns its uuid instantly.
waitForTask polls the status until it hits one of stopOn and returns the final Task.
textInput, fileInput and voiceInput helpers build input array items with the right type.
Client tools, file uploads, the full method reference and error handling — in depth, with examples.
The automatic interrupt loop: the SDK calls your handler, sends the result back and carries on.
uploadFile in Node and the browser, building download links.
The constructor, low-level methods, the waitForTask/runTask helpers and key types.
The typed error hierarchy: a subclass for every HTTP status.
The package is built with tsup into ESM, CJS and .d.ts. Tests run on vitest with a mocked fetch, no network.
For an end-to-end run against a live server, see the examples/ directory
(npx tsx examples/client-tools.ts). License — MIT.
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.