Introduction
The base URL, the endpoints for voice-overs and speech to text, and how requests and responses work
The Voice213 API is a REST API for speech in Algerian, Tunisian and Libyan darija, in both directions: voice-overs from text, and text from speech. Voice-overs are one endpoint: send your text to POST /tts, and choose the voice model with model and the voice with voice. Switching from a fast everyday voice to the most expressive one is a one-word change in the request. Speech to text has two models: KhasbhaSTT transcribes an audio or video file sent to POST /stt, and KhasbhaSTT LIVE transcribes a live audio stream over a WebSocket. The API answers in JSON, and authenticates every request with an API key.
Base URL
All endpoints live under one base URL:
https://api.voice213.com/api/v1KhasbhaSTT LIVE's socket is the exception: it's at wss://api.voice213.com/ws/stt, and it takes a single-use token instead of your key.
SDKs
The official SDKs call every endpoint and the live socket for you, with typed answers, clear errors, safe retries and timeouts long enough for long recordings. The Python and JavaScript examples in this reference use them, and the cURL examples show the HTTP requests themselves, for any other language.
JavaScript & TypeScript
npm install @voice213/sdk: Node.js, Bun, Deno and edge runtimes, and live transcription in the browser.
Python
pip install voice213: a synchronous and an asynchronous client, for Python 3.9 and later.
Voice-over
One endpoint takes any model and any voice:
curl -X POST https://api.voice213.com/api/v1/tts \
-H "Authorization: Bearer $VOICE213_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "مرحبا بيكم في Voice213", "model": "voice213-pro-2", "voice": "nariman"}'modelpicks one of the five voice models, fromvoice213-lite(the default) tovoice213-pro-2. Each has its own price per character.voicepicks one of the 30 voices. Every voice works with every model.dialectpicks Algerian (the default), Tunisian or Libyan.
GET /models and GET /tts/voices list what you can choose from, and POST /tts/estimate tells you what a text will cost on a model before you generate it. Don't have a key yet? See Get Your API Key.
Speech to text
Send a recording to POST /stt, and get its transcript back:
curl -X POST https://api.voice213.com/api/v1/stt \
-H "Authorization: Bearer $VOICE213_API_KEY" \
-F "file=@call.mp3" \
-F "language=ar" \
-F "dialect=algerian"fileis the recording, uploaded asmultipart/form-data: audio or video, up to 100 MB and 30 minutes. For a file that's already online, send its publicurlin a JSON body instead.languagepicks Arabic (ar, the default), French (fr) or English (en). For Arabic,dialectpicks the darija the transcription is tuned for: Algerian (the default), Tunisian or Libyan.modeliskhasbha-stt, KhasbhaSTT, unless you name another.
For speech as it happens, KhasbhaSTT LIVE (khasbha-stt-live) streams instead: your server gets a single-use token from POST /stt/live/token, then your app streams 16 kHz PCM audio over a WebSocket and gets partial and final transcripts back. See KhasbhaSTT LIVE.
GET /stt/models lists both models with their prices, and POST /stt/estimate tells you what a recording will cost from its length. See KhasbhaSTT for a guide.
Endpoints
| Method | Path | Description | Price |
|---|---|---|---|
POST | /tts | Turn a script into speech, with any model and any voice | Per character, by model |
POST | /tts/estimate | What a voice-over will cost, before you generate it | Free |
GET | /models | List the voice models and their prices | Free |
GET | /tts/voices | List the voices | Free |
GET | /tts/tones | List the tone directions | Free |
POST | /stt | Transcribe an audio or video file, uploaded or by URL, with KhasbhaSTT | Per second of audio |
POST | /stt/estimate | What a transcription will cost, from the length of the audio | Free |
GET | /stt/models | List the speech-to-text models and their prices | Free |
POST | /stt/live/token | Get a single-use token for one KhasbhaSTT LIVE session | Free (the session is paid per second of audio) |
WSS | /ws/stt | Stream audio and receive live transcripts (at wss://api.voice213.com/ws/stt) | Per second of audio |
GET | /me | Your API credit, your key's name and your account's limits | Free |
GET | /health | Check that the API is up (at https://api.voice213.com/health) | Free |
The API covers voice-overs and speech to text. Ad scripts, tone directions written for you, tashkeel, product images and landing pages are made in the web app. The endpoints that used to do them through the API (/generate-script, /generate-angles, /generate-tone, /tashkiil, /product-image and /landing-page) now answer 410 with the code ENDPOINT_REMOVED. See Errors.
Requests
- Send JSON bodies with
Content-Type: application/json, UTF-8 encoded, up to 25 MB. Without that header the body is ignored, and the request fails as if it were empty. - To upload a recording to
POST /stt, sendmultipart/form-datainstead: the file in thefilefield, up to 100 MB, and the other options as text fields. Let your HTTP client write theContent-Typeheader with its boundary; don't set it yourself. - Voice-overs are billed per character of text, including spaces and punctuation, with a minimum of 100 characters per request. Tone directions in parentheses aren't billed when they're at most 100 characters long.
- A voice-over takes up to 5,000 words, tone directions included, and needs something to speak: a text made only of tone directions is refused with
400 EMPTY_TEXT. - Tone directions, spaces and invisible characters can't outweigh the spoken text: a text may be at most twice its billable characters plus 1,000 characters long, or it's refused with
400 TEXT_TOO_LONG. - Transcription is billed per second of audio, rounded up, with a minimum of 30 seconds per file and 15 seconds per live session. A file can hold up to 30 minutes of audio, and a live session can last up to 60 minutes.
Responses
Successful responses are JSON. A voice-over reports the model and voice that spoke, the characters billed, what it cost and what's left of your API credit, in Algerian dinars:
{
"success": true,
"audioUrl": "https://pub-5d56f47943d84bbda9b38f1a6f9962e6.r2.dev/tts/66f1c0a4e1b2c3d4e5f60718/1727254800000-9f3c2a7b1d4e6f80.mp3",
"model": "voice213-pro-2",
"voice": "nariman",
"cost": 1.2,
"currency": "DZD",
"chars": 22,
"billableChars": 100,
"remainingCredit": 4998.8,
"words": 4,
"quality": "pro2",
"dailyProCount": 0,
"dailyProLimit": null
}Audio comes back as a link to an MP3 file or, in the inline format, as a WAV data URL.
A transcription reports the text, the model, the language and dialect, the length of the audio and the seconds billed, what it cost and what's left of your API credit:
{
"success": true,
"text": "واش راك خويا، الطلبية وصلت؟",
"model": "khasbha-stt",
"language": "ar",
"dialect": "algerian",
"durationSeconds": 42.37,
"billableSeconds": 43,
"cost": 2.15,
"currency": "DZD",
"remainingCredit": 997.85
}dialect is null for French and English. KhasbhaSTT LIVE sends its transcripts as messages on its socket instead: see Live Transcription Socket.
Errors use standard HTTP status codes and a JSON body with a readable message:
{
"error": "Missing 'text' in request body"
}The speech-to-text endpoints, and a few others, put a code in error and the explanation in message:
{
"error": "INVALID_MEDIA",
"message": "We couldn't read any audio in this file."
}See Errors for every status code and which ones to retry.
Call it from your server
Use the API from backend code. It doesn't accept cross-origin requests from other websites' browser code, and a key in front-end code would be exposed to anyone who opens your app. If your front end needs audio or a transcript, have it call your server, and let your server call Voice213. See Going to Production.
Live transcription in a browser is the one exception, and even then the key stays on your server: your server creates a live token with POST /stt/live/token, and the browser opens the KhasbhaSTT LIVE socket with it. A token opens one session within two minutes, and with origin set, other websites can't use it. See Live tokens for browsers.
Pricing and limits
The API is open on every plan, Free included. Requests are paid from prepaid API credit in dinars, separate from your plan's credits: voice-overs per character, transcription per second of audio. Every account has the same limits, shared by all its keys (up to 10): 600 requests a minute, 1,000 a day and 20 requests running at once, voice-overs and transcriptions together, plus 5 live sessions at once. See API Pricing & Limits and Rate Limits.
Was this page helpful?