Skip to main content
This guide builds a working voice agent on Express: the browser captures speech, your Express server decides what to say, and Rime speaks the reply. There is no Rime npm package to install — and you don’t need one. Rime is a single HTTPS API; the route below is plain 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

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, 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.