Stream text in and speech out, with no agent or call involved
wss://api.hilus.ai/Platform/tts/stream
Stream text in and speech out, with no agent or call involved.
The server sends ready. Send config to choose the voice
(provider, voice, model, speed, language, controls, cheaper
streaming) and the audio (format, sample rate, word timestamps);
it is acknowledged with config_updated. Then send one speak
per piece of text: the server answers with audio chunks as they
are generated and a done frame with the chunk count, time to
first audio, total time and, when asked, each word's timing.
Fields on a speak change the configuration from then on. An
invalid configuration (a voice not in your voice list: a custom voice
only speaks for the organization that cloned it) or a failed
synthesis sends error and the stream stays open; close ends
it. Your organization's pronunciation dictionary applies and the
speech cache is on, as on calls; speech is billed per character.
Heartbeat: the server pings every 25.0s; answer each with {"type": "pong"}.
Close codes
| Code | Meaning |
|---|---|
| 1000 | Normal close; also sent when the client stops answering heartbeat pings. |
| 1003 | No WebSocket route at this path. |
| 1008 | Policy violation: credential not accepted for this route, missing scope or role, or invalid connection parameters (the reason names them). |
| 1011 | Server error while handling the connection. |
| 1012 | Server restarting; reconnect. |
| 1013 | Rate or concurrency limit reached; retry later. |
| 4001 | Session expired or missing; re-authenticate (reload) and reconnect. |
| 4002 | Closed for inactivity (no real client frame within the idle timeout); reconnect at once only to resume a conversation the server has stored, otherwise when the user acts again. |
| 4003 | Credential of the wrong kind for this route; do not retry with the same credential. |
Example
// Mint a short-lived session token on your server; never put an API key in a browser or a URL.
const socket = new WebSocket("wss://api.hilus.ai/Platform/tts/stream?token=" + HILUS_SESSION_TOKEN);