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.- 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.
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. 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.