fetch.
Prerequisites
- A Rime API key from the API Tokens page, exported as
RIME_API_KEY - A Vite + React project (
npm create vite@latest -- --template react-tsdefaults work) - Express for the proxy:
npm install express
1. The TTS proxy server
Createserver.mjs in the project root:
server.mjs
vite.config.ts, so the browser can call a same-origin /api/tts:
vite.config.ts
test.mp3 should be playable audio. A 401 means RIME_API_KEY isn’t visible to server.mjs.
2. Client: mic in, Rime audio out
Replacesrc/App.tsx. It uses the browser’s built-in SpeechRecognition for input (Chrome/Edge/Safari), a stub respond() function as the agent brain, and the proxy for the voice:
src/App.tsx
http://localhost:5173, click Speak, say something, and the agent answers in Rime’s astra voice.
In production, deploy
server.mjs (or fold the route into whatever backend you already have) and serve Vite’s built assets from it — the same-origin /api/tts path keeps working. The API key lives only in the server environment.Want streaming?
For incremental synthesis — audio starts playing while later sentences are still generating — connect your server to Rime’s WebSocket API and relay events to the browser. Rime’s WebSocket endpoints authenticate with anAuthorization header, which browser WebSockets cannot send, so the bridge always lives server-side. The bridge pattern is identical to the one in the Next.js guide; 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.

