Get started

Quickstart

Sign up, store your provider key, and hear a sentence through the router: once from the provider, then from the cache.

View as Markdown

You need an API key from one of the providers (or none, for Maya Open-Source), Python 3.10 or later, and, for step 4, a LiveKit agent on livekit-agents 1.8.5 or later. Step 5 works without an agent.

1. Sign up#

Create your account at ttscacherouter.dev.

Signing up creates your org, which owns your API keys, provider keys, cache and usage, and an API key for it. The next two steps happen on the dashboard’s home.

2. Add your provider key#

Pick the provider your agent uses and add your key for it.

The router calls the provider with this key, so the provider bills you directly for the sentences it synthesizes. The key is stored encrypted and never shown again; your agent never sends it.

Maya Open-Source runs on our own GPU and needs no key: skip this step for it. We bill its synthesized characters from your credit.

3. Copy your API key#

Your agent authenticates to the router with this key alone.

Copy it from the top of the dashboard. It starts with tcr_. Set it in 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-router
from livekit.plugins import tts_cache_router as tcr# The API key comes from TTS_CACHE_ROUTER_API_KEY.tts = tcr.TTS(    model="maya/maya-2-native",    voice="Monika",    language="hi",)# then, in your entrypoint:# session = AgentSession(vad=..., stt=..., llm=..., tts=tts)

The settings use the same names for every provider: model as <provider>/<model>, voice, language, speed and the provider’s options. Every option is on the provider’s page: Maya Open-Source, Vaakini, Sarvam, Raya, ElevenLabs, OpenAI, Deepgram, xAI, Soniox, Smallest AI, Cartesia, Gemini, 60db. Each third-party provider’s page also shows how to keep the provider’s own LiveKit plugin and change only its URL and key.

5. Hear it, twice#

Run your agent and talk to it, or speak one sentence with this script.

import asyncioimport aiohttpfrom livekit import rtcfrom livekit.plugins import tts_cache_router as tcrasync def main() -> None:    async with aiohttp.ClientSession() as http:        tts = tcr.TTS(            model="maya/maya-2-native",            voice="Monika",            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())

Run it twice. The first run synthesizes the sentence at the provider, which bills its characters (60 for the Hindi sentence, 68 for the English one; for Maya Open-Source, we bill them), and caches it. The second plays it from the cache and bills nothing. Both write the same audio to hello.wav.

Shell
$ python hello.pycharacters billed by the provider: 60$ python hello.pycharacters billed by the provider: 0

6. See what it saved#

The dashboard's Usage page counts sentences served from the cache against those the provider synthesized.

Open Usage for the hit rate and the characters kept off your provider’s bill, per hour or day and per provider. Counts arrive within about a minute.

Next: how the cache works, or every setting of the LiveKit plugin.