The VocalStack speech API for Node (20 or newer) and browsers: one client,
VocalStack, with one group per resource, typed from the API's one OpenAPI
document (/v1/openapi.json, generated into @vocalstack/contract).
Read more about the VocalStack JavaScript SDK and our other SDKs on the VocalStack website.
import { VocalStack } from '@vocalstack/js-sdk';
const vs = new VocalStack({ apiKey: process.env.VOCALSTACK_API_KEY }); // baseUrl defaults to https://api.vocalstack.com
// A stored transcription of a link (or `file:` a path, Blob or bytes).
const tx = await vs.transcriptions.create({ url: 'https://example.com/talk.mp3' });
const job = await vs.jobs.wait(tx.job!.recordingId); // done | failed | cropping
const { sentences } = await vs.recordings.transcript(job.recordingId);
const srt = await (await vs.recordings.export(job.recordingId, 'srt')).text();npm install @vocalstack/js-sdk- Quickstart: An API key, the SDK, and your first transcript in a dozen lines.
- Transcribe a file: Upload a file, wait for its job, read the transcript and export it. Asynchronous; nothing to keep open.
- Transcribe a link: The server fetches a public URL, a YouTube video or a recording on a video or audio site, then transcribes it like a file. Asynchronous, with a fetch phase first.
- Search your transcriptions: Find transcriptions by words in their name or link, site, language, kind, tag and date, keep the shared ones, and play each with its share code.
- Stream a microphone: Live audio in, transcript events out, over one WebSocket. Drafts replace the live tail; commits append.
- Stream a file at full speed: Send a file's bytes through a realtime session and read the transcript as fast as the server makes it. Nothing is stored.
- Go live: Publish live audio to a stored transcription, and put it on a broadcast link listeners open. Control is HTTP; audio is one WebSocket.
- Listen: Follow a recording as it happens, in any language: subscribe, catch up from a snapshot, then apply live frames in order.
- Live translation and spoken translations: Translate a stream as it is spoken, and have each translated sentence spoken back in a voice. Text frames and audio clips, over the same socket.
- Connect an app with one click: Let the people who use your app connect their VocalStack account with one Authenticate click — OAuth 2.0 authorization code with PKCE, where the access token is an API key — instead of pasting a key.
- Errors, retries and limits: One error envelope everywhere; what to retry (429, 503 unavailable) and how to make a retry safe (Idempotency-Key); credit, plan limits and the 402s.
| Name | What it is | Group |
|---|---|---|
| realtime session | a signed token plus one socket; nothing stored | vs.realtime |
| broadcast | the link listeners open | vs.broadcasts |
| transcription | a file, link, microphone or stream, transcribed and stored (live: true for a microphone or stream) |
vs.transcriptions |
| recording | one take inside a broadcast or a transcription | vs.recordings |
| job | a file or link recording's transcription work | vs.jobs |
The other groups: vs.corrections, vs.shareLinks, vs.speakers, vs.voices,
vs.search, vs.me, vs.languages, vs.rtmp, vs.events, vs.meta.
Method names follow the document's operationIds (broadcasts.startRecording
is POST /v1/broadcasts/{id}/recordings); lists return arrays.
new VocalStack({
baseUrl, // default https://api.vocalstack.com
apiKey, // an API key (vs_key_…), for a server
token, // or, in a browser: an access token / browser token, or a getter (read per request)
actingPrincipal, // act for an organization (X-Acting-Principal)
deviceId, // correlation only (X-Device-Id)
fetch, // any fetch
maxRetries: 2, // 429s, and 503 unavailable on safe calls, retried after Retry-After (at most 60 s each)
readyDeadlineMs, // how long a realtime socket may take to report ready
});Every call that creates something takes { idempotencyKey } last.
const session = await vs.realtime.connect({ spokenLanguage: 'en' });
session.sendAudio(pcmChunk); // raw PCM, f32le, 16 kHz, mono, as binary frames
for await (const event of session) {
if (event.type === 'transcript.committed') render(event.segment);
}
session.eof(); // at end of source: final commits, then session.done
// A whole file through one socket, nothing stored:
const { text, segments } = await vs.realtime.transcribeFile('meeting.mp3', { spokenLanguage: 'en' });transcript.draftframes fully replace the live tail; never append them.transcript.committedsegments are immutable, gapless bysegment.seq, and carry word timings.- A dropped connection ends the session (no resume): start a new one.
const b = await vs.broadcasts.create({ name: 'Release standup' }); // b.code is the link
const grant = await vs.broadcasts.startRecording(b.id); // 409 conflict + details.takeover
// when another device records
const stream = await vs.recordings.publish(grant); // the publisher socket
await vs.recordings.pause(grant.recording.id);
await vs.recordings.resume(grant.recording.id);
await vs.recordings.stop(grant.recording.id); // only from paused
// A listener (no account), holding a share link's code:
const link = await vs.broadcasts.createShareLink(b.id, { label: 'Audience' });
const anon = new VocalStack({ baseUrl, deviceId });
const sub = await anon.recordings.subscribe(grant.recording.id, { lang: 'es', shareCode: link.code, asOwner: false });
for await (const ev of sub) {
if (ev.type === 'snapshot') render(ev.snapshot); // backfill, initial or after a gap
if (ev.type === 'frame') apply(ev.frame); // transcript.*, recording.state, ...
}Browser microphone capture ships as @vocalstack/js-sdk/mic
(streamMicrophone(session, { onStall, onRecover })).
VocalStackError carries code (the contract's closed enum), message,
status, retryable, details (quota numbers, code suggestions,
{ recordingId, takeover }), headers and retryAfter.
recordings.export, recordings.clip, recordings.voiceClip, jobs.preview,
voices.preview, speakers.voicePreview and speakers.sample return the
Response itself: .text(), .arrayBuffer() or stream it.
recordings.audioUrl returns the signed media URL.
Verified against a language-agnostic conformance suite shared by every
VocalStack SDK and against a running API. For agents: SKILL.md.