Skip to content

SDK Quickstart

The @tanzanite/sdk is a lightweight, zero-dependency TypeScript SDK. It works in browsers and Node.js 18+ (it uses native fetch).

Terminal window
npm install @tanzanite/sdk
import { Tanzanite } from "@tanzanite/sdk";
// Initialize the client with your API key
const client = new Tanzanite({ apiKey: "tanzanite_your_key_here" });
// Create a session
const session = await client.createSession({
goal: "Design a challenging game level",
context: { projectId: "proj_1", sceneId: "scene_main" },
});
// Poll for new messages and status until the session finishes
const TERMINAL = ["complete", "failed", "cancelled"];
let after: string | undefined;
while (true) {
const info = await session.getInfo();
const { messages } = await session.getMessages({ after, limit: 50 });
for (const msg of messages) {
console.log(`[${msg.role}] ${msg.content}`);
after = msg.roundId; // advance the cursor so we only fetch new messages
}
if (info.status === "waiting_human") {
// The agent is blocked on a question — respond, then keep polling.
// See Sessions → Human input for choice / free-text responses.
}
if (TERMINAL.includes(info.status)) {
console.log("Done:", info.status, info.completionReport ?? "");
break;
}
await new Promise((r) => setTimeout(r, 2000)); // poll every 2s
}
OptionTypeDefaultDescription
apiKeystring(required)Your Tanzanite API key
baseUrlstringhttps://api.tanzanite.devAPI base URL
wsUrlstring(derived from baseUrl)Reserved for streaming (not yet available)
timeoutnumber30000Request timeout in milliseconds

Point the SDK at your own deployment:

const client = new Tanzanite({
apiKey: "tanzanite_your_key_here",
baseUrl: "https://your-self-hosted-api.example.com",
});
  • Node.js 18+ (native fetch) or any modern browser
  • TypeScript 5.4+ for development