Installation
Quick Start
Configuration
API Reference
startTTS(payload, options?)
Starts an async TTS generation job. Returns immediately with a generation_id.
| Parameter | Type | Required | Description |
|---|---|---|---|
text | string | ✅ | Text to convert (min 30 chars) |
voice_id | string | ✅ | Voice identifier |
model | 'base' | 'advanced' | ❌ | Model to use (default: 'base') |
speed | number | ❌ | Speed multiplier, 0.5–2.0 (default: 1.0) |
cfg_weight | number | ❌ | Advanced model: guidance strength, 1.0–5.0 |
exaggeration | number | ❌ | Advanced model: expressiveness, 0.0–1.0 |
audio_format | 'wav' | 'mp3' | ❌ | Output format (default: 'wav') |
| Option | Type | Description |
|---|---|---|
signal | AbortSignal | Cancel the request |
customEndpointSlug | string | Override endpoint slug for this request |
getStatus(generationId, options?)
Check the status of a generation.
TTSResponse with status, audio_url, voice_id, model, etc.
generateTTS(payload, options?)
Convenience method: starts TTS and polls until completion. Returns the audio URL.
signal, customEndpointSlug):
| Option | Type | Default | Description |
|---|---|---|---|
pollInterval | number | 1000 | Milliseconds between status checks |
maxWaitTime | number | 120000 | Maximum wait time in milliseconds |
getVoices(params?, options?)
List available voices with optional filtering.
| Parameter | Type | Default | Description |
|---|---|---|---|
model | 'base' | 'advanced' | — | Filter by model |
limit | number | 100 | Max results (1–500) |
offset | number | 0 | Skip results |
getHistory(params?, options?)
Retrieve generation history.
| Parameter | Type | Default | Description |
|---|---|---|---|
limit | number | 20 | Max results (1–100) |
offset | number | 0 | Skip results |
status | string | — | Filter: IN_QUEUE, GENERATING, COMPLETED, FAILED, EXPIRED |
TypeScript Types
The SDK exports all types for full type safety:Key Type Definitions
Error Handling
The SDK provides typed errors for all API failures:Error Codes
| Code | HTTP Status | Description |
|---|---|---|
AUTHENTICATION_ERROR | 401 | Invalid or missing API key |
INSUFFICIENT_BALANCE | 402 | Account has insufficient funds |
RATE_LIMITED | 429 | Rate limit exceeded |
VALIDATION_ERROR | 400/422 | Invalid request parameters |
API_ERROR | 500+ | Server-side error |
NETWORK_ERROR | — | Network connectivity issue |
TIMEOUT_ERROR | — | Request timed out |
GENERATION_ERROR | — | TTS generation failed |
Request Cancellation
UseAbortSignal to cancel in-flight requests: