fetch, and 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
Createserver.mjs:
server.mjs
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
Createindex.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
http://localhost:3000, click Speak, say something, and the agent answers in Rime’s astra voice.
Want streaming?
For incremental synthesis — audio starts playing while later sentences are still generating — attach a WebSocket bridge to the same HTTP server: browser WS ↔ Express server ↔wss://users-ws.rime.ai/ws3 with header auth. Rime’s WebSocket endpoints authenticate with an Authorization header, which browser WebSockets cannot send, so the bridge always lives server-side. The complete bridge implementation (using the ws package with new WebSocketServer({ server })) is in the Next.js guide — it works unchanged with Express’s underlying HTTP server via const server = app.listen(3000). The /ws3 message schema is in the Coda WebSocket reference.
Next steps
WebSocket API overview
Endpoints, word-level timestamps, context IDs, and interruption handling.
Voices
Swap
astra for any Coda voice across six languages.Streaming formats
Choose between Opus, MP3, WAV, PCM, and μ-law for your latency budget.
Plain Node (no framework)
The same agent with zero dependencies — just node:http and built-in fetch.

