Security
Where your keys, audio and transcripts go when you use VoiceAI SDK, and how to report a vulnerability.
VoiceAI SDK is a library that runs in your process. It calls each provider directly with your credentials, and it does not store audio or transcripts. This page explains where data goes and what is up to you.
Keys stay on the server
Adapters read credentials from environment variables, such as DEEPGRAM_API_KEY, or from the options you pass to the factory. Open sessions on your server only. A browser bundle that imports a provider adapter ships the key to every visitor.
# .env on the server. Keep it out of version control and out of client bundles.
DEEPGRAM_API_KEY=dg_...
ELEVENLABS_API_KEY=sk_...To use a microphone in the browser, stream the audio to your server over a WebSocket and attach it with webSocketAudio(ws) from voiceai-sdk/ws. The browser sends audio. It never sees a key.
Check callers before you open a session
Every session uses your provider account. Check who is connecting before you open one, and set idleTimeoutMs so sessions that stop receiving audio close.
import { createSession } from "voiceai-sdk";
import { deepgram } from "voiceai-sdk/deepgram";
import { webSocketAudio } from "voiceai-sdk/ws";
import { isSignedIn } from "./auth.js"; // your own check, such as a session cookie
Bun.serve({
port: 3000,
async fetch(req, server) {
if (!(await isSignedIn(req))) return new Response("unauthorized", { status: 401 });
return server.upgrade(req) ? undefined : new Response("upgrade required", { status: 426 });
},
websocket: {
async open(ws) {
await using session = await createSession(deepgram(), { idleTimeoutMs: 30_000 });
session.connect(webSocketAudio(ws));
await session.converse(async (text) => `You said: ${text}`);
},
},
});No relay in between
There is no VoiceAI-hosted server. Audio goes from your server straight to the provider's API, or through the vendor's SDK for Google Cloud, Azure and AWS. Nothing passes through a VoiceAI service on the way.
| Provider | Where audio goes |
|---|---|
| Cloud providers | Your server, then the provider you chose |
local() | Nowhere else. whisper.cpp and Piper run on your machine |
mock() | Nowhere. It runs in your process with no network |
So the parties that handle your audio are your own servers, the transport you connect, such as Twilio or LiveKit, and the speech provider.
What is stored
The SDK does not store audio or transcripts. It does not write them to disk, and it sends them nowhere except the provider and the transport you connected.
Retention is decided by the provider. Whether a provider keeps audio or transcripts, and for how long, is set by that provider's terms and your account settings with it. Check both before you send real calls.
Logging
The SDK does not log audio or transcript text. A VoiceError carries a code, the provider name, a message and the underlying cause. Log code and provider freely. cause comes from the provider and can include request details, so review it before you send it to a log service.
session.on("error", (err) => {
console.error(JSON.stringify({ session: session.id, code: err.code, provider: err.provider }));
});Transcripts you log yourself, from listen, converse or the transcript event, are your users' words. Treat those logs as user data.
Session keys and metadata
A session key and metadata are identifiers, not secrets. Session keys show up in listSessions and in npx voiceai-sdk sessions list. Put labels in metadata, such as a tenant or a call id. Never put API keys, tokens or passwords in either.
import { createSession } from "voiceai-sdk";
import { deepgram } from "voiceai-sdk/deepgram";
const callId = crypto.randomUUID();
await using session = await createSession(deepgram(), {
key: `call:${callId}`,
metadata: { tenant: "acme", callId },
// Never: metadata: { apiKey: process.env.DEEPGRAM_API_KEY }
});A key built from a phone number, such as caller:+15551234567, is personal data. Anyone who can list your sessions can read it.
Report a vulnerability
Report security issues privately, as described in the security policy on GitHub. Don't open a public issue for a vulnerability. Include the SDK version, the provider, and the steps to reproduce it.