Why Use KugelAudio with LiveKit?
- Native plugin: Drop-in TTS provider for LiveKit’s
AgentSession - Streaming support: Real-time WebSocket-based audio streaming
- Ultra-low latency: streaming TTS built for real-time agents — see Latency for current TTFA figures
- Simple setup: Works with
VoicePipelineAgentand the newAgentSessionAPI
Installation
livekit-agents>=1.1.0).
Quick Start
Minimal Voice Agent
Set the
KUGELAUDIO_API_KEY environment variable or pass api_key directly to the TTS constructor.TypeScript / JavaScript
The KugelAudio TS/JS SDK ships the same plugin for LiveKit Agents for Node.js. Import it from thekugelaudio/livekit subpath.
Installation
@livekit/agents and its peer @livekit/rtc-node are optional peer dependencies of kugelaudio — they are only required when you import kugelaudio/livekit. The core kugelaudio client never loads them.
The subpath is importable from both ESM and CommonJS, and its types resolve
under every TypeScript moduleResolution setting. See
Module systems for details.
Quick Start
Set the
KUGELAUDIO_API_KEY environment variable or pass apiKey to the TTS constructor. A full runnable worker lives at packages/public/js-sdk/examples/livekit_agent.ts.TTS Options (JS/TS)
Options are camelCase and otherwise mirror the Python plugin:Streaming, one-shot, and runtime updates (JS/TS)
Configuration
TTS Parameters
Supported Sample Rates
Models
Usekugel-3 — the current production model for all use cases (voice agents,
narration, brand voices). See Models for capabilities and
Latency for TTFA figures.
See Models for the full comparison.
Usage Patterns
Non-Streaming Synthesis
Usesynthesize() for one-shot text-to-speech:
Streaming Synthesis
Usestream() for real-time text input (e.g., from an LLM):
Setting the Language
Setlanguage to skip server-side auto-detection on every request (see Latency):
Updating Options at Runtime
You can change TTS options dynamically without creating a new instance:Word-Level Alignment
Word timestamps are off by default (including forkugel-3), which avoids server-side post-processing errors on models where alignment is not yet supported.
When you set word_timestamps=True, the server performs forced alignment on each audio chunk and delivers per-word timing alongside the audio. LiveKit’s AgentSession uses these timings for barge-in and transcript sync via the aligned_transcript capability (advertised only when timestamps are enabled).
Timestamp frames are delivered after their corresponding audio chunks, so
clients do not need to hold audio playback while waiting for them. See
Word timestamps.
Plugin Registration
You can also register KugelAudio as a LiveKit plugin namespace:Complete Voice Agent Example
Here’s a production-ready voice agent with metrics logging:Running the Agent
Save the complete example above asvoice_agent.py, then run it in LiveKit’s
console or worker mode:
Environment Variables
Troubleshooting
API key not found
API key not found
Make sure
KUGELAUDIO_API_KEY is set in your environment or pass api_key directly:WebSocket connection fails
WebSocket connection fails
Verify your
base_url is correct and the KugelAudio API is reachable. The plugin connects via WebSocket (wss://) for audio streaming.Audio quality issues
Audio quality issues
- Use the native
24000Hz sample rate for best results - Try increasing
cfg_scale(e.g.,2.5) for more expressive output - Switch to
kugel-3model for premium quality
High latency
High latency
- Set
languageexplicitly (e.g.language="de") to skip auto-detection — see Latency - Create and reuse one
TTSinstance instead of constructing one for every phrase - Call
prewarm()before the first turn; both the Python and JavaScript plugins support it - Measure from the same region as the API before changing synthesis parameters
Next Steps
Pipecat Integration
Use KugelAudio with Pipecat pipelines
Streaming
Advanced streaming techniques