npm install: just node:http and fetch. 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. The Next.js, Vite, Express, and FastAPI starters show the same boundary in their respective frameworks.
Prerequisites
- A Rime API key from the API Tokens page, exported as
RIME_API_KEY - Node.js 20.11 or later. Nothing else is required.
1. Server
Createserver.mjs:
server.mjs
index.html first if you’re testing the API route alone):
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
index.html at startup), open http://localhost:3000, select Speak, say something, and the agent answers in Rime’s astra voice.
Add streaming when latency matters
For incremental synthesis, connect your server towss://users-ws.rime.ai/ws3 and relay events to the browser. 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 browser-facing side adds the one dependency, ws. The Next.js guide provides a complete bridge that works with the same createServer instance. The Coda WebSocket reference defines the /ws3 schema.
Production building blocks
WebSocket API overview
Endpoints, word-level timestamps, context IDs, and interruption handling.
Voices
Swap
astra for any Coda voice. Coda covers eight languages, and each voice serves one of them.Streaming formats
Choose between Opus, MP3, WAV, PCM, and μ-law for your latency budget.
TTS in five minutes
The core API walkthrough in cURL, Python, JavaScript, and TypeScript.

