RIME_API_KEY on the server and call Rime over HTTPS with httpx. No Rime-specific PyPI package is required.
Prerequisites
- A Rime API key from the API Tokens page, exported as
RIME_API_KEY - Python 3.10+ with
pip install fastapi uvicorn httpx
1. Server: FastAPI app with a TTS endpoint
Createmain.py:
main.py
test.mp3 should be playable audio. A KeyError: 'RIME_API_KEY' at startup means the environment variable isn’t set.
2. Client: mic in, Rime audio out
Createindex.html next to main.py. 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 endpoint for the voice:
index.html
http://localhost:8000, select Speak, say something, and the agent answers in Rime’s astra voice.
Add streaming when latency matters
For an existing/ws3 integration, connect your server to wss://users-ws.rime.ai/ws3 with the Python websockets library and relay events through FastAPI’s WebSocket support. Audio can then start while later sentences are still generating. Browser WebSockets cannot send the required Authorization header, so the Rime connection stays server-side.
Production building blocks
Choose a WebSocket API
Compare Coda v1 and Mist endpoints, message formats, and synthesis controls.
Voices
Swap
astra for any Coda voice. Coda covers nine languages, and each voice serves one of them.Streaming formats
Choose between Opus, MP3, WAV, PCM, and μ-law for your latency budget.
Pipecat
Building a full Python voice pipeline? Use the ready-made Rime plugin.

