Generate speech
Generates audio from text using the TTS REST endpoint.
Generates audio from text using the TTS REST endpoint.
Headers
AuthorizationRequiredBearer <SONIOX_API_KEY>Request
application/jsonRequiredmodelRequiredstringTTS model to use.
"tts-rt-v1"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.
client_reference_idstringOptional tracking identifier string. Does not need to be unique. Ignored if the request authenticates with a temporary API key.
256Header parameters
X-Request-IdstringOptional request ID for tracing.
Response
200
Generated audio stream.
Response body contains raw audio bytes.
responseRequiredstring"binary"Errors
Generated audio stream.
Response body contains raw audio bytes.
"string"Bad request. The request is malformed or contains invalid parameters.
error_type is one of
invalid_request
or model_not_available.
Possible messages:
Invalid JSON bodyMissing 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).Client reference ID is too long (max length 256).Invalid voice '<voice>' for model '<model>'.Invalid language '<language>' for model '<model>'.The requested model is not available. See https://soniox.com/docs/tts/models for the list of supported TTS models.(error_type: model_not_available)
{
"error_code": 400,
"error_type": "invalid_request",
"error_message": "Missing required field: model",
"more_info": "https://soniox.com/docs/api-reference/errors#invalid-request",
"request_id": "3d37a3bd-5078-47ee-a369-b204e3bbedda"
}Authentication is missing or incorrect. Ensure a valid API key is provided before retrying.
error_type: unauthenticated.
Possible messages:
Missing API key. Provide it as an Authorization header (e.g. 'Authorization: Bearer <SONIOX_API_KEY>'). You can get an API key at https://console.soniox.com.Authorization header must use the Bearer scheme (e.g. 'Authorization: Bearer <SONIOX_API_KEY>'). You can get an API key at https://console.soniox.com.Incorrect API key provided. You can get an API key at https://console.soniox.comInvalid or expired temporary API key. Create a new temporary API key and retry. See https://soniox.com/docs/guides/temporary-api-keys for details.- The temporary API key cannot be used for this action. Each temporary API key is scoped to a specific
usage_type; create a new key with the correct usage type.
{
"error_code": 401,
"error_type": "unauthenticated",
"error_message": "Incorrect API key provided. You can get an API key at https://console.soniox.com",
"more_info": "https://soniox.com/docs/api-reference/errors#unauthenticated",
"request_id": "3d37a3bd-5078-47ee-a369-b204e3bbedda"
}The organization's balance or monthly budget has been reached. Additional credits or a higher cap are required before making further requests.
error_type is one of
organization_balance_exhausted,
organization_monthly_budget_exhausted,
or project_monthly_budget_exhausted.
Possible messages:
Organization balance exhausted. Please either add funds manually or enable autopay.Organization monthly budget exhausted. Please increase it.Project monthly budget exhausted. Please increase it.
{
"error_code": 402,
"error_type": "organization_balance_exhausted",
"error_message": "Organization balance exhausted. Please either add funds manually or enable autopay.",
"more_info": "https://soniox.com/docs/api-reference/errors#organization-balance-exhausted",
"request_id": "3d37a3bd-5078-47ee-a369-b204e3bbedda"
}The temporary API key in use was created with a max_session_duration_seconds cap,
and that duration has elapsed for the current session. Create a new temporary API key
to start a new session.
error_type: temp_api_key_session_expired.
Possible messages:
Temporary API key session duration limit exceeded. Create a new temporary API key to start a new session.
{
"error_code": 403,
"error_type": "temp_api_key_session_expired",
"error_message": "Temporary API key session duration limit exceeded. Create a new temporary API key to start a new session.",
"more_info": "https://soniox.com/docs/api-reference/errors#temp-api-key-session-expired",
"request_id": "3d37a3bd-5078-47ee-a369-b204e3bbedda"
}A backend call exceeded its deadline before completing. Retry the request.
error_type: request_timeout.
{
"error_code": 408,
"error_type": "request_timeout",
"error_message": "Request timeout.",
"more_info": "https://soniox.com/docs/api-reference/errors#request-timeout",
"request_id": "3d37a3bd-5078-47ee-a369-b204e3bbedda"
}A usage or rate limit has been exceeded. You may retry after a delay or request an increase in limits via the Soniox Console.
error_type: limit_exceeded.
Possible messages:
Requests per minute limit for text-to-speech has been exceeded for your organization.Requests per minute limit for text-to-speech has been exceeded for your project.Concurrent requests limit for text-to-speech has been exceeded for your organization.Concurrent requests limit for text-to-speech has been exceeded for your project.
{
"error_code": 429,
"error_type": "limit_exceeded",
"error_message": "Requests per minute limit for text-to-speech has been exceeded for your organization.",
"more_info": "https://soniox.com/docs/api-reference/errors#limit-exceeded",
"request_id": "3d37a3bd-5078-47ee-a369-b204e3bbedda"
}An unexpected server-side error occurred. The request may be retried.
error_type: internal_error.
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_type": "internal_error",
"error_message": "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.",
"more_info": "https://soniox.com/docs/api-reference/errors#internal-error",
"request_id": "3d37a3bd-5078-47ee-a369-b204e3bbedda"
}The service cannot accept the request right now (upstream overload, cache exhausted, shutdown).
Retry with backoff. The numeric (code N) in the message identifies the sub-cause for support triage.
error_type: service_unavailable.
Possible messages:
Cannot continue request (code N). Please restart the request. Refer to: https://soniox.com/url/cannot-continue-request
{
"error_code": 503,
"error_type": "service_unavailable",
"error_message": "Cannot continue request (code 11). Please restart the request. Refer to: https://soniox.com/url/cannot-continue-request",
"more_info": "https://soniox.com/docs/api-reference/errors#service-unavailable",
"request_id": "3d37a3bd-5078-47ee-a369-b204e3bbedda"
}