context_id.
1
Open the socket and start
One connection carries the whole conversation. Send
start first, then read
metadata.2
Push sentences as they are written
Same
context_id, continue: true until the last one. Do not wait
between sentences — fire them as fast as your LLM produces them.3
Cancel the moment the user speaks
Barge-in drops the whole turn — queued and in-flight — and replies
cancelled instead of end.The rules that matter
One end per turn, always
One end per turn, always
Closing a turn gives you exactly one
end, tagged with its context_id.
A cancelled turn gives you cancelled instead — never both.context_id cannot be reused
context_id cannot be reused
Once a turn has ended, that id is spent. Reusing it is an error rather than
a second turn, because two terminators for one id desynchronises everything
after it.
Cancel before you close the socket
Cancel before you close the socket
Closing alone leaves the GPU finishing audio nobody will hear. Send
cancel, then close.Audio arrives in order
Audio arrives in order
Sentences are spoken in the order you sent them, tagged with the
context_id, and streamed as they are generated.