LiveKit Agents
Deepgram with LiveKit
Deepgram's Aura and Flux in a LiveKit agent: through our plugin, or through LiveKit's Deepgram plugin with a changed URL.
With our plugin#
Deepgram’s Aura and Flux with the settings of LiveKit’s Deepgram plugin (TTS and TTSv2). Deepgram’s model id is the model and the voice joined: model="aura-2" and voice="thalia-en" is aura-2-thalia-en. With Aura, the first sentence of a reply after a pause of about five seconds or more takes about 0.7–1.2 s longer to start than with LiveKit’s plugin; sentences from the cache, and Flux, are unaffected.
pip install livekit-plugins-tts-cache-routerfrom livekit.plugins import tts_cache_router as tcr# The API key comes from TTS_CACHE_ROUTER_API_KEY.tts = tcr.TTS( provider=tcr.Deepgram( model="aura-2", voice="thalia-en", ),)Pass tts to AgentSession(tts=tts). Set TTS_CACHE_ROUTER_API_KEY in the agent’s environment, and store your Deepgram key under Provider keys. The constructor of TTS itself is on the plugin’s page.
tcr.Deepgram(...)#
modelstrDefault"aura-2"aura-2,aura-1orflux.voicestrDefault"andromeda-en"- The voice with its language, e.g.
thalia-en(Aura-2),asteria-en(Aura-1) oralexis-en(Flux). speedfloat | NoneDefaultNone- Speaking rate, 0.7–1.5,
aura-2only.Noneleaves it to Deepgram. mip_opt_outboolDefaultFalse- Opt out of Deepgram's Model Improvement Program.
Every value the router accepts, and the languages per model, are in Models and options.
Changing settings#
Replies that start afterwards use the new settings:
tts.update_options(voice="andromeda-en")With LiveKit's Deepgram plugin#
Keep livekit-plugins-deepgram and point it at the router: your router API key in place of your Deepgram key, and the router’s address. Nothing else changes.
pip install livekit-plugins-deepgramimport osfrom livekit.plugins import deepgramtts = deepgram.TTS( model="aura-2-thalia-en", api_key=os.environ["TTS_CACHE_ROUTER_API_KEY"], base_url="https://api.ttscacherouter.dev/deepgram/v1/speak",)For Flux, use deepgram.TTSv2(model="flux-alexis-en", …) with base_url ending in /deepgram/v2/speak. The plugin streams your agent’s reply word by word; the router splits it into sentences and caches each one, with a few differences from Deepgram’s own messages.
Requests, responses and errors keep Deepgram’s own shape. The endpoints behind it are described in Deepgram API drop-in.
Which to choose#
Both use your org's cache and your stored provider key, and sound the same.
- Our plugin reports only the characters Deepgram billed in LiveKit’s
TTSMetrics(cache hits count zero), and lets you switch provider withupdate_options. - Deepgram’s plugin is the smallest change to an agent that already uses it. Its metrics count every character, cached or not; the dashboard’s Usage page has the real split.