Frameworks: LiveKit Agents & Pipecat¶
If you build on an agent framework you don't write the WebSocket loop from the voice agents guide yourself: a
Vartaloop TTS plugin does it for you. Each plugin opens one WS /v1/tts/stream per session, sends every sentence of a turn as its own
utterance as the LLM produces it, forwards 24 kHz 16-bit PCM as it arrives, and drops the socket on a barge-in so the server stops
synthesising the interrupted turn. First audio stays at 40–60 ms on top of the network.
| Framework | Package | Status |
|---|---|---|
| Pipecat (Python) | pipecat-vartaloop — vartalaap-si/pipecat-vartaloop |
Live. Community integration, listed in Pipecat's supported services since 1.16.0; see the page on docs.pipecat.ai. |
| LiveKit Agents (Python) | livekit-plugins-vartaloop — livekit/agents#8449 |
In review at LiveKit. Install from the branch until it is on PyPI. |
| LiveKit Agents (Node) | @livekit/agents-plugin-vartaloop — livekit/agents-js#2958 |
In review at LiveKit. On npm when it lands. |
All three take the same options as the API: voice, expression, digits, speed, temperature, seed, postfx, profile,
raw (POST /v1/tts has the meanings). Every option travels with each utterance, so changing one mid-call applies
from the next sentence without reconnecting. The key is read from VARTALOOP_API_KEY.
Pipecat¶
uv add pipecat-vartaloop
export VARTALOOP_API_KEY="vt_live_…" # from https://tts.vartaloop.ai/keys
import os
from pipecat.pipeline.pipeline import Pipeline
from pipecat_vartaloop import VartaloopTTSService
tts = VartaloopTTSService(
api_key=os.environ["VARTALOOP_API_KEY"],
settings=VartaloopTTSService.Settings(
voice="saanvi", expression="neutral", digits="mixed",
),
)
pipeline = Pipeline([
transport.input(), stt, user_aggregator,
llm, tts,
transport.output(), assistant_aggregator,
])
VartaloopTTSServiceis the WebSocket service for conversational agents. Audio frames carry the turn'scontext_id, so an interrupted turn's leftovers are discarded and the socket is reopened to cancel what the server was still synthesising.VartaloopHttpTTSServicemakes one chunkedPOST /v1/ttsper sentence; use it in pipelines without interruptions.- Change a setting mid-call with
TTSUpdateSettingsFrame(delta=VartaloopTTSService.Settings(expression="excited")). sample_ratedefaults to the pipeline's rate; the 24 kHz audio is resampled on the way out when they differ.- Tested with Pipecat 1.15. Measured through a real pipeline the service adds about 2 ms of time-to-first-audio over a raw WebSocket
call (
bench/in the repository).examples/voice-vartaloop.pyis a complete agent; run it with--transport webrtcfor a browser client.
LiveKit Agents (Python)¶
Until the pull request is merged, install the plugin from the source archive of the reviewed commit. This needs no git and no
Git LFS; a git+https link to this repository does, because it is a full copy of LiveKit's repository.
pip install "livekit-agents>=1.8.12" "livekit-plugins-vartaloop @ https://github.com/vartalaap-si/vartaloop-agents/archive/\
37baabb5183f687a65cdb9448a9c11ca07ecc414.tar.gz#subdirectory=livekit-plugins/livekit-plugins-vartaloop"
export VARTALOOP_API_KEY="vt_live_…"
Once it is released, pip install livekit-plugins-vartaloop and the page at
docs.livekit.io/agents/models/tts/vartaloop replace this.
from livekit.agents import AgentSession
from livekit.plugins import vartaloop
session = AgentSession(
stt=...,
llm=...,
tts=vartaloop.TTS(voice="saanvi", expression="neutral", digits="auto", profile="telephony"),
)
tts.stream()is whatAgentSessionuses: sentences go over a pooled WebSocket, the server queues them in order, and the next sentence is synthesised while the current one plays.tts.synthesize(text)is one HTTP request whose audio is forwarded as it arrives.tts.update_options(voice="sahil")applies from the next sentence; nothing reconnects.- A
503before any audio is raised as anAPIStatusErrorwith the server'sRetry-After, so the framework's own retry handles it and nothing is billed (Limits). - Requires
livekit-agents >= 1.8.12, Python 3.10 to 3.14.
LiveKit Agents (Node)¶
Until the pull request is released on npm, copy the plugin's two source files, pinned to the reviewed commit, into your project:
npm install @livekit/agents@^1.10.0 @livekit/rtc-node@^1.2.2 ws && npm install -D @types/ws
SRC=https://raw.githubusercontent.com/vartalaap-si/vartaloop-agents-js/efd9a85b6b8b214b84e1839dbc6fc1dae80c646a/plugins/vartaloop/src
mkdir -p src/vartaloop
curl -fsSL $SRC/models.ts -o src/vartaloop/models.ts
curl -fsSL $SRC/tts.ts | sed 's/\${__PACKAGE_VERSION__}/1.10.0/' > src/vartaloop/tts.ts
export VARTALOOP_API_KEY="vt_live_…"
The sed fills in the version the official build would insert (it only appears in the User-Agent). The files import each other
with a .js suffix, so tsconfig.json needs "moduleResolution": "NodeNext" or "Bundler". Once
@livekit/agents-plugin-vartaloop is on npm, install it, import from it instead, and delete the folder.
import * as vartaloop from './vartaloop/tts.js'; // '@livekit/agents-plugin-vartaloop' once released
const tts = new vartaloop.TTS({ voice: 'saanvi', expression: 'neutral', digits: 'auto' });
// later, mid-call:
tts.updateOptions({ voice: 'sahil' });
Same behaviour as the Python plugin: stream() over a pooled WebSocket with per-sentence utterances, synthesize() over HTTP, both
producing 16-bit PCM mono at 24 kHz. chunkTimeout (default 10 000 ms) is how long an utterance in flight may go silent before the
turn is retried on a fresh socket.
Writing your own¶
For a framework not listed here, the shape is in Voice agents → Shape of the loop and the
events in WS /v1/tts/stream. The three plugins above are small and are the reference for how
request_id, first_audio_ms, end and per-utterance error events map onto a framework's frames; copy from whichever is closest.