TypeScript SDK
Official TypeScript client with full typing, retry logic, WebSocket streaming, and Node.js/browser support. Source: api-client.
Installation
Section titled “Installation”npm install @responsivevoice/api-clientQuick Start
Section titled “Quick Start”import { ResponsiveVoiceAPIClient } from '@responsivevoice/api-client';
const client = new ResponsiveVoiceAPIClient({ apiKey: process.env.RESPONSIVEVOICE_API_KEY, apiSecret: process.env.RESPONSIVEVOICE_API_SECRET,});
// Synthesizeconst audio = await client.synthesize({ text: 'Hello world', voice: 'UK English Female', format: 'mp3',});console.log(audio.blob, audio.url, audio.format);
// List voices (with optional filters)const { voices } = await client.getVoices({ lang: 'en-GB', gender: 'female' });
// Cancel a requestconst controller = new AbortController();setTimeout(() => controller.abort(), 5_000);await client.synthesize( { text: 'Long text…', voice: 'UK English Female' }, { signal: controller.signal },);Authentication
Section titled “Authentication”Server-side callers send an apiKey + apiSecret pair (the client attaches them as X-API-Key + X-API-Secret). Get both from your website's settings in the ResponsiveVoice dashboard (sign up): the API key from the "Your site code" snippet, and the API secret under "Server-to-server API secrets" (shown only once, revocable). Keep the secret server-side — browser apps use @responsivevoice/core, which authenticates by origin and needs no secret.
Runtime Notes
Section titled “Runtime Notes”- Node 18+: works out of the box (native
fetch,Blob,AbortController). - Node 16–17: pass a
fetchpolyfill via thefetchconfig option. - Node < 22 + WebSocket streaming: pass a
WebSocketimplementation (e.g.ws) toWebSocketConnection.
Reference Documentation
Section titled “Reference Documentation”- API Reference (TypeDoc) — complete typed API surface
- Package README on GitHub — full walkthrough, all configuration options, error taxonomy, retry tuning