Skip to main content
This guide builds a working voice agent with zero dependencies — no framework, no packages, no npm install. Just node:http and Node’s built-in fetch. If you want the same agent on a framework, see the Next.js, Vite, Express, or FastAPI guides. There is no Rime npm package — and you don’t need one. Rime is a single HTTPS API.

Prerequisites

  • A Rime API key from the API Tokens page, exported as RIME_API_KEY
  • Node.js 20.11 or later — nothing else

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, 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 — connect your server to wss://users-ws.rime.ai/ws3 and relay events to the browser. Rime’s WebSocket endpoints authenticate with an Authorization header, which browser WebSockets cannot send, so the bridge always lives server-side; the browser-facing side needs the ws package (the one dependency streaming adds). The complete bridge implementation is in the Next.js guide and works with this same createServer instance. 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.

TTS in five minutes

The core API walkthrough in cURL, Python, JavaScript, and TypeScript.