Preview a voice
Generate a preview of a cloned voice from a source audio file. Upload the audio, provide the text to speak, and stream back PCM16 audio — before committing to a permanent voice.
Endpoint
Requires API key authentication via the x-api-key header. The request is multipart/form-data.
Request
Form data — Content-Type: multipart/form-data
| Field | Type | Required | Description |
|---|---|---|---|
text | string | Yes | Text to generate preview with (minimum 3 words, 10 characters) |
similarity | number | Yes | Voice similarity to source (0.0 to 1.0). Higher values produce more similar voice |
model_id | string | Yes | The model identifier to use for generation |
speed | number | No | Speech speed (0.7 to 1.2, default 1.0). Values below 1.0 slow down speech, above 1.0 speed it up |
file | File | Yes | Audio file containing the voice to preview |
sample_rate | number | No | Output sample rate in Hz, 8000–48000 (default 24000). Use 48000 — it's the engine's native rate, so the audio skips downsampling and needs no client-side resampling for WebRTC. |
text must be at least 3 words and 10 characters long. The default stays 24000 for backward compatibility — pass sample_rate=48000 for the best quality.
Example request
Upload a source recording and stream the preview audio back.
Response
Status code: 200 OK. The body is streaming PCM16 audio, mono, 16-bit, at the rate you requested — 24000 Hz by default, or 48000 when you pass sample_rate=48000 (recommended). The resolved rate is always echoed in the Content-Type header, so a client can follow it rather than assume.
| Header | Value |
|---|---|
Content-Type | audio/raw;codec=pcm16;rate=<sample_rate>;channels=1 — e.g. rate=48000 |
Cache-Control | no-cache |
Connection | keep-alive |
Error responses
Errors come back as JSON with an errorCode and errorMessage.
| Status | Error code | Example message |
|---|---|---|
| 400 Bad Request | 400xx | text is required |
| 400 Bad Request | 400xx | similarity must be a number between 0 and 1 |
| 400 Bad Request | 400xx | speed must be a number between 0.7 and 1.2 |
| 400 Bad Request | 400xx | model_id is required |
| 400 Bad Request | 400xx | file is required and must be of audio type |
| 401 Unauthorized | 40101 | Invalid or missing API key |
| 402 Payment Required | 40201 | Insufficient wallet balance |
| 500 Internal Server Error | 50001 | Failed to generate voice preview |
Go further
Working with an AI assistant? Every page is available as Markdown: add .md to the URL, or send an Accept: text/markdown header. For the whole documentation in one request, point it at llms-full.txt; the page index is llms.txt. Or use Copy Page, top right.
