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.
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
Install
Add the package, and a provider's SDK for the few providers that need one.
Quickstart
Run your first session in memory with no account, then on your machine.
Choose a provider
Pick where speech is processed, based on what your app needs.
Compare providers
See which features each provider supports, side by side.
What you can build
Give your agent a voice
Connect a model to a voice session so it can listen, answer and be interrupted.
Build a phone agent
Answer a phone call over Twilio and hold a conversation on it.
One session per caller
Give each caller a session that is still there when they reconnect.
Interruptions and barge-in
Stop speaking when the caller talks, and pick up where it makes sense.
Providers
Local
Whisper and Piper on your machine. No account.
OpenAI Realtime
Speech in, speech out, in one model.
Deepgram
Streaming transcripts with word timings and speakers.
ElevenLabs
Text-to-speech in a large library of voices.
Mock
An in-process fake for unit tests.
Write a provider
Adapt any other speech service to the same API.
Works with your stack
AI SDK
Voice tools for generateText and streamText.
Mastra
A tool map for a Mastra agent.
OpenAI Agents
A tool array for the OpenAI Agents SDK.
MCP
An MCP server and the voiceai-sdk mcp CLI.
Twilio
Phone calls over Twilio Media Streams.
LiveKit
Join a LiveKit room as a participant.
CLI
Check setup with doctor, transcribe files, and list voices.
All integrations
Everything in one place.
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,
createSessionfails withunsupportedinstead of returning something different from what you asked for. - Silence is a result. A recognition that hears no speech comes back as
ok: falsewith 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.