Use video-to-text-js to upload media, create transcription tasks, and poll for results.
The Node.js client wraps the public upload and task APIs with typed helpers.
Install
Section titled “Install”pnpm add video-to-text-jsInitialize
Section titled “Initialize”import { VideoToTextClient } from 'video-to-text-js'
const client = new VideoToTextClient({ apiKey: process.env.VTT_API_KEY!,})Transcribe a file
Section titled “Transcribe a file”import { readFile } from 'node:fs/promises'
const file = await readFile('meeting.mp4')
const task = await client.transcriptions.transcribeFile(file, { filename: 'meeting.mp4', mimetype: 'video/mp4', language: 'Auto', timestampMode: 'CHUNK', transcriptionMode: 'balanced', timeoutMs: 10 * 60 * 1000,})
console.log(task.fullText)Use precision when accuracy is more important than credit cost.
Upload and create manually
Section titled “Upload and create manually”const upload = await client.uploads.create({ filename: 'meeting.mp4', mimetype: 'video/mp4',})
await client.uploads.put(upload.uploadUrl, file, { mimetype: 'video/mp4',})
const asset = await client.uploads.complete(upload.uploadId, { fileKey: upload.fileKey, fileUrl: upload.fileUrl, filename: 'meeting.mp4', mimetype: 'video/mp4', fileSize: file.byteLength,})
const created = await client.tasks.create({ assetId: asset.assetId, language: 'Auto', timestampMode: 'CHUNK', transcriptionMode: 'balanced',})
const result = await client.tasks.wait(created.transcriptId)console.log(result.fullText)Task results
Section titled “Task results”tasks.wait() returns when the task reaches SUCCEEDED. If the task reaches FAILED or CANCELED, the client throws an APIError and uses showError as the error detail when available.
Task details include fullText, chunks, words, sourceDurationMs, resultLanguage, transcriptionMode, and billedCredits.
Errors
Section titled “Errors”import { APIError, RateLimitError, UploadError } from 'video-to-text-js'
try { await client.transcriptions.transcribeFile(file, { filename: 'meeting.mp4', mimetype: 'video/mp4', })} catch (error) { if (error instanceof RateLimitError) { console.error('Please retry later.') } else if (error instanceof UploadError) { console.error('The media upload did not complete.') } else if (error instanceof APIError) { console.error(error.errorCode, error.detail) }}Resources
Section titled “Resources”For source code, issues, and contributions, visit the video-to-text-js GitHub repository. Install the latest video-to-text-js package from npm.