Which server message to listen to know when the as...
# support
a
hey there — I'm working with Server Messages and wanted to know if there is a way to listen a particular event message that tells me when the last model output happens. I tried
transcriptType="final"
and
model-output
, and
conversation-update
but none of them seem to be reliable as they're being sent multiple times within the same AI turn. This is an example of
model-output
events:
Copy code
{
    "message": {
        "timestamp": 1764796598671,
        "type": "model-output",
        "output": " It’s a photo of a family hanging a framed picture on a light-colored wall, working together as a team.<flush />",
        ...
    }
}
Copy code
{
    "message": {
        "timestamp": 1764796599003,
        "type": "model-output",
        "output": " What kinds of things do you usually notice when people are decorating their homes?<flush />",
        ...
    }
}
As you can see, none of them indicates which one is the last one before the user starts speaking.
v
To reliably detect when the assistant has finished generating its response, listen for the following
speech-update
event, which signals the assistant is starting to speak:
Copy code
json
{
  "message": {
    "type": "speech-update",
    "status": "started",
    "role": "assistant"
  }
}
When you receive this event, you can treat it as the end of the model's output for that turn. This approach is recommended in the documentation for tracking the assistant's speaking state and is more reliable than using
model-output
alone. Source: [Vapi Server Events Documentation](https://docs.vapi.ai/server-url/events)
a
but can the speech-update happen multiple times on the same turn?
t
You’re right model-output and conversation-update fire multiple times in a single turn, so they’re not reliable end-of-turn markers. The only dependable signal is the final speech-update, which fires once per turn, right before the user can speak. I can help you structure your VAPI event flow so your app cleanly detects that final event. Quick question: are you handling these events client-side or through a server webhook? @adrivelasco
a
@Tremix server webhook.
speech-update
seems to work as I was expecting although it does with a bit of delay as it runs when the assistant ends to speak and not when the LLM output last tokens.
@Tremix the problem with
speech-update
is that it's sent too late for me (when TTS finishes) and I would like to run a process when I know the last LLM output happened.
t
I can help you handle this by detecting the real final LLM token instead of relying on TTS timing. There are reliable ways to mark end-of-turn using buffer tracking + custom server events. Your use case makes sense, and I can walk you through the setup privately. Happy to jump in and help you implement the cleanest approach. @adrivelasco
c
Thanks for the detailed question — here’s the most reliable way to detect when the assistant has finished its LLM output. At the moment, Vapi does not emit a dedicated “final LLM token” event. The events that exist (
model-output
,
conversation-update
,
speech-update
) can fire multiple times within a single turn or occur only after TTS finishes, which is why you're seeing inconsistency. The recommended approach is: - Use
conversation-update
events if you want the completed turn with full message history. - Use
speech-update
if you want to detect when the assistant begins speaking its final response for that turn (the
started
event fires once per turn). - If you need to trigger logic exactly when the last LLM token is generated, the best option today is to implement your own buffer tracking on the server side and treat the last
model-output
event before the next
speech-update
as the true end of the LLM turn. This combination is currently the most reliable way to detect end-of-turn behavior before TTS begins.
2 Views