Skip to main content
A turn is one thing your agent says — usually one LLM reply, often several sentences. You choose its 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

Closing a turn gives you exactly one end, tagged with its context_id. A cancelled turn gives you cancelled instead — never both.
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.
Closing alone leaves the GPU finishing audio nobody will hear. Send cancel, then close.
Sentences are spoken in the order you sent them, tagged with the context_id, and streamed as they are generated.

Latency

Measured against Mumbai, eight turns on one socket: