Soniox
API referenceText-to-Speech

Generate speech

Generates audio from text using the TTS REST endpoint.

POST
https://tts-rt.soniox.com/tts

Headers

AuthorizationRequiredBearer <SONIOX_API_KEY>

Request

application/jsonRequired
modelRequiredstring

TTS model to use.

Default: "tts-rt-v1-preview"
languageRequiredstring

Language code of the input text.

voiceRequiredstring

Voice identifier to use.

audio_formatRequiredstring

Output audio format (for example mp3, wav, pcm_s16le, pcm_s16be).

textRequiredstring

Input text to generate audio from.

sample_rateinteger

Optional output sample rate in Hz.

bitrateinteger

Optional output bitrate in bits per second.

Header parameters

X-Request-Idstring

Optional 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-Code
  • X-Tts-Error-Message
responseRequiredstring
Format: "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-Code
  • X-Tts-Error-Message

"string"

Bad request. The request is malformed or contains invalid parameters.

Possible messages:

  • Invalid JSON body
  • Invalid message format
  • Missing required field: model
  • Model name is too long (max length 50).
  • Missing required field: language
  • Language is too long (max length 50).
  • Missing required field: voice
  • Voice is too long (max length 50).
  • Missing required field: audio_format
  • Audio format is too long (max length 50).
  • Missing required field: text
  • Text 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."
}