adorable-petabyte-73906
12/27/2025, 5:21 AMtall-airline-16756
12/27/2025, 5:21 AMtall-airline-16756
12/27/2025, 5:22 AMadorable-petabyte-73906
12/27/2025, 7:50 AMtall-airline-16756
12/27/2025, 7:51 AMsession = AgentSession(
stt=deepgram.STT(),
llm=openai.LLM(),
tts=elevenlabs.TTS(model="eleven_multilingual_v2"),
vad=ctx.proc.userdata["vad"],
preemptive_generation=True,
)
Node.js/TypeScript example
const session = new voice.AgentSession({
stt: new assemblyai.STT(),
llm: new openai.LLM(),
tts: new cartesia.TTS(),
vad: proc.userData.vad,
voiceOptions: {
preemptiveGeneration: true,
},
});
How it works (brief)
• On interim transcripts, the agent triggers LLM inference early.
• A draft response is stored; if final transcript matches, reuse it; otherwise regenerate.
• Streaming still applies for subsequent tokens.
Trade-offs & tips
• Extra cost/compute if drafts are discarded when user continues speaking.
• Prewarm VAD and LLM clients at startup to avoid load/cold-start delays.
• Monitor Time-To-First-Token to measure improvements.
• Ensure your STT returns interim transcripts quickly and turn detection is tuned.
If you want, tell me:
• which language (Python/Node) and LLM/STT providers you use, and
• whether you already prewarm clients—
and I’ll give exact code changes and tuning suggestions.
Sources: Pipeline Translator Agent | LiveKit docs | examples/voice_agents | livekit/livekit_composite | DeepWiki | Agent speech and audio | LiveKit docs