Skip to content

Voice213 has official SDKs for JavaScript and TypeScript, and for Python. They cover the whole developer API: voice-overs, KhasbhaSTT transcription, KhasbhaSTT LIVE sessions, the catalogue of voices, tones and models, and your account. Both have the same methods, named the way each language names things, so an example in one reads like the other.

JavaScript & TypeScriptPython
Package@voice213/sdk on npmvoice213 on PyPI
Runs onNode.js 18+, Bun, Deno and edge runtimes, with ES modules or CommonJS. Live sessions in the browser tooPython 3.9+, with a synchronous client and an asynchronous one
Clientnew Voice213()Voice213(), or AsyncVoice213() for asyncio
GuideJavaScript & TypeScriptPython

​Install

pip install voice213

Then set your API key in the VOICE213_API_KEY environment variable on your server: see Get Your API Key.

​A first request

The same voice-over and transcription in both languages:

from voice213 import Voice213

client = Voice213()  # reads VOICE213_API_KEY

speech = client.text_to_speech.create("مرحبا بيكم في Voice213", voice="kenza", model="voice213-pro-2")
speech.save("welcome.mp3")
print(f"{speech.cost} {speech.currency}, {speech.remaining_credit} left")

transcript = client.speech_to_text.transcribe("call.mp3", language="ar", dialect="algerian")
print(transcript.text)

​What they handle for you

  • Your key. The client reads it from VOICE213_API_KEY, or takes the one you pass, and sends it with every request. A missing key fails before anything is sent, with the code MISSING_API_KEY.
  • Both voice-over formats. A voice-over comes back as a link to an MP3 or, with inline, as a WAV inside the answer. Either way you get one Speech, with its cost and your remaining credit, and save() writes the audio to a file.
  • Files. transcribe() uploads a recording from a path or its bytes, with its name and type, or sends the link to one that's already online.
  • Long requests. The client waits up to 10 minutes for an answer, enough for a long script on a Pro model or a recording near the 30-minute limit. In Node.js, the JavaScript SDK isn't cut off after 5 minutes, as the built-in fetch is.
  • Safe retries. Rate limits, maintenance and failures that cost nothing are retried twice, after the API's Retry-After or with exponential backoff. A voice-over or a transcription that may have reached Voice213, but whose answer never came, isn't sent again, so you're never charged twice. See Handle errors and retry safely.
  • Clear errors. Every error has a class for its status and a code to branch on, such as INSUFFICIENT_CREDIT or RATE_LIMIT_DAY, with an English message even when the API's own is in Arabic.
  • Live sessions. connect() creates the single-use token and opens the socket. A session streams a WAV file at real-time pace, or your own audio, and keeps the transcript, final sentences and the one being spoken. In the browser, the JavaScript SDK captures the microphone at 16 kHz for you.
  • Types. TypeScript types in the JavaScript SDK, typed results in the Python one, with the docs in your editor.

The answers follow the API Reference, without success. The voices and tones come out of the data the API wraps them in, and your account is flattened to credit, currency and key. In Python, every name is in snake_case: remainingCredit is remaining_credit.

​Keep the key on your server

The SDKs run on your server, where your API key is safe. The JavaScript client refuses to run in a web page, with the code BROWSER_NOT_ALLOWED: a key there would be readable by every visitor. For live transcription in a browser, your server creates a token with the key, and the page opens the session with LiveSession, which never needs the key. See Live transcription in a browser.

​Other languages

From any other language, call the API over HTTP: every endpoint page has a cURL example of the request, and Live Transcription Socket describes the protocol of a live session, message by message.

​Next steps

Was this page helpful?