Skip to main content
Build a minimal voice-agent loop with Node.js built-ins only. There is no framework, package, or 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

Create server.mjs:
server.mjs
Verify it works before touching the frontend (create an empty 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

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
Restart the server (it reads 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

Legacy Coda /ws3. Use this section only for an existing /ws3 integration. For new clients, use the Coda WebSocket v1 JSON quickstart. Coda WebSocket v1 uses a different message format and does not return word timestamps.
For an existing /ws3 integration, connect your server to wss://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 one dependency, ws. The legacy Next.js bridge provides a complete bridge that works with the same createServer instance.

Production building blocks

WebSocket API overview

Compare Coda WebSocket v1 with the legacy endpoints, their message formats, and their synthesis controls.

Voices

Swap astra for any Coda voice. Coda covers ten 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.