Skip to content

The API uses standard HTTP status codes. A 2xx status means success. Anything else comes with a JSON body holding a readable message in error:

{
  "error": "Missing 'text' in request body"
}

Some errors add details. A rate-limit error carries the limit you reached, a word-limit error the words you sent and the maxWords allowed, a text-length error the chars you sent and the maxChars allowed, and an audio-length error the durationSeconds of your file and the maxDurationSeconds allowed. Show the message to your developers, but branch your code on the status: messages can be reworded over time.

A few errors put a machine-readable code in error and the explanation in message: INSUFFICIENT_CREDIT, UNKNOWN_MODEL, UNKNOWN_VOICE, EMPTY_TEXT, TEXT_TOO_LONG, ENDPOINT_REMOVED and the codes listed under Speech-to-text errors. The per-IP limit's RATE_LIMITED is a code in error too, with no message. Branch on the code, not on the message.

A few others keep a message in Arabic in error and put the code in code: API_ACCESS_BLOCKED, MODEL_DISABLED, TOOL_DISABLED and MAINTENANCE. Branch on code for those.

KhasbhaSTT LIVE reports problems on its socket, as messages, rather than with a status: see Live session errors.

​Insufficient API credit

When your API credit can't cover a request, you get 402 with the code INSUFFICIENT_CREDIT, a message and the amounts in dinars:

{
  "error": "INSUFFICIENT_CREDIT",
  "message": "Not enough API credit. Top up your balance in the developer workspace.",
  "required": 1.2,
  "balance": 0.35,
  "currency": "DZD"
}
  • required is what the request would have cost: a voice-over's billable characters at the model's price, or a transcription's billable seconds at the model's price per minute. When your credit can't cover even the shortest file, POST /stt answers before it reads the file, and required is the price of 30 seconds of KhasbhaSTT, 1.50 DA. For a live token, it's the price of the shortest session: 15 seconds of KhasbhaSTT LIVE, 1.25 DA.
  • balance is what you can spend right now: your API credit, less what your requests still running have set aside.

While a voice-over or a transcription runs, its price is set aside from your API credit, so the requests you run at the same time can't spend more than you have between them. A request is refused when what's left after the others can't cover it, even if your credit alone could. The price stays set aside until the request is charged its cost, the moment it succeeds, or until it fails, which is charged nothing. Either way nothing stays set aside once a request has ended.

