SDK reference

npm install @vaux/sdk

The package has two entry points: @vaux/sdk for browsers (realtime) and @vaux/sdk/server for servers (REST, token minting).

You can also load the browser build directly: import { createVauxClient } from 'https://vaux.ng/sdk/vaux.js'.

Server: Vaux

import { Vaux, VauxError } from '@vaux/sdk/server';

const vaux = new Vaux({ apiKey: process.env.VAUX_API_KEY });

await vaux.tokens.create({ maxMinutes: 15, expiresIn: 60, allowedModes: ['voice', 'type'] });
await vaux.voices.list();                 // → Voice[]
await vaux.sounds.list();                 // → Sound[]
await vaux.usage.get({ limit: 50 });      // → { credits, plan, sessions }
const { audio } = await vaux.tts.create({ text: 'Hello', voice: 'maya', emotion: 'excited', format: 'mp3' });

Errors throw VauxError with status, code and message.

Browser: createVauxClient

import { createVauxClient } from '@vaux/sdk';

const vaux = createVauxClient({
  apiKeyProvider: () => fetch('/api/vaux-token', { method: 'POST' }).then((r) => r.json()), // { token, streamUrl }
});

apiKeyProvider is called once per connect(). Return either the token string, or { token, streamUrl }.

vaux.realtime.connect(input, options)

OptionTypeDescription
voicestringVoice slug ("leo"), name or id
emotionstringStarting emotion
modevoice · type · agentDefault voice
languagestringen, es, fr, …, or multi to auto-detect
speed, volumenumberDelivery multipliers
latencyfast · balancedDefault fast
onAudioStream(MediaStream) => voidThe converted voice, ready for <audio>, WebRTC or recording
outputDeviceIdstringRoute output to a device (Chrome/Edge), e.g. a virtual microphone
monitorbooleanAlso play through the default speakers

input is the microphone MediaStream, or null for type/agent-only sessions. Returns a RealtimeSession.

RealtimeSession

MemberDescription
set({ voice, emotion, mode, speed, volume, language, latency })Update live
say(text, { emotion, interrupt })Speak typed text
sound(slugOrUrl, { rate, gain })Play a soundboard sound into the output
interrupt()Stop speech now
brief(text, name) · whisper(text) · respond()Agent controls
attachRemoteAudio(stream)Feed meeting audio to the agent
setOutputDevice(id) · setMonitor(on)Output routing
outputStreamThe converted MediaStream
on(event, fn) / off(event, fn)Events from realtime, plus connected, speaking, disconnected
disconnect()End the session
session.on('transcript', (t) => t.final && console.log(t.text));
session.on('speaking', ({ playing }) => avatar.setTalking(playing));
session.on('disconnected', ({ code }) => code === 4001 && alert('Session time is up'));