Get started
Quickstart
From sign-up to a LiveKit agent speaking through the router, in about ten minutes.
You need a Sarvam, Raya or ElevenLabs API key, Python 3.10 or later, and a LiveKit agent on livekit-agents 1.8.5 or later. No agent yet? Step 5 speaks through the router without one.
1. Sign up#
Create your account at ttscacherouter.dev.
Signing up creates your org: the account your API keys, provider keys, cache and usage belong to. Everything below happens in its dashboard.
2. Add your provider key#
The router calls your provider with your own key, so the provider bills you directly, for the sentences it synthesizes.
In the dashboard, open Provider keys and add your key for the provider your agent uses. It’s stored encrypted and never shown again, only its last four characters. Your agent never sends it.
3. Create an API key#
Your agent authenticates to the router with this key alone.
Open API keys and create one. It starts with tcr_ and is shown once, so copy it into your agent’s environment:
export TTS_CACHE_ROUTER_API_KEY=tcr_…4. Connect your agent#
Install our LiveKit plugin and make it your agent's TTS.
pip install livekit-plugins-tts-cache-routerfrom livekit.plugins import tts_cache_router# The API key comes from TTS_CACHE_ROUTER_API_KEY.tts = tts_cache_router.TTS( provider=tts_cache_router.Sarvam( model="bulbul:v3", speaker="shubh", language="hi-IN", ),)# then, in your entrypoint:# session = AgentSession(vad=..., stt=..., llm=..., tts=tts)from livekit.plugins import tts_cache_router# The API key comes from TTS_CACHE_ROUTER_API_KEY.tts = tts_cache_router.TTS( provider=tts_cache_router.Raya( model="standard", voice_id="d6a002d0-230c-49b1-a137-b8a7d564b1ae", language="hi", ),)# then, in your entrypoint:# session = AgentSession(vad=..., stt=..., llm=..., tts=tts)from livekit.plugins import tts_cache_router# The API key comes from TTS_CACHE_ROUTER_API_KEY.tts = tts_cache_router.TTS( provider=tts_cache_router.ElevenLabs( voice_id="JBFqnCBsd6RMkjVDRZzb", model="eleven_flash_v2_5", ),)# then, in your entrypoint:# session = AgentSession(vad=..., stt=..., llm=..., tts=tts)The provider’s settings keep the provider’s own names: speaker and pace for Sarvam, voice_id for Raya and ElevenLabs. Every option is on the provider’s page: Sarvam, Raya, ElevenLabs. Already using the provider’s own LiveKit plugin? You can keep it and change only its URL and key; each provider’s page shows how.
5. Hear it, twice#
Run your agent and talk to it. Or, without an agent, speak one sentence with this script.
import asyncioimport aiohttpfrom livekit import rtcfrom livekit.plugins import tts_cache_routerasync def main() -> None: async with aiohttp.ClientSession() as http: tts = tts_cache_router.TTS( provider=tts_cache_router.Sarvam(model="bulbul:v3", speaker="shubh", language="hi-IN"), http_session=http, ) tts.on("metrics_collected", lambda m: print(f"characters billed by the provider: {m.characters_count}")) frames = [event.frame async for event in tts.synthesize("धन्यवाद, आपकी चार लोगों की टेबल आज रात आठ बजे के लिए बुक है।")] with open("hello.wav", "wb") as f: f.write(rtc.combine_audio_frames(frames).to_wav_bytes()) await tts.aclose()asyncio.run(main())import asyncioimport aiohttpfrom livekit import rtcfrom livekit.plugins import tts_cache_routerasync def main() -> None: async with aiohttp.ClientSession() as http: tts = tts_cache_router.TTS( provider=tts_cache_router.Raya(model="standard", voice_id="d6a002d0-230c-49b1-a137-b8a7d564b1ae", language="hi"), http_session=http, ) tts.on("metrics_collected", lambda m: print(f"characters billed by the provider: {m.characters_count}")) frames = [event.frame async for event in tts.synthesize("धन्यवाद, आपकी चार लोगों की टेबल आज रात आठ बजे के लिए बुक है।")] with open("hello.wav", "wb") as f: f.write(rtc.combine_audio_frames(frames).to_wav_bytes()) await tts.aclose()asyncio.run(main())import asyncioimport aiohttpfrom livekit import rtcfrom livekit.plugins import tts_cache_routerasync def main() -> None: async with aiohttp.ClientSession() as http: tts = tts_cache_router.TTS( provider=tts_cache_router.ElevenLabs(voice_id="JBFqnCBsd6RMkjVDRZzb", model="eleven_flash_v2_5"), http_session=http, ) tts.on("metrics_collected", lambda m: print(f"characters billed by the provider: {m.characters_count}")) frames = [event.frame async for event in tts.synthesize("Thanks for calling. Your table for four is booked for eight tonight.")] with open("hello.wav", "wb") as f: f.write(rtc.combine_audio_frames(frames).to_wav_bytes()) await tts.aclose()asyncio.run(main())Run it twice. The first run synthesizes the sentence at the provider and caches it; the second plays it from the cache, so the provider bills nothing (the Hindi sentence is 60 characters, the ElevenLabs one 68). Both write the same voice to hello.wav.
$ python hello.pycharacters billed by the provider: 60$ python hello.pycharacters billed by the provider: 06. See what it saved#
The dashboard's Usage page counts sentences served from the cache against those the provider synthesized.
Open Usage: per hour or per day, and per provider, the hit rate, and the characters the cache kept off your provider’s bill. Counts arrive within about a minute.
Next: how the cache works, or every setting of the LiveKit plugin.