A KhasbhaSTT LIVE session sets aside the price of the audio it has received so far plus the next two minutes (never more than the session's limit), and keeps that amount up to date as it runs, so it never ties up your whole balance. When your credit can no longer cover it, the session doesn't fail with 402: it ends on its own with the reason credit_limit, and is charged for the audio it received.

Your plan's credits never pay for API requests, so this can happen on an Unlimited subscription too. Top up on the Developer Dashboard. To check before you send, ask Estimate Cost about a text, or POST /stt/estimate about a length of audio: their enough field tells you whether your credit covers it. It doesn't subtract what your running requests have set aside.

​Unknown model or voice

A model that isn't one of the five models gets 400 with the code UNKNOWN_MODEL and the models you can use:

{
  "error": "UNKNOWN_MODEL",
  "message": "Unknown model 'voice213-ultra'. Use one of: voice213-lite, voice213-lite-2, voice213-pro, voice213-pro-1.5, voice213-pro-2 (see GET /v1/models).",
  "models": ["voice213-lite", "voice213-lite-2", "voice213-pro", "voice213-pro-1.5", "voice213-pro-2"]
}

A voice that isn't one of the 30 voice IDs gets 400 with the code UNKNOWN_VOICE and the full list of IDs in voices. In the inline format, an unknown voiceId gets 400 Invalid voice ID: '<id>'. Read the lists from GET /models and GET /tts/voices instead of hard-coding them.

On POST /stt and POST /stt/estimate, an unknown model gets the same 400 UNKNOWN_MODEL, with the models that endpoint takes in models: khasbha-stt alone on POST /stt, and both speech-to-text models on POST /stt/estimate. POST /stt refuses khasbha-stt-live with 400 WRONG_MODEL: KhasbhaSTT LIVE streams over a socket, so create a session with POST /stt/live/token instead. GET /stt/models lists both models.

​Text that can't be spoken

A voice-over, or an estimate, needs words to speak. A text with nothing to speak, such as one made only of tone directions, gets 400 with the code EMPTY_TEXT:

{
  "error": "EMPTY_TEXT",
  "message": "Nothing to speak: the text is empty or contains only tone directions."
}

A text over 5,000 words gets 400 Max 5000 words exceeded, with the words it has and the maxWords allowed. Every word counts, tone directions included, in both formats of POST /tts and in Estimate Cost. Split longer scripts into several requests.

​Too much unspoken text

Tone directions of up to 100 characters, invisible characters and repeated spaces aren't billed, but they can't outweigh what the voice speaks. A text may be at most twice its billable characters plus 1,000 characters long, counting every character you send:

  • Billable characters are the ones Voice213 bills, before the 100-character minimum: the chars a voice-over or an estimate returns. Below 100, they count as 100.
  • Every character counts toward the length, tone directions, spaces and invisible characters included. Characters are Unicode code points: an Arabic letter, or an emoji, is one character (in JavaScript, [...text].length, not text.length).

So a text with 150 billable characters can be up to 1,300 characters long, and one with 2,000 up to 5,000. An ordinary script with tone directions is far from this limit. A longer text gets 400 with the code TEXT_TOO_LONG, the characters you sent in chars and the most you could send in maxChars:

{
  "error": "TEXT_TOO_LONG",
  "message": "Too much of the text isn't spoken: tone directions, punctuation and invisible characters can't be more than about the spoken text itself. Remove them or split the text.",
  "chars": 1842,
  "maxChars": 1300
}

This applies in both formats of POST /tts and in Estimate Cost, and nothing is charged. Tone directions stay free: remove the ones you don't need, or the padding, and send the text again.

​API access switched off

Voice213 can switch off API access for an account. Every request made with its key then gets 403, with the code API_ACCESS_BLOCKED in code and a message in Arabic in error:

{
  "error": "تم إيقاف وصولك إلى واجهة المطورين. تواصل مع الدعم.",
  "code": "API_ACCESS_BLOCKED"
}

While it's off, you also can't create a key or switch yours back on, and a KhasbhaSTT LIVE session can't start: its socket sends the error ACCOUNT_BLOCKED and closes. Don't retry: contact support.

​Paused models and maintenance

Voice213 can pause a voice model for the API, pause the API's paid requests, pause speech to text on its own, or take the API down for maintenance. Requests then get 503, with a code in code, a message in Arabic in error, and the same message in Arabic, English and French in messages:

CodeWhenWhich requests
MODEL_DISABLEDThe model you asked for is paused for the API. model names it.POST /tts with that model. GET /models lists it with "available": false.
TOOL_DISABLEDA switch is off, and tool names it: public_api pauses the API's paid requests, and stt_api pauses speech to text alone, while voice-overs keep working.With public_api: POST /tts, POST /stt and POST /stt/live/token. With stt_api: POST /stt and POST /stt/live/token. Estimates and the other free endpoints keep working, and GET /stt/models lists the speech-to-text models with "available": false while either switch is off. Live sessions already running carry on.
MAINTENANCEThe API is down for maintenance. endsAt is when it's expected back, or null.Every endpoint under /api/v1, and new live sessions. /health keeps answering.
{
  "error": "هذا النموذج الصوتي غير متاح مؤقتًا. اختر نموذجًا آخر أو حاول لاحقًا.",
  "code": "MODEL_DISABLED",
  "model": "voice213-pro-2",
  "messages": {
    "ar": "هذا النموذج الصوتي غير متاح مؤقتًا. اختر نموذجًا آخر أو حاول لاحقًا.",
    "en": "This voice model is temporarily unavailable. Pick another model or try again later.",
    "fr": "Ce modèle de voix est temporairement indisponible. Choisissez-en un autre ou réessayez plus tard."
  }
}

The texts in error and messages can differ from these, so branch on code. While endsAt is set and still ahead, a MAINTENANCE answer also has a Retry-After header with the seconds left until then. Maintenance doesn't end on its own at endsAt: past that time the answer keeps the old endsAt and has no Retry-After, so retry after a short wait. Nothing is charged, and these requests don't count toward your limits.

  • MODEL_DISABLED: send the voice-over with another model. Once GET /models no longer shows "available": false for it, the model is back.
  • TOOL_DISABLED and MAINTENANCE: retry later. A KhasbhaSTT LIVE session that tries to start meanwhile gets the same code as a socket error, and closes.

​Removed endpoints

These endpoints are no longer part of the API. They answer 410 Gone whatever you send, with or without a valid key. While the API is down for maintenance they answer 503 MAINTENANCE, like every endpoint:

EndpointWhere to do it now
POST /generate-scriptScript Writer in the web app
POST /generate-anglesScript Writer in the web app
POST /generate-toneWrite the directions yourself from GET /tts/tones, or use Auto Generate with AI on the web app's Text to Speech page
POST /tashkiilTashkeel in the web app
POST /product-imageAI Photo in the web app
POST /landing-pageLanding Pages in the web app
{
  "error": "ENDPOINT_REMOVED",
  "message": "POST /v1/tashkiil is no longer part of the Voice213 API. The API now covers voice-overs and speech to text: see https://docs.voice213.com/api-reference/introduction"
}

Nothing is charged for these requests. Don't retry them: remove the calls from your code.

​Speech-to-text errors

POST /stt, POST /stt/estimate and POST /stt/live/token answer with a code in error, a sentence in English in message, and sometimes details:

{
  "error": "WRONG_MODEL",
  "message": "KhasbhaSTT LIVE streams over a socket: create a session with POST /v1/stt/live/token."
}
StatusCodeWhen
400MISSING_FILEPOST /stt got no file in file and no url. With a form, check the field's name; with JSON, check the Content-Type: application/json header.
400INVALID_MEDIAVoice213 couldn't read any audio in the file: it has no audio track, can't be decoded, or is empty.
400AUDIO_TOO_LONGThe audio is longer than 30 minutes. The body has the file's durationSeconds and the maxDurationSeconds allowed (1800). Nothing is charged: split the recording and send the parts.
400UNKNOWN_MODELmodel isn't one of the speech-to-text models. The body lists the models you can use.
400WRONG_MODELPOST /stt got khasbha-stt-live. KhasbhaSTT LIVE streams over a socket: create a session with POST /stt/live/token.
400INVALID_LANGUAGElanguage isn't ar, fr or en.
400INVALID_DIALECTdialect isn't algerian, tunisian or libyan.
400INVALID_OPTIONspeakers, punctuation or profanity isn't true or false, as a JSON boolean or as text, or a form has too many fields or one that's too long. field names the field.
400INVALID_URLurl isn't a public http or https address.
400FETCH_FAILEDVoice213 couldn't download the file at url within 60 seconds, or its server answered with an error, whose HTTP status is in status. Check that the link opens without signing in and hasn't expired.
400INVALID_DURATIONPOST /stt/estimate got a durationSeconds that isn't a number above 0, or that's longer than the model takes: 1,800 seconds for KhasbhaSTT, 3,600 for KhasbhaSTT LIVE. The body has the max.
400INVALID_VOCABULARYPOST /stt/live/token got a vocabulary that isn't a list of up to 50 terms of 1 to 40 characters each.
400INVALID_MAX_SECONDSmaxSeconds isn't a whole number from 15 to 3,600.
400INVALID_ORIGINorigin isn't a site's origin, such as https://shop.example: http or https, a host and an optional port, and nothing else (a trailing / is fine).
402INSUFFICIENT_CREDITYour API credit, less what your running requests have set aside, can't cover the transcription, or the 15-second minimum of a live session. See Insufficient API credit.
413FILE_TOO_LARGEThe file, uploaded in file or downloaded from url, is over 100 MB. The body has maxFileMB (100). Compress the recording or split it.
429SESSION_LIMITPOST /stt/live/token: your account already has 5 live sessions running. The body has the limit.
502TRANSCRIPTION_FAILEDThe transcription couldn't be completed. Nothing was charged: retry.

Their other errors, such as a missing key or a rate limit, are the same as everywhere else, and paused speech to text answers 503 TOOL_DISABLED with tool set to stt_api (see Paused models and maintenance). A recording with no speech in it isn't an error: the transcription succeeds with an empty text, and is billed like any other.

​Live session errors

A KhasbhaSTT LIVE session reports a problem on its socket, as a message, then closes the socket:

{
  "type": "error",
  "code": "ENGINE_UNAVAILABLE",
  "message": "The live transcription service is unavailable. Try again in a moment."
}

A session that can't start sends one of these errors and closes with the code 4000. Nothing is charged:

CodeWhen
INSUFFICIENT_CREDITYour API credit, less what your running requests have set aside, can't cover 15 seconds of audio.
SESSION_LIMITYour account already has 5 live sessions running.
BUSYThe service can't take another session right now. Retry in a moment.
TOOL_DISABLED, MAINTENANCESpeech to text or the API's paid requests are paused, or the API is down for maintenance. Retry later.
ACCOUNT_BLOCKEDThe account that owns the key is deactivated or suspended, or its API access is switched off.
KEY_REVOKEDThe API key that created the token has been switched off or deleted since.
ENGINE_UNAVAILABLEThe live transcription service is unavailable. Retry in a moment.
INTERNALSomething went wrong on our side while the session started. Retry with a new token.

Once a session is running, this is how it can end, what your client receives, and how its socket closes:

How it endsWhat your client receivesClose code
You send end, the session reaches its time limit, your credit runs out, or 60 seconds pass without audioThe last final transcripts, then ended with the reason: client_ended, max_duration, credit_limit or idle1000
The transcription fails and can't recoverended with the reason engine_error1011
Voice213 restartsThe last final transcripts, then ended with the reason server_restart1012
An audio frame has an odd number of bytes, or an audio message's data isn't base64: send 16-bit PCMerror with the code INVALID_AUDIO, and no ended1008
The audio gets more than 10 seconds ahead of real time: stream it at the pace it's recordederror with the code TOO_FAST, and no ended1008
Something goes wrong on our sideerror with the code INTERNAL, and no ended1011
Your client sends a message over 64 KBNothing: Voice213 drops the connection, and the session ends as connection_lost1006
Your client closes the socket without end, the connection drops, or it stops answering pingsNothing: the session ends as connection_lostYour own, or 1006

However it ends, a running session is charged once, for the audio it received. An end sent before ready isn't lost: right after ready, the session transcribes the audio it held, then ends as in the first row.

A socket refused with HTTP 401 during the handshake has a token that's missing, invalid, expired or already used, or was opened from another origin than the token's: create a new token. See Live Transcription Socket for every message and close code.

​Status codes

StatusMeaningRetry?
200Success.
400The request is invalid: a required field is missing, the model or voice is unknown, the text has nothing to speak, is over the word limit or is mostly unspoken, the audio can't be read or is longer than 30 minutes, an option has a value the API doesn't take, or the body isn't valid JSON.No. Fix the request.
401The API key is missing, wrong, switched off or deleted. On the KhasbhaSTT LIVE socket, the live token is missing, invalid, expired or used, or the socket was opened from another origin.No. Check the key, or create a new live token.
402Your API credit, less what your running requests have set aside, can't cover the request.After you top up, or once your running requests end.
403The account that owns the key is deactivated or suspended, or its API access is switched off.No.
404There's no such endpoint.No. Check the method and path.
410The endpoint was removed from the API.No. Remove the call.
413A JSON body is over 25 MB, or a file sent to POST /stt, uploaded or at a url, is over 100 MB (FILE_TOO_LARGE).No. Send less.
429Too many requests: your account's per-minute or per-day limit, 20 requests already running with your account's keys, 5 live sessions already running on your account (SESSION_LIMIT), or too many requests from your IP address.Yes, after a pause.
500Something went wrong on our side, including a failed voice-over in the inline format.Yes, with backoff.
502The voice-over or the transcription couldn't be completed.Yes, with backoff.
503The model you asked for, the API's paid requests or speech to text are paused, or the API is down for maintenance.Later. For MODEL_DISABLED, switch to another model.

Voice213 charges a request only once its work has succeeded: a voice-over once its audio is ready, and a transcription once its text is ready, even when the text is empty because the audio has no speech. A request that fails with an error costs nothing, and only says that it failed: the engine's own error isn't passed on. A live session is charged once, when it ends, for the audio it received.

​Common errors

StatusErrorWhat to do
400Missing 'text' in request bodySend text as a non-empty string (voice-over in the inline format).
400text is requiredSend text as a non-empty string (voice-over in the studio format, estimates). If you did, check Content-Type: application/json: without it the body is ignored.
400UNKNOWN_MODELSend one of the models from GET /models, such as voice213-lite, or for speech to text from GET /stt/models, such as khasbha-stt.
400UNKNOWN_VOICESend one of the 30 voice IDs, such as nariman.
400Invalid voice ID: 'sarah'In the inline format, voiceId must be one of the 30 voice IDs.
400EMPTY_TEXTThe text has nothing to speak, such as only tone directions. Add the words to say.
400Max 5000 words exceededA voice-over or an estimate takes up to 5,000 words, tone directions included, in either format. The body has words and maxWords. Split the script.
400TEXT_TOO_LONGToo much of the text isn't spoken: tone directions, spaces or invisible characters. The body has chars and maxChars. Remove what you don't need. See Too much unspoken text.
400MISSING_FILESend the recording in the file field of a multipart/form-data body, or its public url in a JSON body.
400INVALID_MEDIAThe file has no audio Voice213 can read. Send an audio or video file with sound.
400AUDIO_TOO_LONGA file can hold up to 30 minutes of audio. The body has durationSeconds and maxDurationSeconds. Split the recording.
400Invalid JSON bodyCheck that the body is valid JSON.
401Missing API key. Pass it as 'Authorization: Bearer sk_live_...'Send your key.
401Invalid or inactive API keyCheck the key on the API Keys page.
402INSUFFICIENT_CREDITTop up your API credit, or wait for your running requests to end.
403Account deactivatedContact support.
403API_ACCESS_BLOCKED (in code)API access is switched off for your account. Contact support. See API access switched off.
404Not foundCheck the method and path, such as POST /api/v1/tts.
410ENDPOINT_REMOVEDThe endpoint is no longer part of the API. See Removed endpoints.
413Request body too largeKeep a JSON body under 25 MB.
413FILE_TOO_LARGEKeep files under 100 MB: compress the recording, or split it.
429Rate limit exceeded: RPM limit exceededWait for the minute to pass.
429Rate limit exceeded: Daily limit exceededWait until the next day.
429Rate limit exceeded: Concurrent request limit exceededYour account already has 20 requests running, voice-overs and transcriptions together. Retry when one of them ends.
429SESSION_LIMITYour account already has 5 live sessions running. Create the next token once one has ended.
429RATE_LIMITEDToo many requests from your IP address. Wait Retry-After seconds.
500Internal server error processing TTS requestRetry.
500Server errorRetry. Nothing was charged.
500Internal server error during authenticationRetry.
502Failed to generate audio. No points consumed.Retry. Nothing was charged.
502TRANSCRIPTION_FAILEDRetry. Nothing was charged.
503MODEL_DISABLED (in code)The model is paused for the API. Use another model. See Paused models and maintenance.
503TOOL_DISABLED (in code)The API's paid requests (tool is public_api) or speech to text (stt_api) are paused. Retry later.
503MAINTENANCE (in code)The API is down for maintenance. Retry after Retry-After seconds when it's there, or later.

A few messages still say "points" from an earlier version of the API. They mean nothing was charged to your API credit.

​Retrying safely

Retry 429, 500, 502 and 503 after a pause, and back off exponentially between attempts. Honor Retry-After when it's there. A 429 for your account's daily limit won't clear until the next day, so stop retrying when the message says Daily limit exceeded. A 429 SESSION_LIMIT clears as soon as one of your live sessions ends. A 503 with the code MODEL_DISABLED can last a while too: send the voice-over with another model instead. The SDKs follow these rules for you, and give each error a class and a code to branch on: see Going to Production.

Was this page helpful?