ElevenLabs API
sonix exposes an ElevenLabs-shaped surface so existing ElevenLabs clients
work by switching the base URL and key. These routes accept either
Authorization: Bearer or the ElevenLabs xi-api-key header.
POST /v1/text-to-speech/{voice_id}
The path segment selects the voice. See Voices for how IDs resolve.
curl "$SONIX_URL/v1/text-to-speech/af_alloy?output_format=mp3_44100_128" \
-H "xi-api-key: $SONIX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "Hello from sonix.",
"voice_settings": { "speed": 1.0 }
}' --output hello.mp3
| Field | Notes |
|---|---|
text | The text to synthesize. Required. |
voice_settings.speed | 0.25 to 4.0. Other voice settings are accepted and ignored. |
model_id | Accepted for compatibility; it does not select the sonix model. |
Request bodies are lenient: unknown ElevenLabs fields (seed,
previous_text, pronunciation dictionaries, request-id continuity) are
accepted and ignored, so existing client payloads pass through unmodified.
Output formats
The output_format query parameter follows ElevenLabs naming and defaults
to mp3_44100_128. The codec prefix maps to the response encoding: mp3_*,
pcm_*, wav_* and opus_* are supported. Sample-rate suffixes are
parsed best-effort; audio is not resampled. ulaw_* and alaw_* are
rejected with a validation error.
On qwen3-tts-0.6b only pcm_* and wav_* are available. An omitted
output_format returns wav_24000 (pcm_24000 on /stream) there.
language_code defaults to English when omitted; it is never inferred from
the text.
POST /v1/text-to-speech/{voice_id}/stream
Same contract as the non-streaming route, provided so ElevenLabs streaming clients work unchanged. The response is currently buffered: the full clip is synthesized and then returned. True chunked streaming is planned.
