TypeScript SDK

Run agents from your own backend: stream a run token by token, schedule tasks, isolate each of your customers, and verify webhooks. Typed end to end, no dependencies.

Alpha. @m8tes/sdk publishes under the alpha dist-tag (npm i @m8tes/sdk@alpha). Method signatures may change before 1.0; the streaming wire protocol (m8tes.stream.v2) is semver-stable.

Install

Terminal

Node 18+, Deno, or Bun. Zero dependencies. verifySignature uses node:crypto, so an edge runtime needs Node compatibility enabled.

Your first run

new M8tes() reads M8TES_API_KEY from the environment. runs.create() returns a stream you can iterate immediately:

TypeScript

Nothing to configure first: a brand-new key auto-provisions a default agent, so the run above works on a fresh account.

Everything past this point is the same product you already read about elsewhere, so it lives on the page that owns it. Pages marked TS carry a TypeScript tab beside their Python example; the rest describe behaviour that is identical in both languages:

WhatWhere
Per-customer isolation with user_id, budgets, usageMulti-tenancy TS
Streaming events, iterText, typed event unionStreaming TS
Creating, replying to, cancelling and inspecting runsRuns TS
Schedules, webhooks, email and app-event triggersTasks · Scheduling
Approval and question gatesHuman-in-the-Loop
Signature verification and event payloadsWebhook Events TS
Typed errors, errorCode, retryAfterErrors
Auto-paging list() resultsPagination

Naming

Request params and response fields are the API's own snake_case (user_id, agent_id, created_at, output_data, schedule_timezone), identical to the API reference and the Python SDK, so a field you read in the docs is the field you type. One deliberate exception: agent_id is the canonical name and maps to the wire's teammate_id (the DB model's name), exactly as the Python SDK does. Both spellings are accepted.

What the SDK owns rather than sends stays camelCase: client options (new M8tes({ apiKey })), method names (createAsync, iterText, enableWebhook), RunStream members (stream.runId, stream.output, stream.errors), and stream events (event.requestId, event.questions).

Server-only

This package holds your secret m8_ key, so it throws if constructed in a browser: a bundled key is readable by every visitor. To render an agent in a browser, use @m8tes/react, which pairs a <MateChat> component with a locked-down server proxy that keeps the key on your server. Both packages share one wire-protocol implementation, so the events are identical on either side. See Embed a UI.

Next: Quick Start · Streaming · Multi-tenancy · Embed a UI

Was this page helpful?