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, resultText, and webhook management — createWebhookEndpoint, listWebhookEndpoints, verifyWebhookEndpoint, rotateWebhookSecret, disableWebhookEndpoint, listWebhookDeliveries, replayWebhookDelivery.
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);
}Retries are automatic and never charge twice:
429and503are retried, honouringRetry-After.- A network error is retried with the same idempotency key (so you get the original transcription, not a second one). Requests that are not safe to repeat, such as registering a webhook endpoint, are not retried.
transcribe()(short audio) acceptsidempotencyKey. Without one, the client creates a key and, after a503, retries with a new key. With your own key, a503is thrown to you — resend later with a new key. A504is never retried; usetranscribeFile()for recordings that need longer.- Large uploads resume from the server's offset after a dropped connection.
Webhooks
TypeScript
import { verifyWebhook } from "@26ai/sdk";
const ok = await verifyWebhook(secret, request.headers, rawBody);