Self-Hosting

Run the entire VoiceLayer stack on your own infrastructure. The SDK and server are MIT licensed — no vendor lock-in.

Why self-host?

Self-hosting removes managed features: API key auth, usage dashboard, and rate limiting. You'll manage these yourself.

Requirements

Setup

# Clone the repo
git clone https://github.com/klhenry/voicelayer-sdk
cd voice-layer/packages/server

# Install dependencies
npm install

# Set your Deepgram key
export DEEPGRAM_API_KEY=your_deepgram_key

# Start the server
npm start
# Server running at ws://localhost:3001

Point the SDK at your server

<script
  src="https://voicelayer.co/sdk.js"
  data-key="any_string"
  data-ws-url="wss://your-server.com/ws"
  data-show-branding="false">
</script>

Or with npm:

VoiceLayer.init({
  apiKey: 'any_string',  // not validated when self-hosting
  wsUrl: 'wss://your-server.com/ws',
  showBranding: false,
});

Environment variables

VariableRequiredDescription
DEEPGRAM_API_KEYYesYour Deepgram API key for Nova-3 streaming STT
PORTNo (default: 3001)HTTP/WebSocket server port
CLERK_SECRET_KEYNoEnables API key authentication via Clerk (hosted feature)

Deploy to Railway

cd packages/server

# Install Railway CLI
npm i -g @railway/cli

# Deploy
railway login
railway init
railway up

# Set env vars
railway variables --set "DEEPGRAM_API_KEY=your_key"

Docker

Docker support is coming soon. Track progress on GitHub Issues.

WebSocket endpoint

The server exposes a single WebSocket endpoint at /ws. Connect with an Authorization: Bearer <key> header or ?key=<key> query parameter.

The server proxies audio to Deepgram and forwards transcript events back to the client in the same format Deepgram uses — the SDK handles everything automatically.