Skip to main content
The Rime API authenticates every request with a bearer token in the Authorization header: Authorization: Bearer YOUR_API_KEY. See API authentication for how to create a key.

Overview

This WebSocket sends and receives JSON messages. Compared with the plain-text WebSocket, it adds word-level timestamps, a done event after each synthesis, and contextId tagging. You pass every synthesis parameter as a query parameter when you open the connection, and those settings apply for the life of the connection. The API buffers input until it detects a sentence boundary, typically at ., ?, or !, so synthesis starts once it has enough text for natural prosody. The wait is most noticeable on the first sentence. After that, later text usually arrives while earlier audio is still playing, and the buffering becomes largely invisible. To change when synthesis starts, set segment.

Messages

Send

Text

Sends text for synthesis. This is the message your client sends most often. schema:
examples:
If you set contextId, the server attaches it to the events it sends back for that text. The server tracks one context ID at a time, and each event carries the most recent context ID at the time its audio was requested. In the examples above, even if the server receives both messages before it sends any audio, the first sentence’s audio is tagged contextId: null and the second sentence’s audio is tagged with its UUID.

Clear

Discards buffered text that hasn’t been synthesized yet. Send it when the user interrupts. It doesn’t cancel a synthesis already in progress, so stop playback in your client and drop any audio that still arrives.

Flush

Synthesizes whatever text is buffered, without waiting for a sentence boundary, and sends the audio.

EOS

Synthesizes whatever text is buffered, sends the audio, and then the server closes the connection.

Receive

Chunk

Carries a piece of the synthesized audio. This is the event your client receives most often.
data holds base64-encoded audio in the audioFormat set at connection time. Decode each chunk and append the bytes in order to rebuild the audio. If the text that produced this audio had a contextId, the event includes it.

Timestamps

The server sends word-level timestamps alongside the audio chunks, so your client can tell which words have been spoken at any point. When the user talks over the output, map the playback position back to the last word they actually heard.
Timestamps are emitted only when lang is en/eng or es/spa, or when lang is omitted. Requests in any other language receive chunk and done events with no timestamps event and no error. Don’t block playback while waiting for a timestamps event.
The three arrays inside word_timestamps are the same length and index-aligned: for a given index i, words[i] is spoken from start[i] to end[i]. Times are in seconds, measured from the beginning of the audio for the current synthesis. If a context id was attached to the text that produced this audio, it is included on the event. Example payload:

Done

After the last audio chunk for a synthesis batch has been sent, the server emits a done event. This signals that the current synthesis is fully complete. If the client sends more text and triggers further synthesis, another done will follow. The eos operation emits a final done for any remaining buffered content before the server closes the connection. If the buffer is already empty, the server closes without sending a done.
On /ws2, the done event carries an extra boolean done: true field in addition to type: "done". On /ws3 the event contains only type and contextId. Match on type === "done" to handle both.
When exactly done fires depends on the segment setting. See Segmentation and behavior settings for full details.

Error

If a message is malformed or unexpected, the server responds immediately with an error event. The server does not close the connection and keeps accepting well-formed messages, so your client decides whether to close it.

Variable parameters

string
required
Must be a voice from the Rime voice catalog.
string
Set to mistv2.
string
One of mp3, mulaw, or pcm
string
default:"eng"
If provided, the language must match the language spoken by the selected speaker. Verify the pairing in the Rime voice catalog.
bool
default:"false"
When set to true, adds pauses between words enclosed in angle brackets. The number inside the brackets specifies the pause duration in milliseconds.
Example: “Hi. <200> I’d love to have a conversation with you.” adds a 200ms pause between the first and second sentences.
bool
default:"false"
When set to true, you can specify the phonemes for a word enclosed in curly brackets.
Example: “{h’El.o} World” pronounces “Hello” with the phonemes you supplied. Learn more about custom pronunciation.
string
Comma-separated list of speed values applied to words in square brackets. Values < 1.0 speed up speech, > 1.0 slow it down. Example: “This is [slow] and [fast]”, use “3, 0.5” to make “slow” slower and “fast” faster.
int
The value, if provided, must be between 4000 and 44100. Default: 22050
float
default:"1.0"
Adjusts the speed of speech. Lower than 1.0 is faster and higher than 1.0 is slower.Note: this is the legacy Mist v2 convention. Coda and Mist v3 invert it, so for those models higher than 1.0 is faster.
bool
default:"false"
mist/mistv2 only. Skips text normalization before synthesis. This reduces latency, but digits and abbreviations reach the model unexpanded and may be mispronounced.
string
default:"bySentence"
Controls how text is segmented for synthesis. Available options:
  • “immediate” - Synthesizes text immediately without waiting for complete sentences
  • “never” - Never segments the text, waits for explicit flush or EOS
  • “bySentence” (default) - Waits for complete sentences before synthesis
Note: For backward compatibility, setting immediate=true in query params is equivalent to segment=immediate. If a null value is provided, it will default to “bySentence”.