RaiCentral

docs / quickstart-typescript

Quick start (TypeScript)

Page summary

Install the Node.js SDK and authorize an action before any side effect.

Install: npm install @ztechnium/rai-sdk. Requires Node.js 18 or later. Keep agent keys on the server — never embed them in a browser bundle.

Minimal flow: new RAIClient({ baseUrl, apiKey, integrationId }); await heartbeat(); startSession(); observeInput(); authorizeAction(); execute only when decision.allowed; reportExecution(); end().

Example:
import { RAIClient } from "@ztechnium/rai-sdk";

const client = new RAIClient({
  baseUrl: process.env.RAI_BASE_URL!,
  apiKey: process.env.RAI_AGENT_KEY!,
  integrationId: process.env.RAI_INTEGRATION_ID!,
});

await client.heartbeat();
const session = await client.startSession({ channel: "application" });
await session.observeInput({ content: "Create an order" });
const decision = await session.authorizeAction({
  tool: "create_order",
  parameters: { amount: 100, currency: "USD" },
});
if (decision.allowed) {
  await decision.reportExecution(client, { status: "SUCCEEDED" });
}
await session.end();

Never execute a consequential side effect before RaiCentral returns ALLOW. Only decision.allowed === true means proceed.

Optional helpers in the same session: observeOutput, recordUsage / recordModelCall for metering, authorizeDataAccess for structured-data controls, and approval status polling when REQUIRE_APPROVAL is returned.

Full reference: https://github.com/ztechnium/rai-typescript-sdk

Install

$ npm install @ztechnium/rai-sdk

Requires

$ Node.js 18+ and server-side runtime credentials

Tags:sdktypescript