Skip to content

TypeScript SDK

SDK Download

Setup

Download the TypeScript SDK archive from SDK Overview, extract it, then install it into your project.

npm install <PATH_TO_EXTRACTED_TYPESCRIPT_SDK>

Configure the shared environment variables from Getting Started, and point KOLDAN_FILE_PATH to the audio file you want to transcribe.

Upload And Transcribe With uploadAndTranscribe

The example below keeps the request intentionally minimal: upload one file, start transcription with the general model alias, poll until the job finishes, and print either the transcript or the error details.

import { readFile } from "node:fs/promises";
import path from "node:path";
import { Configuration, SpeechTranscriptionsApi, TranscriptionJobStatus } from "koldan-sdk";

const config = new Configuration({
  basePath: process.env.KOLDAN_BASE_URL,
  apiKey: process.env.KOLDAN_API_KEY,
});

const filePath = process.env.KOLDAN_FILE_PATH!;
const file = new File([await readFile(filePath)], path.basename(filePath));
const api = new SpeechTranscriptionsApi(config);

const response = await api.uploadAndTranscribe({
  name: "meeting-recording",
  file,
  transcription: JSON.stringify({
    model: "general",
    punctuation: false,
    capitalization: false,
  }),
  diarization: JSON.stringify({ enabled: false }),
});

let job = response.job!;
while (true) {
  job = await api.getJob({ id: job.id! });
  console.log(`Job status: ${job.status}`);

  if (job.status && [TranscriptionJobStatus.Completed, TranscriptionJobStatus.Failed, TranscriptionJobStatus.Cancelled].includes(job.status)) {
    break;
  }

  await new Promise((resolve) => setTimeout(resolve, 2000));
}

console.log(job.status === TranscriptionJobStatus.Completed ? job.result?.text : job.errors);

Run

npx tsc
node dist/upload-file.js

Expected Result

A successful run prints Job status: ... updates and then the transcription text from your uploaded audio.

If the job fails, the example prints the error array returned by the API.