Generate speech
Generates audio from text using the TTS REST endpoint.
Headers
AuthorizationRequiredBearer <SONIOX_API_KEY>Request
application/jsonRequiredmodelRequiredstringTTS model to use.
"tts-rt-v1-preview"languageRequiredstringLanguage code of the input text.
voiceRequiredstringVoice identifier to use.
audio_formatRequiredstringOutput audio format (for example mp3, wav, pcm_s16le, pcm_s16be).
textRequiredstringInput text to generate audio from.
sample_rateintegerOptional output sample rate in Hz.
bitrateintegerOptional output bitrate in bits per second.
Header parameters
X-Request-IdstringOptional request ID for tracing.
Response
200
Generated audio stream.
Response body contains raw audio bytes. If a streaming error occurs after bytes have started, inspect response trailers:
X-Tts-Error-CodeX-Tts-Error-Message
responseRequiredstring"binary"Errors
Generated audio stream.
Response body contains raw audio bytes. If a streaming error occurs after bytes have started, inspect response trailers:
X-Tts-Error-CodeX-Tts-Error-Message
"string"Bad request. The request is malformed or contains invalid parameters.
Possible messages:
Invalid JSON bodyInvalid message formatMissing required field: modelModel name is too long (max length 50).Missing required field: languageLanguage is too long (max length 50).Missing required field: voiceVoice is too long (max length 50).Missing required field: audio_formatAudio format is too long (max length 50).Missing required field: textText is too long (max length 5000).API key is too long (max length 250).
{
"error_code": 400,
"error_message": "Missing required field: model"
}Authentication is missing or incorrect. Ensure a valid API key is provided before retrying.
Possible messages:
Invalid API key.Missing API key.Invalid/expired temporary API key.
{
"error_code": 401,
"error_message": "Invalid API key."
}The organization's balance or monthly usage limit has been reached. Additional credits are required before making further requests.
Possible messages:
Organization balance exhausted. Please either add funds manually or enable autopay.
{
"error_code": 402,
"error_message": "Organization balance exhausted. Please either add funds manually or enable autopay."
}The HTTP request was not completed within the allowed time window and timed out.
Possible messages:
Request timeout.
{
"error_code": 408,
"error_message": "Request timeout."
}A usage or rate limit has been exceeded. You may retry after a delay or request an increase in limits via the Soniox Console.
Possible messages:
Rate limit for your organization has been exceeded.Rate limit for your project has been exceeded.Your organization has exceeded max number of concurrent requests.Your project has exceeded max number of concurrent requests.
{
"error_code": 429,
"error_message": "Rate limit for your organization has been exceeded."
}An unexpected server-side error occurred. The request may be retried.
Possible messages:
The server had an error processing your request. Sorry about that! You can retry your request, or contact us through our support email support@soniox.com if you keep seeing this error.
{
"error_code": 500,
"error_message": "The server had an error processing your request. Sorry about that! You can retry your request."
}Cannot continue request or accept new requests.
Possible messages:
Cannot continue request (code N). Please restart the request. Refer to: https://soniox.com/url/cannot-continue-request
{
"error_code": 503,
"error_message": "Cannot continue request (code N). Please restart the request."
}