Skip to content

TypeScript SDK

Official TypeScript client with full typing, retry logic, WebSocket streaming, and Node.js/browser support. Source: api-client.

Terminal window
npm install @responsivevoice/api-client
import { ResponsiveVoiceAPIClient } from '@responsivevoice/api-client';
const client = new ResponsiveVoiceAPIClient({
apiKey: process.env.RESPONSIVEVOICE_API_KEY,
apiSecret: process.env.RESPONSIVEVOICE_API_SECRET,
});
// Synthesize
const 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 request
const controller = new AbortController();
setTimeout(() => controller.abort(), 5_000);
await client.synthesize(
{ text: 'Long text…', voice: 'UK English Female' },
{ signal: controller.signal },
);

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.

  • Node 18+: works out of the box (native fetch, Blob, AbortController).
  • Node 16–17: pass a fetch polyfill via the fetch config option.
  • Node < 22 + WebSocket streaming: pass a WebSocket implementation (e.g. ws) to WebSocketConnection.