Skip to main content
Build a minimal voice-agent loop on one Express server: the browser captures speech, your server decides what to say, and Rime speaks the reply. This starter uses browser speech recognition and a stub response function; replace both with production components. Keep RIME_API_KEY on the server and call Rime over HTTPS with fetch. No Rime-specific npm package is required; Express is the only dependency.

Prerequisites

  • A Rime API key from the API Tokens page, exported as RIME_API_KEY
  • Node.js 20.11+ and npm install express

1. Server: Express app with a TTS route

Create server.mjs:
server.mjs
Verify it works before touching the frontend:
test.mp3 should be playable audio. A 401 means RIME_API_KEY isn’t visible to the server process.

2. Client: mic in, Rime audio out

Create index.html next to server.mjs. It uses the browser’s built-in SpeechRecognition for input (Chrome/Edge/Safari), a stub respond() function as the agent brain, and your /api/tts route for the voice:
index.html
Open http://localhost:3000, select Speak, say something, and the agent answers in Rime’s astra voice.

Add streaming when latency matters

Legacy Coda /ws3. Use this section only for an existing /ws3 integration. For new clients, use the Coda v1 JSON quickstart. Its message format differs and it has no word timestamps.
For an existing /ws3 integration, attach a WebSocket bridge to the same HTTP server: browser WS ↔ Express server ↔ wss://users-ws.rime.ai/ws3 with header authentication. Audio can then start while later sentences are still generating. Browser WebSockets cannot send the required Authorization header, so the bridge stays server-side. The legacy Next.js bridge provides the complete bridge; it works with Express’s HTTP server through const server = app.listen(3000).

Production building blocks

Choose a WebSocket API

Compare Coda v1 and Mist endpoints, message formats, and synthesis controls.

Voices

Swap astra for any Coda voice. Coda covers nine languages, and each voice serves one of them.

Streaming formats

Choose between Opus, MP3, WAV, PCM, and μ-law for your latency budget.

Plain Node (no framework)

Build the same starter with only node:http and built-in fetch.