websocket_url="wss://api.rime.ai/coda/ws" 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 and uv. SetRIME_API_KEY in your server’s environment. The plugin sends this key to the selected endpoint.
Use livekit-plugins-rime version 1.8.2 or later. LiveKit Agents 1.8.2 introduced Coda WebSocket v1 support, including both JSON and binary protocols. Earlier plugin versions do not accept websocket_url or websocket_protocol.
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 the agent already supplies speech recognition and an LLM. Omit model because /coda/ws selects Coda; supplying both raises ValueError.
websocket_protocol="json" to use JSON. Both modes support streaming through session.say() and streamed LLM replies. Do not add a tts.StreamAdapter.
For room setup, speech recognition, and an LLM, follow the LiveKit agent quickstart, then use the TTS configuration above.
Run the audio demo
Download the audio demos, extract the archive, and open itscoda-audio-demos directory. With RIME_API_KEY set and a local audio output device available, run:
Playback complete. It needs no LiveKit room, speech recognition provider, or LLM. To test JSON, run RIME_WEBSOCKET_PROTOCOL=json uv run stream_livekit.py. The included README covers audio-device setup and troubleshooting.
For direct plugin calls, use stream(); the WebSocket provider’s synthesize() method raises an error. Call end_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.
Supported settings
Withwebsocket_url, do not supply base_url, use_websocket=True, segment, reduce_latency, speed_alpha, or generation controls such as temperature. These select or configure older interfaces and the adapter rejects them. Use time_scale_factor for speed.
The adapter does not expose splitStrategy, config.defaults, or codaParameters.textLookaheadTokens. Use a direct client if your application needs these fields. It does not provide aligned word timestamps.
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.
Call
flush() only at a complete sentence or stable clause boundary. It can release incomplete buffered text, and there is no server-side flush operation. An input pause needs no message. Only end_input() finishes normal input.
- Sequential turns reuse pooled connections. Concurrent LiveKit streams use separate sockets.
speech.update_options(...)changes settings for later streams; active streams retain their initial settings.- The plugin checks the subprotocol,
ready.protocol, context IDs, and event order. It discards connections after malformed responses or failed cancellation cleanup. - Set connection and terminal timeouts with
speech.stream(conn_options=...)using LiveKit’sAPIConnectOptions.

