Skip to navigation

Errors

What a failed text-to-speech request returns, how to tell failures apart, and which ones to retry.

View as Markdown

This page covers errors from POST /v1/text-to-speech, POST /v1/text-to-speech/stream and the WebSocket.

The official Python and JavaScript SDKs turn every error below into a typed exception and retry the retryable ones for you.

Every error tells you four things

KeyTypeMeaning
error_codestringWhat went wrong, from the list below. Branch on this.
messagestringA specific sentence for a person: which field, which model, what to do. Safe to show and to log.
retryablebooleantrue if sending the same request again, unchanged, can succeed.
request_idstringThe request’s id, also in the X-Request-Id header. Quote it to support.

The body also keeps older keys (detail, and error on a 402 or 429) so existing integrations keep working. New code should read error_code and message.

Error codes

error_codeHTTPWhenRetry?What to do
invalid_request422, 400A field is missing or wrong, the body is not JSON, or the text is empty.NoFix the request. message names every bad field; a 422 also lists them in detail.
request_too_large413The body is over 256 KiB, or the text is over 5,000 characters.NoSend less text per request.
model_not_found400model is not a model we offer.NoUse one of the models message lists.
voice_not_found404voice_id does not exist for the model.NoPick a voice from GET /v1/voices with the matching model.
invalid_account403The API key is not linked to an active billing account.NoA new account can take up to a minute to appear; otherwise contact support.
insufficient_credits402The balance does not cover this request.NoTop up. required_inr and available_inr give the amounts.
concurrency_limit_exceeded429Your account already has as many requests in progress as its plan allows.YesWait for Retry-After (1 s) or for one of your requests to finish.
capacity_exhausted503Every server for the model is busy.YesRetry after Retry-After, with backoff.
model_unavailable503No server for the model is healthy right now.YesRetry after a few seconds, with backoff.
model_timeout504The model did not produce audio in time.YesRetry.
model_error502The model failed while generating audio.YesRetry.
stream_interrupted200, then an error eventA stream that had already sent audio stopped before it finished.YesRequest the text again. The interrupted request is charged.
service_unavailable503The service is restarting or cannot check balances right now.YesRetry shortly.
internal_error500A fault inside the service.YesRetry; if it keeps failing, contact support with request_id.

The list only grows: a code is never renamed, removed or given a new meaning. Treat a code you don’t recognise by its HTTP status.

Retrying

  • Retry only when retryable is true. Every 4xx except 429 needs the request changed first.
  • Honour Retry-After when present. Otherwise back off exponentially from about 0.5 s and give up after a few attempts.
  • Never retry a stream after you have received audio. It was charged, and the retry would play the start again. A request that fails before any audio is not charged.

Examples

A request with bad fields (422) lists every problem at once:

{
"detail": [
{"type": "missing", "loc": ["body", "voice_id"], "msg": "Field required"},
{"type": "value_error", "loc": ["body", "output_format", "encoding"], "msg": "Value error, encoding must be one of: pcm_f32le, pcm_s16le, pcm_mulaw, pcm_alaw", "input": "mulaw", "ctx": {"error": {}}}
],
"error_code": "invalid_request",
"message": "Invalid request: voice_id: Field required; output_format.encoding: encoding must be one of: pcm_f32le, pcm_s16le, pcm_mulaw, pcm_alaw.",
"retryable": false,
"request_id": "req_0071415897e5d4ac1c0f8576c827a723"
}

Insufficient credits (402):

{
"error": "Insufficient credits",
"message": "The billing account has insufficient balance.",
"error_code": "insufficient_credits",
"required_inr": 1.56,
"available_inr": 0.0005,
"retryable": false,
"request_id": "req_432fb998ac8d85101424c94f1c79499f"
}

Too many concurrent requests (429, with Retry-After: 1):

{
"error": "Too many concurrent requests",
"error_code": "concurrency_limit_exceeded",
"message": "This account allows 2 concurrent requests and 2 are in progress. Retry when one of them finishes, or contact support to raise the limit.",
"concurrency_limit": 2,
"retryable": true,
"request_id": "req_52276699f92dfd6939e0f242511ef602"
}

A stream that fails after audio has started can’t change its status any more, so the failure is the stream’s last event:

event: error
data: {"type":"error","status_code":502,"message":"The audio stream ended before it was complete.","error_code":"stream_interrupted","retryable":true,"request_id":"req_5a5714bd13aaac71ac49b31ceddc77e5"}

A stream that ends with neither a done nor an error event did not complete.

Errors from the API gateway

A few requests are refused before they reach the speech service. Their body has only message and the gateway’s own request_id:

HTTPmessageCause
401No API key found in requestNo X-API-Key header.
401UnauthorizedThe API key is not valid.
413Request size limit exceededThe body is over 256 KB.
404no Route matched with those valuesWrong path, or the wrong method on a speech path.