On this page

FAQ

Short answers to common questions about VoiceAI SDK, its providers, audio, and running it in production.

General

Is the API stable?

Not yet. VoiceAI SDK is a developer preview, and these docs describe the planned 1.0 API. Expect changes before 1.0. Upgrade from 0.2 lists what changed since 0.2.

Does my audio go through a VoiceAI server?

No. The SDK runs in your process and calls the provider directly with your keys. There is no VoiceAI-hosted relay. See Security.

Can I use it in the browser?

Not directly. Provider adapters need your API keys, and those must stay on the server. Stream audio from the browser to your server over a WebSocket and attach it with webSocketAudio(ws).

Providers

Can I use one provider for speech-to-text and another for text-to-speech?

Yes. Pass a pipeline, such as createSession({ stt: deepgram(), tts: elevenlabs() }). The session API is the same. See Choose a provider.

What happens if a provider can't do what I ask?

createSession throws a VoiceError with code unsupported. The SDK never ignores an option silently. See Capabilities and Compare providers.

Can I try it without an account?

Yes. mock() runs in memory with no network, and local() runs whisper.cpp and Piper on your machine. The Quickstart uses both.

Audio

Which audio formats can I use?

Set sampleRate to 8000, 16000, 24000 or 48000, and encoding to pcm16, mulaw or opus. Which combinations a provider accepts depends on the provider. One it can't use fails at createSession. See Latency and audio formats.

What happens when nobody speaks?

transcribe resolves with ok: false and reason: "no_speech". It doesn't throw. converse calls your handler only for final transcripts, so silence doesn't reach it.

TypeScript
const result = await session.transcribe(audio);

if (!result.ok && result.reason === "no_speech") {
  await session.say`Sorry, I didn't catch that.`;
}

Production

How do I keep a session when a caller reconnects?

Give the session a key, such as caller:+15551234567. When the caller reconnects, createSession with the same key returns the live session instead of opening a new one. See One session per caller.

How do I make sure sessions are closed?

Open them with await using, which closes the session when the scope ends, even on an error. session.close() is safe to call more than once, and idleTimeoutMs closes sessions that stop receiving audio. See Clean up sessions.

Was this page helpful?

Esc

Loading…

↑↓ navigate openCtrl J preview