Errors
Status codes, the error format, and which errors are safe to retry
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"
}requiredis 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 /sttanswers before it reads the file, andrequiredis 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.balanceis 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
charsa 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, nottext.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:
| Code | When | Which requests |
|---|---|---|
MODEL_DISABLED | The 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_DISABLED | A 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. |
MAINTENANCE | The 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."
}
}{
"error": "هذه الأداة متوقفة مؤقتًا. يرجى المحاولة لاحقًا.",
"code": "TOOL_DISABLED",
"tool": "stt_api",
"messages": {
"ar": "هذه الأداة متوقفة مؤقتًا. يرجى المحاولة لاحقًا.",
"en": "This tool is temporarily paused. Please try again later.",
"fr": "Cet outil est temporairement suspendu. Veuillez réessayer plus tard."
}
}{
"error": "المنصة قيد الصيانة حاليًا. سنعود قريبًا، شكرًا على صبرك.",
"code": "MAINTENANCE",
"messages": {
"ar": "المنصة قيد الصيانة حاليًا. سنعود قريبًا، شكرًا على صبرك.",
"en": "Voice213 is down for maintenance. We'll be back soon, thanks for your patience.",
"fr": "Voice213 est en maintenance. Nous revenons très vite, merci de votre patience."
},
"endsAt": "2026-10-01T06:00:00.000Z"
}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. OnceGET /modelsno longer shows"available": falsefor it, the model is back.TOOL_DISABLEDandMAINTENANCE: 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:
| Endpoint | Where to do it now |
|---|---|
POST /generate-script | Script Writer in the web app |
POST /generate-angles | Script Writer in the web app |
POST /generate-tone | Write the directions yourself from GET /tts/tones, or use Auto Generate with AI on the web app's Text to Speech page |
POST /tashkiil | Tashkeel in the web app |
POST /product-image | AI Photo in the web app |
POST /landing-page | Landing 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."
}| Status | Code | When |
|---|---|---|
400 | MISSING_FILE | POST /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. |
400 | INVALID_MEDIA | Voice213 couldn't read any audio in the file: it has no audio track, can't be decoded, or is empty. |
400 | AUDIO_TOO_LONG | The 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. |
400 | UNKNOWN_MODEL | model isn't one of the speech-to-text models. The body lists the models you can use. |
400 | WRONG_MODEL | POST /stt got khasbha-stt-live. KhasbhaSTT LIVE streams over a socket: create a session with POST /stt/live/token. |
400 | INVALID_LANGUAGE | language isn't ar, fr or en. |
400 | INVALID_DIALECT | dialect isn't algerian, tunisian or libyan. |
400 | INVALID_OPTION | speakers, 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. |
400 | INVALID_URL | url isn't a public http or https address. |
400 | FETCH_FAILED | Voice213 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. |
400 | INVALID_DURATION | POST /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. |
400 | INVALID_VOCABULARY | POST /stt/live/token got a vocabulary that isn't a list of up to 50 terms of 1 to 40 characters each. |
400 | INVALID_MAX_SECONDS | maxSeconds isn't a whole number from 15 to 3,600. |
400 | INVALID_ORIGIN | origin 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). |
402 | INSUFFICIENT_CREDIT | Your 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. |
413 | FILE_TOO_LARGE | The file, uploaded in file or downloaded from url, is over 100 MB. The body has maxFileMB (100). Compress the recording or split it. |
429 | SESSION_LIMIT | POST /stt/live/token: your account already has 5 live sessions running. The body has the limit. |
502 | TRANSCRIPTION_FAILED | The 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:
| Code | When |
|---|---|
INSUFFICIENT_CREDIT | Your API credit, less what your running requests have set aside, can't cover 15 seconds of audio. |
SESSION_LIMIT | Your account already has 5 live sessions running. |
BUSY | The service can't take another session right now. Retry in a moment. |
TOOL_DISABLED, MAINTENANCE | Speech to text or the API's paid requests are paused, or the API is down for maintenance. Retry later. |
ACCOUNT_BLOCKED | The account that owns the key is deactivated or suspended, or its API access is switched off. |
KEY_REVOKED | The API key that created the token has been switched off or deleted since. |
ENGINE_UNAVAILABLE | The live transcription service is unavailable. Retry in a moment. |
INTERNAL | Something 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 ends | What your client receives | Close code |
|---|---|---|
You send end, the session reaches its time limit, your credit runs out, or 60 seconds pass without audio | The last final transcripts, then ended with the reason: client_ended, max_duration, credit_limit or idle | 1000 |
| The transcription fails and can't recover | ended with the reason engine_error | 1011 |
| Voice213 restarts | The last final transcripts, then ended with the reason server_restart | 1012 |
An audio frame has an odd number of bytes, or an audio message's data isn't base64: send 16-bit PCM | error with the code INVALID_AUDIO, and no ended | 1008 |
| The audio gets more than 10 seconds ahead of real time: stream it at the pace it's recorded | error with the code TOO_FAST, and no ended | 1008 |
| Something goes wrong on our side | error with the code INTERNAL, and no ended | 1011 |
| Your client sends a message over 64 KB | Nothing: Voice213 drops the connection, and the session ends as connection_lost | 1006 |
Your client closes the socket without end, the connection drops, or it stops answering pings | Nothing: the session ends as connection_lost | Your 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
| Status | Meaning | Retry? |
|---|---|---|
200 | Success. | |
400 | The 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. |
401 | The 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. |
402 | Your 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. |
403 | The account that owns the key is deactivated or suspended, or its API access is switched off. | No. |
404 | There's no such endpoint. | No. Check the method and path. |
410 | The endpoint was removed from the API. | No. Remove the call. |
413 | A 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. |
429 | Too 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. |
500 | Something went wrong on our side, including a failed voice-over in the inline format. | Yes, with backoff. |
502 | The voice-over or the transcription couldn't be completed. | Yes, with backoff. |
503 | The 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
| Status | Error | What to do |
|---|---|---|
400 | Missing 'text' in request body | Send text as a non-empty string (voice-over in the inline format). |
400 | text is required | Send 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. |
400 | UNKNOWN_MODEL | Send one of the models from GET /models, such as voice213-lite, or for speech to text from GET /stt/models, such as khasbha-stt. |
400 | UNKNOWN_VOICE | Send one of the 30 voice IDs, such as nariman. |
400 | Invalid voice ID: 'sarah' | In the inline format, voiceId must be one of the 30 voice IDs. |
400 | EMPTY_TEXT | The text has nothing to speak, such as only tone directions. Add the words to say. |
400 | Max 5000 words exceeded | A 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. |
400 | TEXT_TOO_LONG | Too 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. |
400 | MISSING_FILE | Send the recording in the file field of a multipart/form-data body, or its public url in a JSON body. |
400 | INVALID_MEDIA | The file has no audio Voice213 can read. Send an audio or video file with sound. |
400 | AUDIO_TOO_LONG | A file can hold up to 30 minutes of audio. The body has durationSeconds and maxDurationSeconds. Split the recording. |
400 | Invalid JSON body | Check that the body is valid JSON. |
401 | Missing API key. Pass it as 'Authorization: Bearer sk_live_...' | Send your key. |
401 | Invalid or inactive API key | Check the key on the API Keys page. |
402 | INSUFFICIENT_CREDIT | Top up your API credit, or wait for your running requests to end. |
403 | Account deactivated | Contact support. |
403 | API_ACCESS_BLOCKED (in code) | API access is switched off for your account. Contact support. See API access switched off. |
404 | Not found | Check the method and path, such as POST /api/v1/tts. |
410 | ENDPOINT_REMOVED | The endpoint is no longer part of the API. See Removed endpoints. |
413 | Request body too large | Keep a JSON body under 25 MB. |
413 | FILE_TOO_LARGE | Keep files under 100 MB: compress the recording, or split it. |
429 | Rate limit exceeded: RPM limit exceeded | Wait for the minute to pass. |
429 | Rate limit exceeded: Daily limit exceeded | Wait until the next day. |
429 | Rate limit exceeded: Concurrent request limit exceeded | Your account already has 20 requests running, voice-overs and transcriptions together. Retry when one of them ends. |
429 | SESSION_LIMIT | Your account already has 5 live sessions running. Create the next token once one has ended. |
429 | RATE_LIMITED | Too many requests from your IP address. Wait Retry-After seconds. |
500 | Internal server error processing TTS request | Retry. |
500 | Server error | Retry. Nothing was charged. |
500 | Internal server error during authentication | Retry. |
502 | Failed to generate audio. No points consumed. | Retry. Nothing was charged. |
502 | TRANSCRIPTION_FAILED | Retry. Nothing was charged. |
503 | MODEL_DISABLED (in code) | The model is paused for the API. Use another model. See Paused models and maintenance. |
503 | TOOL_DISABLED (in code) | The API's paid requests (tool is public_api) or speech to text (stt_api) are paused. Retry later. |
503 | MAINTENANCE (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?