Skip to main content
The official TypeScript SDK is published as @supertone/supertone on npm. Source: supertone-inc/supertone-ts.

At a glance

Installation

The package is published with both ESM and CommonJS entry points and ships with TypeScript types. Node 18+ is required (for the global fetch and ReadableStream). Works in Bun and Deno; not designed for the browser (your API key should never live client-side).

Set your API key

Voice IDs are not environment variables — they change per use case, so keep them as plain strings in your code (or pass them from your request payload).

Generate speech

Every method is async and returns a Promise. There is no sync alternative.

Stream speech

Streaming is currently supported on sona_speech_1 only.

Long text auto-chunking

createSpeech and streamSpeech both auto-chunk text longer than 300 characters. Pass the text as-is — the SDK splits it, generates each segment, and merges (or streams) the result.
predictDuration does not auto-chunk — its 300-character limit is enforced. See Long text for details.

Common operations

Type-safe enums (optional)

For type safety, the SDK exposes enum constants in @supertone/supertone/models:
Plain string literals ("en", "sona_speech_1") work too — use whichever style you prefer.

Error handling

Errors live in @supertone/supertone/models/errors and all extend SupertoneError:
Network-layer errors (ConnectionError, RequestTimeoutError, RequestAbortedError, etc.) extend HTTPClientError, not SupertoneError.

Configuration

Python SDK

The equivalent SDK for Python.

Examples

Recipes for common workflows.