Create Speech
POSThttps://api.knoxstudio.ai/v1/text-to-speech/:voice_id
Synthesize the full text with an ElevenLabs voice_id from Voices. A public voice such as 21m00Tcm4TlvDq8ikWAM also works. Default model eleven_multilingual_v2. Billed per character ($0.15 or $0.10 / 1K). Guide: Text to Speech.
Request
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| voice_id | String | Yes | ElevenLabs voice ID. |
Query Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| enable_logging | Boolean | No | Default true. false requests zero-retention mode. |
| optimize_streaming_latency | Integer | No | Deprecated. 0–4 latency/quality tradeoff. |
| output_format | String | No | Default mp3_44100_128. Format is codec_sample_rate_bitrate. |
Allowed output_format values include WAV: alaw_8000, mp3_22050_32, mp3_24000_48, mp3_44100_128, mp3_44100_192, mp3_44100_32, mp3_44100_64, mp3_44100_96, opus_48000_128, opus_48000_192, opus_48000_32, opus_48000_64, opus_48000_96, pcm_16000, pcm_22050, pcm_24000, pcm_32000, pcm_44100, pcm_48000, pcm_8000, ulaw_8000, wav_16000, wav_22050, wav_24000, wav_32000, wav_44100, wav_48000, wav_8000.
Request Headers
| Name | Type | Required | Description |
|---|---|---|---|
| Authorization | String | Yes | Bearer <token> Knox API key. xi-api-key is also accepted. |
| Content-Type | String | Yes | application/json. |
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| text | String | Yes | Text to speak. Max characters depend on model_id (5,000–40,000). |
| model_id | String | No | Default eleven_multilingual_v2. See GET /v1/text-to-speech/models. |
| language_code | String | No | ISO 639-1. Ignored by eleven_multilingual_v2. |
| voice_settings | Object | No | Per-request overrides: stability (0.5), similarity_boost (0.75), style (0), speed (1.0), use_speaker_boost (true). |
| pronunciation_dictionary_locators | List of Objects | No | Up to 3 locators with pronunciation_dictionary_id and optional version_id. |
| seed | Integer | No | 0–4294967295. Best-effort determinism. |
| previous_text | String | No | Preceding text for continuity. |
| next_text | String | No | Following text for continuity. |
| previous_request_ids | List of Strings | No | Up to 3 prior request_id values. Overrides previous_text if both are sent. |
| next_request_ids | List of Strings | No | Up to 3 following request_id values. Overrides next_text if both are sent. |
| apply_text_normalization | String | No | auto (default), on, or off. |
| apply_language_text_normalization | Boolean | No | Extra language normalization (Japanese). Increases latency. Default false. |
cURL Example
curl -X POST "https://api.knoxstudio.ai/v1/text-to-speech/21m00Tcm4TlvDq8ikWAM?output_format=mp3_44100_128" \
-H "Authorization: Bearer $KNOXCHAT_API_KEY" \
-H "Content-Type: application/json" \
-o speech.mp3 \
-d '{
"text": "Hello from Knox. This is text to speech.",
"model_id": "eleven_multilingual_v2"
}'
Response
Success Response (200)
The generated audio file. Content-Type follows output_format.
Error Responses
Validation uses HTTP 422:
{
"detail": [
{
"loc": ["body", "field"],
"msg": "…",
"type": "value_error"
}
]
}
Other errors use { "detail": "message" }.
| Status | When |
|---|---|
400 | WebSocket path called without Upgrade: websocket. |
401 | Missing or invalid API key. |
402 | Insufficient credits. |
403 | Token is not allowed to use this model. |
404 | Resource not found. |
422 | Validation error. |
429 | Rate limit exceeded. |
500 | Internal server error. |