Skip to main content
The Speech API pages use one URL per route and the Authorization header. The routes also answer to the names on this page, so existing code keeps working without changes. New code needs none of them, except stream tokens when a browser opens the socket itself.

Other URLs for the same routes

Each one runs the same handler as its route. Auth, fields, headers and billing are identical, so switching changes only the URL.

Other model names

Any other value returns 404 model_not_found. Request-log rows and the socket’s session.begin name the build that served you, for example mira-stt:v5-realtime, whichever name you sent.

Browser stream tokens

A browser cannot set headers on a WebSocket, and your API key must never reach a web page. Your backend mints a short-lived stream token with its key and hands the page only the token.
201 Created (speech to text)
201 Created (text to speech)
url is a path. The page connects to your API host followed by that path. On the speech-to-text socket, add your query parameters after it with &. A token:
  • lasts 60 seconds and opens one socket;
  • acts for the workspace of the key that minted it, under that key’s rate limit;
  • stops working if that key is revoked.
The speech-to-text mint also takes count, up to 20 (?count=5, or {"count": 5} as the body), and returns that many tokens in tokens, each good for one socket. It checks the wallet before minting, so an empty wallet gets 402 insufficient_balance here instead of at the socket. Ignore edge_url: it is null, and you connect to url. A token that is unknown, expired or already used fails the upgrade with 401 invalid_token. Mint a new one for each connection, including a reconnect.
A socket opened with a token can synthesise or transcribe on your wallet until it closes, for up to an hour. Mint tokens only for users you have signed in, one per connection, right before the page connects, and rate-limit the route that mints them.
The browser example on the TTS socket page shows a backend route that mints a token and a page that uses it.

The api-subscription-key header

The speech-to-text socket also accepts the key in an api-subscription-key header in place of Authorization: Bearer. Both carry the same sk_live_ key. An API key in the URL (?api_key=) is refused with 401 on every socket, because URLs end up in proxy and server logs.

Moving from Sarvam realtime

If your code already speaks Sarvam’s v3 realtime protocol, it can connect to the speech-to-text socket as it is. The messages are the same ones, so you change the URL and the key and keep the rest:
  • send the key in api-subscription-key, as you do now, or in Authorization: Bearer;
  • model=saaras:v3-realtime is accepted and served by Mira STT;
  • mode (transcribe or codemix) and stream_type (balanced or fast) are accepted. Both values of each behave the same today.
Mira STT has no automatic language detection, so pass the language you expect in language_code. See Languages.

The original speech endpoint

/tts/v1 and its old mira_ keys predate the current API. The URL is an alias of POST /v1/audio/speech, and the original endpoint’s page says what changed for callers still on it.