On this page

Overview

One TypeScript API for voice agents on OpenAI Realtime, Deepgram, ElevenLabs, Cartesia, and 8 more providers.

VoiceAI SDK gives your code a voice session: a connection that turns speech into text, text into speech, and keeps a conversation going in real time. You use the same TypeScript API whether the audio is processed by Whisper on your laptop or by a cloud provider.

This is the MIT-licensed voiceai-sdk package on npm. It ships 11 cloud provider adapters plus Local (Whisper and Piper) and Mock. Install lists which providers need an extra package.

It is for two kinds of app. One gives an AI agent a voice: the model listens to a caller, answers, and can be interrupted. The other processes audio your users record, such as meeting notes or voice messages. Both need speech-to-text and text-to-speech you can swap without rewriting.

TypeScript
import { createSession } from "voiceai-sdk";
import { local } from "voiceai-sdk/local";

await using session = await createSession(local());

const result = await session.transcribe(await Bun.file("hello.wav").bytes());
console.log(result.text);

That opens a session, transcribes one file, prints the text, and closes the session when the block ends. Swap local() for openai(), deepgram(), or azure() and nothing else changes.

Start here

What you can build

Providers

Works with your stack

How it differs

  • Your keys, no middleman. The SDK calls each provider's API or SDK with your credentials. No audio passes through a VoiceAI server.
  • It never quietly ignores an option. If you ask a provider for diarization or a sample rate it can't deliver, createSession fails with unsupported instead of returning something different from what you asked for.
  • Silence is a result. A recognition that hears no speech comes back as ok: false with a reason. The SDK throws only when the session or the provider fails.
  • Sessions come back. Give a session a key and a caller who reconnects, on any server, gets the same one with its history.

The SDK does not store audio or transcripts. The provider you choose decides what is retained and for how long. See Security.

Was this page helpful?

Esc

Loading…

↑↓ navigate openCtrl J preview