Overview
This guide covers integrating AssemblyAI’s AssemblyAI-STT-3.7-Realtime-Agent speech-to-text model into a LiveKit voice agent using the Agents framework. LiveKit Agents is an open-source framework for building real-time voice, video, and multimodal AI agents. Your agent joins a LiveKit room as a participant and exchanges audio with users over WebRTC or SIP telephony. AnAgentSession wires together speech-to-text, LLM, and text-to-speech plugins and handles the orchestration, including turn detection and interruptions.
AssemblyAI-STT-3.7-Realtime-Agent is our most accurate streaming model for voice agents — multilingual and promptable, with conversation context and voice focus.It’s the AssemblyAI plugin’s default model as of
livekit-agents 1.9.0. On 1.8.12 or 1.8.13, set model="assemblyai-stt-3-7-realtime-agent" explicitly, since those versions default to universal-3-6-pro.Turn detection
Decide when the user is done speaking — modes, defaults, and entity tuning.
Latency
Shorten the gap between the user finishing and the agent replying.
Accuracy
Prompting, key terms, conversation context, and noise handling.
Interruptions
Natural barge-in without false triggers from backchannels.
Quickstart
Get a working, talking agent in a few minutes, then optimize from there.1
Install the SDK
Install the plugin and supporting packages (silero, codecs, dotenv) from PyPI:LiveKit’s turn detector is built into
livekit-agents, so external turn detection needs no extra package.2
Set your API keys
Set your API keys in a
.env file:3
Build a minimal agent
The following example uses For a complete voice agent, you will also need to install LLM and TTS plugins for your chosen providers. See the LiveKit plugins documentation for available options.
turn_detection="stt" (recommended). The comments show how to switch to external turn detection with LiveKit’s turn detector.4
Run and test
Start your agent in development mode:Then test it in the LiveKit Playground:
- Go to agents-playground.livekit.io
- Connect to your LiveKit Cloud project (same credentials as your
.env) - Click Connect: a room will be created, your agent will join, and you can start talking
Parameters reference
AssemblyAI-STT-3.7-Realtime-Agent parameters
These are the key parameters to tune for LiveKit when using AssemblyAI-STT-3.7-Realtime-Agent:The streaming model.
"assemblyai-stt-3-7-realtime-agent" is our
recommended model for voice agents and the plugin’s default as of
livekit-agents 1.9.0. On 1.8.12 or 1.8.13, the plugin defaults to
"universal-3-6-pro", so pass model explicitly there.Accuracy/latency preset:
"min_latency", "balanced", or "max_accuracy". Sets
the defaults for min_turn_silence and max_turn_silence; any value you set
explicitly still takes precedence. The server default is "balanced". When
mode is set, the plugin leaves min_turn_silence and max_turn_silence
unset so the preset’s values apply. Connect-time only — cannot be changed
with update_options. See Optimizing accuracy and latency.Set "manual" to let LiveKit’s turn detector, VAD, or your own logic end
each turn instead of AssemblyAI. Requires livekit-agents 1.9.0+. See
External turn detection.List of terms to boost recognition for. Applied automatically alongside any
contextual prompt.
Contextual prompt — a natural-language description of what the audio is
about (domain, scenario, or full details). Transcription behavior is built
in and optimized automatically.
Your agent’s most recent spoken reply, up to 1750 characters, used as context
for transcribing the next user turn. The 1750-character cap is enforced
client-side — explicit values over the cap raise
ValueError (both at
construction and via update_options); only automatic forwarding truncates
silently. Can be set at construction time and updated mid-stream with
update_options. See Conversation context.Steer transcription toward one or more expected languages instead of
auto-detecting across all supported languages. Accepts a single code
(
"es") or a list (["en", "es"]); entries are normalized to ISO 639-1
("en-US", "english" → "en"). Up to 10 codes. Leave unset for the
default multilingual behavior. Can be updated mid-session via
update_options; pass an empty list to clear steering.How many prior conversation entries are carried forward automatically. Range
0–100; 0 disables carryover. Leave unset for the server default (5).
Connect-time only — cannot be changed with update_options.Milliseconds of silence before AssemblyAI checks for end-of-turn. The plugin
sends
100 when mode is unset; set mode to use the
preset’s value instead. With mode="manual", it no longer ends turns, so
leave it unset.Maximum milliseconds of silence before the turn is forced to end.
When
mode is unset, the LiveKit plugin defaults to 100
(matching min_turn_silence). When using turn_detection="stt", set
mode="balanced" (which applies 1280) or set max_turn_silence=1280
explicitly. With mode="manual", it defaults to 10000 and only ends a turn
if LiveKit never does.AssemblyAI’s internal VAD onset threshold. Defaults to
0.2 in every mode.
Set LiveKit’s Silero activation_threshold to the same value for consistent
behavior.Server-side noise suppression that isolates the primary speaker.
"near-field"
for close-talking mics, "far-field" for distant capture. Connect-time only.
See Voice focus.How aggressively
voice_focus suppresses background audio. 0.0–1.0; higher
is more aggressive. Connect-time only.How soon the first partial transcript is emitted during a turn, in
milliseconds. Range:
0–1000. Lower values produce faster time to first
token (TTFT) for barge-in and speculative inference; higher values produce
more confident first partials. Defaults to 0 in every mode. The server adds a fixed 256 ms on top of the
configured value (interruption_delay: 0 → ~256 ms effective,
interruption_delay: 500 → ~756 ms effective). See
Tuning early partial timing
for details.AssemblyAI-STT-3.7-Realtime-Agent code-switches natively between
supported languages. This parameter controls whether
language_code and
language_confidence are included in turn messages. Defaults to true in the
LiveKit plugin, but false when using the API directly.General STT parameters
These parameters apply to all AssemblyAI streaming models and can remain the same between models:Legacy parameters
These parameters apply to theuniversal-streaming-english and universal-streaming-multilingual AssemblyAI streaming models, but do not affect AssemblyAI-STT-3.7-Realtime-Agent:
Confidence threshold for end-of-turn detection. AssemblyAI-STT-3.7-Realtime-Agent uses
min_turn_silence and max_turn_silence instead.Whether to return formatted final transcripts. AssemblyAI-STT-3.7-Realtime-Agent always returns formatted transcripts, so this parameter no longer applies.
Turn detection
In LiveKit, how your agent detects the end of a user’s turn is controlled by theturn_detection parameter inside TurnHandlingOptions, which is passed to AgentSession via the turn_handling argument.
AssemblyAI-STT-3.7-Realtime-Agent supports two ways of deciding when the user is done:
Built-in turn detection
Withturn_detection="stt", AssemblyAI’s built-in turn detection determines when the user has finished speaking. AssemblyAI’s end_of_turn signals are then used directly by LiveKit to commit the turn.
When the user pauses, AssemblyAI-STT-3.7-Realtime-Agent checks for end-of-turn. The min_turn_silence and max_turn_silence parameters you pass to AssemblyAI control when that check runs and how long a turn can stay open. For more details, see How turn detection works.
In this mode, we recommend explicitly setting mode="balanced" or min_turn_silence=128 and max_turn_silence=1280.
When mode is unset, the LiveKit plugin defaults to min_turn_silence=100 and max_turn_silence=100, which might be too aggressive for built-in turn detection. See Default parameter differences.
Recommended starting parameters (set on assemblyai.STT(), not on AgentSession):
How it works:
- User speaks → audio streams to AssemblyAI
- User pauses for
128ms(ormin_turn_silence) → AssemblyAI checks for end-of-turn - If the user is done → turn ends immediately
- If not → partial emitted, turn stays open
- If silence reaches
1280ms(ormax_turn_silence) → turn is forced to end
Default parameter differences
AssemblyAI-STT-3.7-Realtime-Agent’s endpointing is controlled by two AssemblyAI API parameters,min_turn_silence and max_turn_silence, that you pass to the STT plugin. These are separate from LiveKit’s endpointing.min_delay and endpointing.max_delay (set inside TurnHandlingOptions).
With
mode unset, the plugin finalizes transcripts after 100ms of silence.
- With a third-party turn detector: for best performance, use external turn detection with
mode="manual". - With built-in turn detection: for best performance, set
mode(for example,mode="balanced"), or setmin_turn_silenceandmax_turn_silenceyourself.
Tuning endpointing parametersThese are the default values used when no parameters are explicitly provided. You will likely need to experiment with different values depending on your use case:
- Increase
min_turn_silence: when brief pauses end turns before the user has finished speaking. - Increase
max_turn_silence: when the forced turn end is cutting off users mid-thought or splitting entities like phone numbers across turns, a higher value lets the model wait longer before forcing the turn to end when the model is unsure.
Entity splitting tradeoff
Lowermin_turn_silence and max_turn_silence values produce faster transcripts but can split entities or utterances across turns. The two parameters affect this differently.
When the user pauses partway through an entity, like a phone number or email address, AssemblyAI holds the turn open until silence reaches max_turn_silence (entity-aware endpointing). That makes max_turn_silence the main setting for keeping entities in one turn.
min_turn_silence too low
- AssemblyAI checks for end-of-turn on very brief pauses, so a turn can end before the user has finished speaking.
max_turn_silence too low
- Forced turn-end cuts off user mid-thought or mid-entity.
-
Example: User spells out an email address with pauses between parts. With the plugin’s
100ms default, each pause forces the turn to end.
- Example: User pauses longer than 1 second to think mid-sentence. The forced end fires at 1000ms, splitting the utterance into two turns.
LLMs downstream can usually piece together split entities, but if your use
case involves alphanumeric dictation or entity extraction, consider increasing
min_turn_silence and max_turn_silence during those portions of the
conversation. You can update configuration
mid-stream to raise max_turn_silence
temporarily (e.g., to 2000–4000 ms) when expecting entity input, then
lower it again afterward.External turn detection
To have LiveKit’s turn detector, VAD, or your own logic decide when each turn ends, setmode="manual" on assemblyai.STT. This turns off AssemblyAI’s own turn detection.
When LiveKit ends the user’s turn, the plugin sends any buffered audio and then a ForceEndpoint, and AssemblyAI returns that turn’s final transcript right away. Every ForceEndpoint gets exactly one final (with an empty transcript if nothing was said), so LiveKit never waits on a final that isn’t coming.
LiveKit turn detector (v1 and v1-mini)
LiveKit’s turn detector is a multimodal model that predicts the end of a turn from the user’s audio and the agent’s last message. It comes in two versions: v1, served on LiveKit Inference, and v1-mini, which runs locally on CPU. It’s the default turn detection in AgentSession, and LiveKit picks the version for your environment.
Using LiveKit Inference? Construct Pass your VAD to
inference.STT with external_endpointing=True and pass mode in extra_kwargs. Without external_endpointing, LiveKit’s flushes don’t end AssemblyAI’s turn. A model string passed to stt can’t set it. Requires livekit-agents 1.9.0+.AgentSession only. A vad on inference.STT ends each turn at VAD end of speech, ignoring LiveKit’s turn detector.- User speaks → AssemblyAI sends partials while they speak and on every pause
- VAD detects the end of speech → LiveKit’s turn detector predicts whether the user is done
- If the user is likely done → LiveKit flushes the stream, the plugin sends
ForceEndpoint, and AssemblyAI returns the final right away. LiveKit commits the turn onceendpointing.min_delayhas passed since the user stopped speaking. - If the user is likely to continue → LiveKit waits up to
endpointing.max_delayfor more speech. Halfway through, it flushes anyway so a final is ready. If the user keeps talking, the next final is added to the same user turn.
min_delay=0.3, max_delay=2.5). Because of the flush halfway through max_delay, a pause longer than about 1.25s ends AssemblyAI’s turn even when the user isn’t done. For steps where users pause longer, like reading out a card number, raise endpointing.max_delay on the agent that handles that step.
Parameter behavior:
min_turn_silence: no longer ends turns, so leave it unset.max_turn_silence: only ends a turn if LiveKit never does. Defaults to10000(ms) in manual mode.
Other turn detection models
Manual mode works with any model that ends LiveKit’s turn, whether it works from audio or text:- Your own model: set
turn_detection="manual"and callsession.commit_user_turn()when your model decides the user is done. Each commit ends the AssemblyAI turn and returns its final. In LiveKit’s manual turn control, interruptions are also yours to handle, withsession.interrupt(). - LiveKit’s text turn detector (
MultilingualModel()): works, though LiveKit has deprecated it in favor of the multimodal turn detector above. It predicts from final transcripts, so LiveKit flushes at every VAD end of speech before predicting, and AssemblyAI’s turns end at each pause.
Other setups
VAD configuration
Withturn_detection="stt", AssemblyAI also sends SpeechStarted events that LiveKit uses for barge-in/interruption handling. SpeechStarted is only emitted when the model produces a transcript.
Silero VAD is not strictly required in this mode, but it is still recommended as Silero runs locally and it can be faster than waiting for AssemblyAI’s SpeechStarted signal. LiveKit respects whichever signal arrives first, so Silero provides faster interruption while AssemblyAI’s signal serves as a reliable backup.
With external turn detection, VAD is required: LiveKit runs the turn detector when VAD detects the end of speech, and uses VAD for interruptions. AgentSession provides a VAD automatically if you don’t pass one, but passing Silero lets you align its threshold with AssemblyAI’s.
Threshold alignment
LiveKit’s Silero VAD defaults to anactivation_threshold of 0.5. AssemblyAI’s vad_threshold defaults to 0.2. For best performance, set Silero’s activation_threshold to 0.2 to match.
Both should be adjusted together to the same value to ensure accurate transcription and consistent barge-in thresholds.
When the thresholds are mismatched, you get a dead zone: if Silero is at 0.5 and AssemblyAI is at 0.2, AssemblyAI will be actively transcribing speech that LiveKit hasn’t detected yet, delaying interruption. Keeping them aligned eliminates this.
stt.vad_threshold and vad.activation_threshold thresholds together.
Latency
A voice agent feels responsive when the gap between the user finishing and the agent replying is short. Start with themode preset — the highest-level dial for the accuracy/latency trade-off. It sets sensible defaults for the fine-grained levers below, so you can pick a target and tune from there:
mode is set at construction time (it can’t be changed mid-session) and sets the defaults of min_turn_silence and max_turn_silence. Any value you set explicitly still wins. The server default is balanced. See Optimizing accuracy and latency.
From there, fine-tune the individual levers:
- Endpointing delay (STT mode). LiveKit’s
endpointing.min_delayis applied on top of AssemblyAI’s own end-of-turn timing and adds up to500msby default. Setendpointing={"min_delay": 0}when usingturn_detection="stt"— see Built-in turn detection. - End-of-turn timing.
min_turn_silence(end-of-turn check) andmax_turn_silence(forced end) directly control how soon a turn ends. Lower is faster but risks splitting entities — see Turn detection. - Time to first partial.
interruption_delaycontrols how soon the first partial is emitted, which drives faster barge-in and speculative inference. The server adds a fixed256mson top of the configured value.
- Sample rate. Use 16 kHz (
sample_rate=16000). Higher rates don’t improve accuracy and only add bandwidth. - Skip client-side preprocessing. Don’t run your own noise cancellation before audio reaches the model — the artifacts it introduces usually hurt accuracy more than the original noise. Use server-side Voice Focus instead.
Latency breakdown
Accuracy
AssemblyAI-STT-3.7-Realtime-Agent is accurate out of the box. When you need more — domain vocabulary, proper nouns, noisy audio — reach for these levers. For entity-heavy dictation, also tune turn detection (see Entity splitting tradeoff), and note that the high-levelmode preset shifts the overall accuracy/latency balance (use max_accuracy to favor quality).
Prompting
AssemblyAI-STT-3.7-Realtime-Agent supports aprompt parameter for contextual prompting — a description of what the audio is about. Transcription behavior (verbatim output, punctuation, turn detection) is built in and optimized automatically; the prompt carries context, not instructions.
- Start with no prompt: AssemblyAI-STT-3.7-Realtime-Agent delivers strong accuracy out of the box — only add context if domain-specific vocabulary is being misrecognized.
- Describe the conversation: domain, scenario, or full details — start broad, and add only details your application actually knows (see the three context levels).
- Include known names and identifiers: caller name, account or order IDs, products — detailed context helps the model spell them correctly.
Key terms
Instead ofprompt, use keyterms_prompt to boost recognition of specific names, brands, or domain terms:
Language selection
By default, AssemblyAI-STT-3.7-Realtime-Agent auto-detects and code-switches across all supported languages. If you know which languages a caller will speak,language_codes steers transcription toward them for better accuracy on short or ambiguous turns. It can also be updated mid-session (e.g. when a caller switches languages) via update_options. Requires livekit-agents 1.6.6+.
Conversation context
Give the model both sides of the dialog so it transcribes the next user turn more accurately. AssemblyAI-STT-3.7-Realtime-Agent keeps a short, per-session memory of the conversation from two sources:- The agent half — what your agent just said, forwarded automatically into
agent_contextbyAgentSessiononlivekit-agents1.6.6+ (no wiring needed). - The user half — prior STT-finalized user turns, carried forward automatically (no configuration needed).
"What's your email address?", agent_context lets the model produce "user@assemblyai.com" instead of "user at assemblyai dot com". This has the biggest impact on short replies ("yes", "7pm", single names) and spelled-out entities. See Conversation context for the full reference.
agent_context and previous_context_n_turns aren’t supported on the legacy Universal-Streaming models. previous_context_n_turns is set at construction time and cannot be changed with update_options().Automatic on 1.6.6+
Onlivekit-agents 1.6.6+, AgentSession forwards each assistant reply into agent_context automatically — no wiring needed. Replies longer than the 1750-character limit are truncated automatically, keeping the tail (the end of the reply — usually the question — has the most biasing value).
To opt out, use the session-level toggle:
While automatic forwarding is on, any
agent_context you set manually is
replaced by the next assistant reply. To manage agent_context yourself
(e.g. custom trimming or filtering), set forward_chat_context: False and
push it via update_options(agent_context=...) after each reply.Manual control / pre-1.6.6
Manual control / pre-1.6.6
If you’re on a version of
livekit-agents that predates 1.6.6, or you want to manage agent_context yourself, wire it via the conversation_item_added event. LiveKit emits it for every conversation item; filter for the assistant’s messages and forward the (trimmed) text to the STT plugin via update_options(agent_context=...). No reconnect is required.A complete runnable example is on GitHub: including-agent-context.LiveKit Inference
LiveKit Inference also serves AssemblyAI-STT-3.7-Realtime-Agent: passstt="assemblyai/assemblyai-stt-3-7-realtime-agent" to AgentSession instead of the plugin, and use your LiveKit Cloud credentials rather than an AssemblyAI API key. As of livekit-agents 1.8.13, the SDK forwards the agent’s replies into agent_context automatically for the 3.7 model. language_codes is plugin-only for now. For external turn detection on Inference, see External turn detection.
Voice focus
Voice Focus isolates the primary speaker and suppresses background noise — chatter, keyboard clicks, fan hum, room echo — server-side, before audio reaches the model. Use it instead of client-side noise cancellation, which tends to introduce artifacts that hurt accuracy more than the noise itself.
Both are connection-time parameters and cannot be changed with
update_options(). See Voice Focus for details.
Interruption handling
In voice agent conversations, users often produce backchannel utterances (“mhm”, “yeah”, “um”, “okay”) while the agent is speaking. These short fillers can trigger LiveKit’s interruption logic, causing the agent to stop mid-sentence even though the user didn’t intend to interrupt. LiveKit Cloud users should reach for adaptive interruption handling first. Self-hosted deployments can combine the two custom filters described below.Recommended: Adaptive interruption handling
LiveKit Agents v1.5.0 introduced adaptive interruption handling, a server-side model that classifies overlapping speech as a real interrupt or a backchannel. On a false interrupt the agent’s TTS resumes from where it left off. No re-generation is needed. The feature is recommended for LiveKit Cloud users and is included on all Cloud plans.Self-hosted alternative
If you’re self-hosting LiveKit, can’t use adaptive interruption handling, or need explicit control over which utterances count as filler, the two complementary filters below provide strong guardrails for interruption and barge-in handling. They have non-overlapping failure modes: the backchannel filter stops known fillers before they enter the pipeline, while the buffer-clearing filter catches any short utterance (including unknown fillers or stutters) that slips past. Running both provides the strongest coverage. A working reference implementation is available on GitHub.Upstream backchannel filter
Upstream backchannel filter
The backchannel filter intercepts STT events at the How it works:
stt_node level, before they reach LiveKit’s audio_recognition. It checks each transcript event for known disfluencies and backchannels (“um”, “mhm”, “yeah”, “okay”, etc.) and drops the event entirely. Because the event never enters the pipeline, none of the downstream orchestration (interrupt gates, end-of-turn detection, and preemptive LLM generation) ever reacts to it.The filter is implemented as a mixin class that wraps Agent.stt_node:- While the agent is speaking (plus a 1-second grace window after speech ends), the filter inspects each STT transcript event
- It strips punctuation and checks whether every token in the transcript matches the
BACKCHANNELSset - Pure-filler transcripts like “mhm” or “yeah okay” are dropped. They never reach LiveKit’s pipeline
- Utterances with any non-filler token (e.g., “yeah I want the suite”) always pass through
The
BACKCHANNELS set is domain-customizable. “yes” and “no” are deliberately excluded because they often represent genuine confirmations in booking or IVR scenarios. Edit the set for your use case.Short-utterance buffer clearing
Short-utterance buffer clearing
LiveKit accumulates committed
FINAL transcripts in a private buffer (_audio_transcript) across the user’s uncommitted turn. The _interrupt_by_audio_activity method checks the running word count against min_words to decide whether to pause TTS.Without intervention, two consecutive short fillers like “yeah” + “um” sum to two words and trip the interrupt gate, even though each utterance on its own is below threshold.This filter listens on the user_input_transcribed event and wipes the buffer whenever the agent is speaking and the user input falls below the configured min_words threshold. Each short utterance is evaluated independently rather than against the accumulated total.Wiring both filters into your agent
Wiring both filters into your agent
Three changes are needed:1. Mix in the backchannel filter on your agent class. Place it before 2. Configure the session with 3. Install the buffer-clearing filter on the session, then start it with your agent:Expected behavior with both filters active and
Agent in the class bases so its stt_node runs first:interruption.min_words >= 2. This enables the word-count gate that the buffer-clearing filter depends on:min_words=2:Dynamic configuration
You can updateprompt, keyterms_prompt, agent_context, language_codes, min_turn_silence, max_turn_silence, and interruption_delay during an active session using update_options — no reconnect required. This lets you adapt to the conversation stage: boost names while collecting caller details, widen silence windows while a user dictates an email, then tighten them again.
For more information, see Updating configuration mid-stream.
Troubleshooting
Migrating from another STT provider
To balance accuracy, latency, turn-taking, and interruption handling, map your current setup to AssemblyAI using the questions below. Each answer points to the settings that reproduce — and usually improve on — your current behavior.How are you detecting end-of-turn today?
Which model and settings are you migrating from?
VAD, interruptions, and infrastructure
Parameter cheat sheet
If you’re coming from AssemblyAI’s standard streaming model:
Migrating a production deployment? Talk to our team.