On this page

Upgrade from 0.2

What changed between 0.2 and 1.0, and how to move each call to the new API.

1.0 replaces the separate transcriber and synthesizer clients with one session, moves every provider to its own subpath, and turns failed recognitions into results instead of exceptions. Most apps upgrade by changing imports and a few call sites.

Install 1.0

npm install voiceai-sdk@1

The package is now ESM only and needs Node 22 or later.

One session instead of two clients

0.2 had createTranscriber and createSynthesizer. 1.0 has createSession, which does both.

0.21.0
createTranscriber({ provider: "deepgram" })createSession(deepgram())
createSynthesizer({ provider: "elevenlabs" })createSession(elevenlabs())
Both, wired by handcreateSession({ stt: deepgram(), tts: elevenlabs() })
transcriber.recognize(buffer)session.transcribe(buffer)
transcriber.stream(source) eventsfor await (const t of session.listen(source))
synthesizer.synthesize(text)session.speak(text)
client.destroy()await using, or session.close()

Provider imports

Providers are no longer chosen by a string. Import the factory from its subpath:

TypeScript
// 0.2
import { createTranscriber } from "voiceai-sdk";
const transcriber = createTranscriber({ provider: "deepgram", apiKey: process.env.DEEPGRAM_API_KEY });

// 1.0
import { createSession } from "voiceai-sdk";
import { deepgram } from "voiceai-sdk/deepgram";
await using session = await createSession(deepgram());

Errors

In 0.2, audio with no speech threw NoSpeechError. In 1.0 it resolves with ok: false and reason: "no_speech". Errors that are still thrown are VoiceError instances with a code; see Errors.

TypeScript
const result = await session.transcribe(audio);
if (!result.ok) console.log("nothing heard:", result.reason);

Options that fail loudly

0.2 dropped options a provider didn't support. 1.0 throws unsupported from createSession instead. If an upgrade starts failing there, check the option against Capabilities and remove it or switch providers.

Was this page helpful?

Esc

Loading…

↑↓ navigate openCtrl J preview