websocket_url="wss://coda.api.rime.ai/ws" and model="coda" in rime.TTS to use Coda WebSocket v1. The plugin handles authorization, message encoding, sentence buffering, audio decoding, and connection reuse.
Install the plugin
Use Python 3.11 or later, uv, andlivekit-plugins-rime version 1.8.2 or later. LiveKit Agents 1.8.2 introduced Coda WebSocket v1 support for both JSON and binary protocols, and earlier plugin versions do not accept websocket_url or websocket_protocol. Set RIME_API_KEY in your server’s environment, because the plugin sends this key to the selected endpoint.
These commands create a project and install the LiveKit Rime plugin:
uv add command in its directory to update the dependency requirement. The plugin installs compatible livekit-agents and rime-api dependencies. Commit your uv.lock file so deployments use the same dependencies.
Use the plugin in an agent session
Passrime.TTS to your AgentSession. This example assumes that the agent already supplies speech recognition and an LLM. Set model="coda", because the plugin reads the model from a /{model}/ws path, and the path on coda.api.rime.ai is only /ws. Without model, the plugin raises ValueError.
- Encoding: the plugin defaults to binary. Set
websocket_protocol="json"to use JSON. Both modes support streaming throughsession.say()and streamed LLM replies, so do not add atts.StreamAdapter. - Agent setup: for room setup, speech recognition, and an LLM, follow the LiveKit agent quickstart, then use the TTS configuration above.
- Direct use: call
stream()when you use the plugin directly, because the WebSocket provider’ssynthesize()method raises an error. Callend_input()to finish input, then keep reading until synthesis ends. Both encodings produce decoded PCM frames.
Plugin parameters
These settings apply to both encodings:
For 8 kHz mu-law, set both
audio_format="audio/pcmu" and sample_rate=8000. The format alone leaves Coda at 24 kHz. The plugin decodes mu-law to 16-bit PCM at the selected rate.
Protocol limits
ForsplitStrategy, config.defaults, or codaParameters.textLookaheadTokens, use a direct client. The adapter does not expose these fields or provide aligned word timestamps.
Move from WS3 to v1
Usewebsocket_url and model for the endpoint, and time_scale_factor for speed. Remove these settings, because the v1 adapter rejects them:
Stream lifecycle
One LiveKit stream uses one Coda context. The adapter opens the context when the first non-empty sentence is ready and uses a pooled connection that has already receivedready.
The adapter also works in these ways:
- Flush: call
flush()only at a complete sentence or stable clause boundary. It can release incomplete buffered text, and there is no server-sideflushoperation. An input pause needs no message, and onlyend_input()finishes normal input. - Connections: sequential turns reuse pooled connections. Concurrent LiveKit streams use separate sockets.
- Options:
speech.update_options(...)changes settings for later streams. Active streams keep their initial settings. - Checks: the plugin checks the subprotocol,
ready.protocol, context IDs, and event order. It discards connections after malformed responses or failed cancellation cleanup. - Timeouts: set connection and terminal timeouts with
speech.stream(conn_options=...), using LiveKit’sAPIConnectOptions.

