1
Install
2
Create the client
3
Check the API and your key
4
Chat with an agent
Complete example
Save asindex.mjs (or use ESM in your project) and run node index.mjs:
Usage
Every client method.
Streaming
Stream replies with SSE.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
From npm install to your first ReyGrid chat reply with the TypeScript SDK.
Install
npm install reygrid
Create the client
import { ReyGrid } from "reygrid";
const client = new ReyGrid({ apiKey: process.env.REYGRID_API_KEY });
Check the API and your key
const { status } = await client.ping();
console.log("API status:", status); // "UP"
const usage = await client.getUsage();
console.log(`Usage: ${usage.total} / ${usage.quotaLimit}`);
Chat with an agent
const res = await client.chat("{AgentId}", "Hello!", { userId: "user-42" });
console.log(res.output.reply.content);
index.mjs (or use ESM in your project) and run node index.mjs:
import { ReyGrid, ReyGridAuthError, ReyGridNetworkError } from "reygrid";
const client = new ReyGrid({ apiKey: process.env.REYGRID_API_KEY });
try {
const usage = await client.getUsage();
console.log(`Usage: ${usage.total} / ${usage.quotaLimit}`);
const res = await client.chat("{AgentId}", "Hello!", { userId: "user-42" });
console.log(res.output.reply.content);
} catch (err) {
if (err instanceof ReyGridAuthError) console.error("Invalid API key");
else if (err instanceof ReyGridNetworkError) console.error("Network problem:", err.message);
else throw err;
}