Skip to content
POST
https://api.voice213.com/api/v1/stt/live/token
curl -X POST https://api.voice213.com/api/v1/stt/live/token \
  -H "Authorization: Bearer $VOICE213_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "language": "ar",
    "dialect": "algerian",
    "vocabulary": ["Voice213", "Yalidine"],
    "maxSeconds": 600
  }'
{
  "success": true,
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI2NmYxYzBhNGUxYjJjM2Q0ZTVmNjA3MTgi…",
  "url": "wss://api.voice213.com/ws/stt?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI2NmYxYzBhNGUxYjJjM2Q0ZTVmNjA3MTgi…",
  "wsUrl": "wss://api.voice213.com/ws/stt",
  "expiresIn": 120,
  "model": "khasbha-stt-live",
  "language": "ar",
  "dialect": "algerian",
  "maxSeconds": 600,
  "sampleRate": 16000,
  "encoding": "pcm_s16le",
  "channels": 1,
  "pricePerMinute": 5,
  "minBillableSeconds": 15,
  "currency": "DZD"
}

Creates a single-use token for one KhasbhaSTT LIVE session, and returns the address of the socket to open with it. Call it from your server, with your API key. The token is what you hand to a browser or an app, never the key. See Live Transcription Socket for what happens on the socket, and KhasbhaSTT LIVE for a guide.

  • One session, within two minutes. A token opens a single session, and only if it's used within 120 seconds of being created.
  • The settings travel in the token. The language, dialect, vocabulary, maxSeconds and origin you send here are fixed for the session. To change them, create a new token.
  • Tied to your website. A token created with an origin only opens a socket from a page on that origin, so other websites can't use it. Set it for every token you hand to a browser.
  • Free, but counted. Creating a token isn't billed: the session is, per second of audio. Each token counts as one request toward your account's requests per minute and per day.
  • Checked twice. Your API credit and your running sessions are checked here, and again when the socket opens.

Authorizations

Authorizationstringrequired

Your API key as a Bearer token: Bearer sk_live_.... You can send it in an x-api-key header instead. See Authentication.

Body

application/json

Every field is optional: an empty body creates a session for Algerian darija that can last up to an hour, as far as your API credit covers.

languageenum<string>default: ar

The language people will speak: ar (Arabic, darija included), fr (French) or en (English), in any capitalization. Any other value gets 400 INVALID_LANGUAGE. See Languages and dialects.

dialectenum<string>default: algerian

The Arabic dialect the transcription is tuned for: algerian, tunisian or libyan, in any capitalization. It applies when language is ar, and is null in the answer otherwise. Any other value gets 400 INVALID_DIALECT.

vocabularystring[]

Words the transcription should recognize, such as your brand, your products, people and places: up to 50 terms, each 1 to 40 characters long once spaces are trimmed. Duplicates, in any capitalization, are dropped, and the first spelling is kept. Anything else, such as a term that isn't a string, gets 400 INVALID_VOCABULARY.

maxSecondsintegerdefault: 3600

The longest the session may last, in seconds: a whole number from 15 to 3,600. The session gets an ENDING_SOON warning 30 seconds before, then ends with the reason max_duration. Use it to cap what one session can spend: 600 seconds cost 50 DA at most. Any other value gets 400 INVALID_MAX_SECONDS.

originstring

The origin of the web page that will open the socket, written scheme://host or scheme://host:port, such as https://shop.example or http://localhost:8080: http or https, and no path (a trailing slash is fine). The socket must then be opened with exactly that Origin header, which browsers send for the page that opens it; any other origin, or none, is refused with 401 during the handshake. https://www.shop.example and https://shop.example are two different origins. Leave it out for a socket opened by your server or an app. Anything else gets 400 INVALID_ORIGIN.

Response

application/json
successbooleanrequired

true.

tokenstringrequired

The token. It opens one session, within expiresIn seconds.

urlstringrequired

The socket to open, with the token already in it: wss://api.voice213.com/ws/stt?token=….

wsUrlstringrequired

The socket without the token, wss://api.voice213.com/ws/stt, if you'd rather add ?token= yourself.

expiresInnumberrequired

Seconds left to open the socket with the token: 120.

modelstringrequired

khasbha-stt-live.

languagestringrequired

The session's language: ar, fr or en.

dialectstring | nullrequired

The dialect the session uses for Arabic, such as algerian, or null when language isn't ar.

maxSecondsnumberrequired

How long the session could last if it started now: your maxSeconds, and no longer than your available API credit covers. It's checked again when the socket opens, and the ready message has the final figure.

sampleRatenumberrequired

The rate of the audio to send: 16000 Hz.

encodingstringrequired

The audio format to send: pcm_s16le, 16-bit signed little-endian PCM.

channelsnumberrequired

1: mono.

pricePerMinutenumberrequired

The session's price, in dinars per minute of audio.

minBillableSecondsnumberrequired

The fewest seconds a session that receives audio is billed: 15.

currencystringrequired

DZD.

Errors

StatusErrorWhen
400INVALID_LANGUAGElanguage isn't ar, fr or en. The body lists the languages.
400INVALID_DIALECTdialect isn't algerian, tunisian or libyan. The body lists the dialects.
400INVALID_VOCABULARYvocabulary isn't a list of up to 50 terms of 1 to 40 characters. The body has maxTerms and maxTermChars.
400INVALID_MAX_SECONDSmaxSeconds isn't a whole number from 15 to 3,600. The body has min and max.
400INVALID_ORIGINorigin isn't an http or https origin without a path, such as https://shop.example.
401Missing API key. Pass it as 'Authorization: Bearer sk_live_...'The request has no key.
401Invalid or inactive API keyThe key is wrong, switched off or deleted.
402INSUFFICIENT_CREDITYour API credit, less what your running requests and sessions have set aside, can't cover the shortest session, 15 seconds (1.25 DA). The body has required and balance.
403Account deactivatedThe account that owns the key is deactivated or suspended.
403API_ACCESS_BLOCKED (in code)API access is switched off for the account.
429SESSION_LIMITYour account already has 5 live sessions running. Retry when one of them ends. The body has the limit.
429Rate limit exceeded: RPM limit exceeded or Rate limit exceeded: Daily limit exceededYour account's requests per minute or per day, all its keys together.
500INTERNALThe token couldn't be created. Retry in a moment.
503TOOL_DISABLED (in code)Speech to text through the API is paused (tool is stt_api), or every paid request of the API is (public_api). Retry later. Sessions already running carry on.
503MAINTENANCE (in code)The API is down for maintenance. Retry later.

What happens once the socket is open, such as a session refused at that point, is in the socket's close codes and errors.

Was this page helpful?