Skip to main content
Set 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, and livekit-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:
For an existing project, run the same 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

Pass rime.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.
Keep these points in mind:
  • Encoding: the plugin defaults to binary. Set websocket_protocol="json" to use JSON. Both modes support streaming through session.say() and streamed LLM replies, so do not add a tts.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’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.

Protocol limits

For splitStrategy, 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

Use websocket_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 received ready. 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-side flush operation. An input pause needs no message, and only end_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’s APIConnectOptions.