TypeScript SDK
A dependency-free client for Node 18+, edge runtimes and browsers, using fetch and Web Crypto.
Install
Shell
npm install @26ai/sdkConfigure
TypeScript
import { Client } from "@26ai/sdk";
const client = new Client({ apiKey: process.env.TWENTYSIX_API_KEY, baseUrl: process.env.TWENTYSIX_BASE_URL });Keep the key on your server — never ship it to a browser.
Transcribe
TypeScript
import { readFile } from "node:fs/promises";
// Short audio, one request
const short = await client.transcribe(new Blob([await readFile("note.ogg")]), "mr-IN", { mode: "codemix" });
// Any length: upload → transcribe → wait → result
const result = await client.transcribeFile(await readFile("meeting.m4a"), "hi-IN", { diarization: true });
console.log(result.text);Step by step
TypeScript
const upload = await client.upload(bytes);
let job = await client.createTranscription(upload.id, "ta-IN", { channelMode: "separate", webhookEndpointId: "wh_…" });
job = await client.wait(job.id);
if (job.state === "completed" || job.state === "partial") {
const result = await client.result(job.id);
}Also: get, list, cancel, delete, usage, models and createWebhookEndpoint.
Errors
TypeScript
import { APIError } from "@26ai/sdk";
try {
await client.createTranscription(upload.id, "xx-XX");
} catch (e) {
if (e instanceof APIError) console.log(e.status, e.code, e.detail, e.requestId);
}429 and 503 are retried automatically, honouring Retry-After.
Webhooks
TypeScript
import { verifyWebhook } from "@26ai/sdk";
const ok = await verifyWebhook(secret, request.headers, rawBody);