Skip to content

The Voice213 API authenticates requests with API keys. Send your key as a Bearer token in the Authorization header of every request. The SDKs do it for you, with the key from the VOICE213_API_KEY environment variable or the one you pass them:

curl -X POST https://api.voice213.com/api/v1/tts \
  -H "Authorization: Bearer $VOICE213_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": "مرحبا بيكم", "model": "voice213-lite", "voice": "nariman"}'

Pass the key yourself when it comes from somewhere else, such as a secret manager. With no key at all, the SDKs refuse a request that needs one before sending it, with the code MISSING_API_KEY.

You can send the key in an x-api-key header instead:

curl https://api.voice213.com/api/v1/me -H "x-api-key: $VOICE213_API_KEY"

When a request has both headers, the Authorization header wins. Write Bearer with a capital B: with any other spelling, Voice213 ignores the header.

The KhasbhaSTT LIVE socket is the one exception: it takes a live token that your server creates with the key, never the key itself.

​Who can use the API

Everyone. The API is open on every plan, Free included, and every account gets the same limits, shared by all its keys. What you need is API credit: a prepaid balance in dinars that pays for your voice-overs and transcriptions, separate from your plan's credits. A key keeps working whatever happens to your plan.

​Your API key

  • Create your keys on the API Keys page of the Developer workspace.
  • A key starts with sk_live_. It's shown once, when you create it; afterwards the page shows only its last eight characters. A lost key can't be shown again: delete it and create a new one.
  • An account can have up to 10 API keys, for example one per app or server. They share your API credit and your limits, so more keys never mean more requests.
  • To replace a key without downtime, create the new one, switch your code to it, then delete the old one.
  • You can switch a key off and on again. While it's off, requests that use it are refused, and your other keys keep working.
  • Voice213 can switch off API access for an account. Its keys are then refused with 403 and the code API_ACCESS_BLOCKED, and it can't create a key or switch one back on. See API access switched off.
  • The API Keys page shows when each key last made a request that counts toward your limits: a voice-over or a live token that succeeded, or a transcription Voice213 started reading (see What counts; estimates, GET /me and the catalogue endpoints don't update it). Usage shows your calls day by day.

​Deleting a key

Delete the key on the API Keys page when it's no longer needed or may have leaked. It stops working immediately, and requests that use it get 401 Invalid or inactive API key. This can't be undone.

​Authentication errors

StatusErrorCause
401Missing API key. Pass it as 'Authorization: Bearer sk_live_...'The request has no key: no Authorization: Bearer header and no x-api-key header.
401Invalid or inactive API keyThe key is wrong, incomplete, switched off or deleted.
403Account deactivatedThe account that owns the key is deactivated or suspended. Contact support.
403API_ACCESS_BLOCKED (in code)API access is switched off for the account that owns the key. The message in error is in Arabic. Contact support.
429Rate limit exceeded: RPM limit exceededYour account reached its requests per minute, all its keys together. See Rate Limits.
429Rate limit exceeded: Daily limit exceededYour account reached its requests per day, all its keys together.
429Rate limit exceeded: Concurrent request limit exceededYour account already has 20 requests running, from any of its keys, voice-overs and transcriptions together (POST /tts and POST /stt only).
500Internal server error during authenticationSomething went wrong on our side while checking the key. Retry.

​Live tokens for browsers

Your API key authenticates every request to the API, and it never leaves your server. KhasbhaSTT LIVE streams over a WebSocket that a browser can open itself, so its socket takes a live token instead of the key:

1

Your server asks for a token

It calls POST /stt/live/token with the API key. For a browser, it sets origin to your site's address, such as https://shop.example.

2

Your server passes it on

It sends the browser the url from the response: the socket's address, with the token in it.

3

The browser opens the socket

It connects to that url and streams the microphone. The session is paid from your API credit.

A live token opens one KhasbhaSTT LIVE session, and can't do anything else:

  • It's single use, and valid for two minutes (expiresIn gives the seconds). Create one per session, just before the browser connects.
  • With origin set, the socket only opens from a page on that exact origin: the same scheme, host and port.
  • It isn't an API key, and doesn't reveal yours. The session's settings, such as the language, the vocabulary and the longest it may run, travel inside it: your server chooses them, and the browser can't change them.

A missing, expired, used or invalid token, or a socket opened from another origin, is refused with HTTP 401 during the handshake. Servers open the socket with a token too: the socket never takes an API key. See Live Transcription Socket.

​Keeping keys safe

An API key gives full access to your API credit. Keep it secret.

  • Store the key in an environment variable or a secret manager, never in source code.
  • Use it only in server-side code. Never put it in websites, mobile apps or anything else you ship to users. To transcribe live in a browser or an app, have your server hand it a live token instead.
  • If the key may have leaked, switch it off right away, then delete it and create a new one.

Was this page helpful?