@voicepilot/sdk
v0.1.19
Published
Official VoicePilot JavaScript SDK — TTS, STT, Agents, and real-time conversations.
Maintainers
Readme
VoicePilot JavaScript SDK
Zero-dependency ES module for browser and Node.js 18+.
Install
npm install @voicepilot/sdk[!NOTE] Zero-Config ML: High-accuracy Voice Activity Detection (Silero VAD) is included out of the box. No extra packages or local model management required.
Quick Start
import { VoicePilotClient } from '@voicepilot/sdk';
const client = new VoicePilotClient({
apiKey: 'sk_platform_...',
baseUrl: 'https://voice.intelligens.app/api/v1',
});Services
TTS
const audio = await client.tts.create('Hello world!', 'anushka');
// audio.audios[0] → base64 WAV
// Streaming (returns raw audio/wav Response)
const stream = await client.tts.stream('Hello world!');
const blob = await stream.blob();STT
const result = await client.stt.transcribe(audioFile); // File or BlobAgents
const agents = await client.agents.list();
await client.agents.create('Support Bot', 'You are a helpful support agent.');
await client.agents.delete('agent_id');Real-Time Conversations (Create-First)
// connect() automatically calls /conversations/create first
const session = await client.agents.connect({
agentId: 'agent_id',
useSessionToken: true, // Browser-safe
});
session.on('agent.response', (evt) => {
console.log(`Agent (${evt.latency_ms}ms): ${evt.text}`);
});
session.on('agent.audio', (evt) => {
playAudio(evt.audio_base64);
});
session.init(); // Triggers greeting
session.send('What is your name?');
// Access conversation ID
console.log(session.conversationId); // "conv_abc123..."
// Explicit end via REST (alternative to session.close())
await client.conversations.end(session.conversationId);
// Or just close the WebSocket (auto-completes the conversation)
session.close();Conversation Lifecycle
// Manual create-first pattern (if not using agents.connect)
const conv = await client.conversations.create('agent_id');
// conv.conversation_id → pass to WebSocket URL
// End an active conversation
await client.conversations.end('conv_abc123');
// List past conversations
const logs = await client.conversations.list(20);
// Fetch full transcript
const full = await client.conversations.get('conv_abc123');Sessions (Browser-Safe Tokens)
const token = await client.sessions.create(300); // 5 min TTL
// token.session_token → "sess_abc123..."API Key Management
const newKey = await client.keys.create('read', 'analytics-dashboard');
const allKeys = await client.keys.list();
await client.keys.revoke('sk_platform_a1b2...');Webhooks
await client.webhooks.register('https://myapp.com/webhook');
const wh = await client.webhooks.get();
await client.webhooks.remove();Usage Dashboard
const usage = await client.usage.get();
// { total_requests, breakdown: { tts, stt, agents, ... }, rate_limit: { remaining } }