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.
Parameters from OpenAI, Sarvam and ElevenLabs
The speech endpoint accepts the voice controls and format names other providers use, so a client written for them needs fewer changes.pitch and loudness are our own fields. See
Speed, pitch and loudness.
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.- cURL
- Python
- Node.js
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.
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.
The text-to-speech mint checks the wallet too: a socket costs ₹0.90 a minute,
so it needs one minute’s price before it mints. See
WebSocket billing.
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.
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 anapi-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 inAuthorization: Bearer; model=saaras:v3-realtimeis accepted and served by Mira STT;mode(transcribeorcodemix) andstream_type(balancedorfast) are accepted. Both values of each behave the same today.
language_code=unknown, Sarvam’s value for a language you don’t know, is
read as auto: Mira STT works out the language of each utterance among its
ten. If you know the language, pass it instead, because a fixed language is
the most accurate and the fastest. 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: it runs the same handler and returns the same audio.
A caller still on it changes only its key:
- Auth is your
sk_live_API key from the console’s Developers page. The oldmira_speech keys are retired. modelismira-tts.mira-tts-v51is accepted as an alias, so an old body keeps working.- Everything else follows the current endpoint: voices, output formats, streaming, the 2,000-character limit, headers, price and request log. See the TTS quickstart.
speech_ready,instructions,lexiconandnumbers, which only the old endpoint had, are ignored. Sending them is not an error.