WSS/v2/stream
One speaker, typically a voice agent's caller. It can use the conversation so far
(messages) to judge whether an utterance is complete. No transcript is returned;
use /v2/room when you need text.
English operating points (the same on /v2/room):
| profile | mean latency | false cut-offs |
|---|---|---|
cutoff_10pct |
317 ms | 9.9 % |
cutoff_5pct |
563 ms | 4.8 % |
cutoff_2pct |
861 ms | 2.0 % |
patient |
1658 ms | 1.0 % |
Session
Open, configure and close the session.
session.startyou sendThe first frame. Authenticates and configures a stream session.
Rejections close the socket with 1008 and a short, fixed reason. Match on
its start:
invalid api key; unknown mode (one of ...); a language error
(N bad language code(s), N language code(s) not supported by this ASR,
unknown language mode (only auto)); an end-of-turn error
(eot must be an object,
eot: give a profile or a latency_budget_ms, not both,
unknown eot profile (N published: GET /v2/eot/profiles),
eot.latency_budget_ms must be a positive number,
eot.action_delay_ms must be an integer from 0 to 5000,
eot.timeout_ms must be an integer from 500 to 15000,
eot.timeout_ms <n> is below eot.action_delay_ms <n> (profile <name>); raise timeout_ms);
a signals error (signals must be a list of names,
unknown signal (one of ...)); or a keywords error
(keywords must be an object of word lists, keywords: unknown list,
keywords.<list> must be a list of at most 200 strings,
keywords.<list>: entry N must be a string of 1 to K words).
1013 stream capacity reached on this instance; retry means retry with backoff.
| Field | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
type required | "session.start" | ||||||||||||||||
api_key required | string | ||||||||||||||||
mode | "transactional_call" | "working_session" | "one_on_one" | "brainstorm" | "formal" | Default | |||||||||||||||
language | one of: Pinned, Allowed set, Automatic | The language the user speaks. Telling Baton improves quality; if they may speak
one of several, an allowed list is still better than nothing.
Default | |||||||||||||||
eot | object | Choose an end-of-turn operating point by name, or by the mean latency you can
afford (the closest of the
English figures,
| |||||||||||||||
signals | array of "vad" | "bargein" | Optional event families to receive besides the turn events, which every
session gets: | |||||||||||||||
keywords | object | Words that interrupt your agent at once, said over it ( | |||||||||||||||
echo | "on" | "off" |
| |||||||||||||||
idle_timeout_s | number | Close after this many seconds without speech. 0 or less disables it. Default | |||||||||||||||
inference_interval | number | Scoring step in seconds. Leave it at 0.1; other values void the published latency and cut-off numbers and the echo and barge-in timings. Default | |||||||||||||||
messages | array of object | Conversation so far, used to judge whether an utterance is complete. Read once, at |
A voice agent that wants barge-in and speech events.
{
"type": "session.start",
"api_key": "baton_0123456789abcdef0123456789abcdef0123456789abcdef",
"eot": {"profile": "cutoff_5pct"},
"language": {"pin": "en"},
"signals": ["vad", "bargein"]
}
Your own stop words, and answer words that interrupt your agent.
{
"type": "session.start",
"api_key": "baton_0123456789abcdef0123456789abcdef0123456789abcdef",
"signals": ["bargein"],
"keywords": {
"stop": ["stop", "wait", "hold on"],
"answer": ["yes", "no", "ready"]
}
}
session.startedyou receiveThe session is open. Start sending audio.
| Field | Type | Description |
|---|---|---|
type required | "session.started" | |
schema_version required | 2 | The protocol version, sent once per connection on |
session_id required | string | |
tier required | string | The scoring tier: |
signals required | array of "vad" | "bargein" | The optional event families this session receives, as you asked for them (in this order). |
eot required | object | The policy this session uses. |
echo | "on" | "off" | Whether Baton ignores your agent's echo in this session, as |
models | object | Present when |
{
"type": "session.started",
"schema_version": 2,
"session_id": "3f7c2a9e5b1d4c8e9a0b6d2f4e8c1a7b",
"tier": "full",
"signals": ["vad", "bargein"],
"eot": {
"profile": "cutoff_5pct",
"rule": "score_point",
"action_delay_ms": 300,
"timeout_ms": 3000,
"overridden": [],
"mean_latency_ms": 563,
"cutoff_rate": 0.0482
},
"models": {"bargein": "v1"}
}
warning (idle_timeout)you receiveNo speech for a while. The session will close soon.
Sent before an idle close (idle_timeout_s, default 600 s). Speech resets the
timer. The close is code 1000 with reason idle_timeout.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "warning" | |
code required | "idle_timeout" | |
close_in_s required | number | Seconds until the idle close. |
{
"type": "warning",
"seq": 40,
"code": "idle_timeout",
"close_in_s": 30.0
}
session.endyou sendEnd the session. Baton replies with session.summary and closes with 1000.
| Field | Type | Description |
|---|---|---|
type required | "session.end" |
{"type": "session.end"}
session.summaryyou receiveTotals for the session. Sent in reply to session.end.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "session.summary" | |
audio_s required | number | Seconds of audio received. |
turns required | integer | Turn ends |
{
"type": "session.summary",
"seq": 41,
"audio_s": 312.4,
"turns": 18
}
Audio
16 kHz mono PCM16 in binary frames.
audioyou sendOne binary frame of audio.
A binary WebSocket frame: one leading byte (send 0; it identifies the source
and is reserved for multi-source sessions), then signed 16-bit little-endian PCM,
mono, 16 000 Hz. Any whole number of samples per frame; 80–100 ms (1280–1600
samples) is typical. Resample on the client: other rates are not accepted. A frame
whose PCM part is an odd number of bytes (e.g. no source byte) closes the session
with 1008 audio frame must be a source byte and 16-bit PCM.
Binary frame. [u8 source = 0][PCM16LE mono 16 kHz samples...]
Speech and turns
When people speak, pause and finish, what they answered, and what may have been missed.
vad.startyou receiveThe user started speaking. With vad in signals.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "vad.start" | |
t required | number | Audio time in seconds since the session's first sample. Not always increasing across events; |
speaker required | "user" |
{"type": "vad.start", "seq": 1, "t": 0.1, "speaker": "user"}
vad.endyou receiveThe user stopped making speech sound. Not yet a turn end. With vad in signals.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "vad.end" | |
t required | number | Audio time in seconds since the session's first sample. Not always increasing across events; |
speaker required | "user" | |
duration required | number | Seconds since |
{
"type": "vad.end",
"seq": 2,
"t": 2.3,
"speaker": "user",
"duration": 2.2
}
turn.endyou receiveThe user has finished their turn. Your agent may respond.
Fired after the speaker goes quiet, either because Baton is confident the turn is
complete (by: score) or because the silence has gone on long enough
(by: timeout). latency_ms is the silence between vad.end and this event. On
the cutoff_* points a by: score turn end always comes at the point's
action_delay_ms (300 ms for cutoff_5pct), and a by: timeout one at
timeout_ms.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "turn.end" | |
t required | number | Audio time in seconds since the session's first sample. Not always increasing across events; |
speaker required | "user" | |
p_eot required | number | Probability, from 0 to 1, that the user has finished their turn, at the moment the turn ended. With |
latency_ms required | integer | Silence between |
by required | "score" | "timeout" | |
profile required | string | |
hint | object | Baton heard speech in this turn but no clear words. |
answer | object or null | Which of your |
{
"type": "turn.end",
"seq": 3,
"t": 2.6,
"speaker": "user",
"p_eot": 0.81,
"latency_ms": 300,
"by": "score",
"profile": "cutoff_5pct"
}
{
"type": "turn.end",
"seq": 6,
"t": 9.6,
"speaker": "user",
"p_eot": 0.12,
"latency_ms": 6000,
"by": "timeout",
"profile": "patient",
"hint": {
"suspect": "speech_without_words",
"text": "Yes.",
"certainty": "low"
}
}
turn.resumedyou receiveThe user started speaking again within 2 s of turn.end. Treat that turn end as cancelled.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "turn.resumed" | |
t required | number | Audio time in seconds since the session's first sample. Not always increasing across events; |
speaker required | "user" | |
after_ms required | integer | Milliseconds since the cancelled |
{
"type": "turn.resumed",
"seq": 5,
"t": 3.9,
"speaker": "user",
"after_ms": 900
}
turn.answeryou receiveWhich of your expected answers the user gave in the turn that just ended.
The result for a turn that followed an agent.speech with expect. It comes on
the turn.end itself when ready; otherwise in this event, typically 2–3 s after
the turn.end (occasionally about 4 s, never more than 6 s). turn_t is that
turn.end's t: match on it. At most one per turn end. A turn.resumed cancels
it with its turn end, and the answer comes again with the next turn.end. An
answer still pending at session.end is not sent: wait for it before ending the
session.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "turn.answer" | |
turn_t required | number | The |
answer required | object or null | Which of your |
{
"type": "turn.answer",
"seq": 5,
"turn_t": 3.0,
"answer": {
"match": "feel good",
"score": 0.91,
"runner_up": "feel bad",
"scores": {"feel good": 0.91, "feel bad": 0.06, "none": 0.03}
}
}
turn.hintyou receiveBaton's best guess at words it heard in the turn that just ended.
Baton heard speech in a turn but no clear words. The hint is its best guess at
what was said. It comes on the turn.end itself when ready; otherwise in this
event, typically 2–3 s after the turn.end (occasionally about 4 s, never more
than 6 s). turn_t is that turn.end's t: match on it. At most one per turn
end, and none when every word was heard. A turn.resumed cancels it with its
turn end. A hint still pending at session.end is not sent. Never logged or
stored.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "turn.hint" | |
turn_t required | number | The |
hint required | object | Baton heard speech in this turn but no clear words. |
{
"type": "turn.hint",
"seq": 4,
"turn_t": 3.0,
"hint": {
"suspect": "speech_without_words",
"text": "Yes.",
"certainty": "low"
}
}
Barge-in
Speech over your agent: a real interruption, or a backchannel.
agent.speechyou sendTell Baton what your agent is saying, and when.
Telling Baton what your agent says makes its predictions better exactly where they are hardest: quiet users, noisy rooms, speakerphones, and short one-word answers.
- Your agent's own voice is ignored. When the user hears your agent through
a speaker, the microphone picks it up again. With
text(andduration_s) orwords, Baton knows that sound is your agent: it opens no turn and never stops your agent, while the user's own words still do. - Answers you expect are recognised. With
expecton the question, Baton tells you which answer the user gave, with a confidence, so your agent can act on it at once (answeronturn.end, orturn.answer). - Barge-in.
startandendtell Baton when your agent is talking, so speech over it is reported (bargein.onset,bargein.class).
Send start before your agent's audio can reach the user's microphone, and end
when it stops. Every field but phase is optional. A malformed field closes the
session with 1008 (see Errors and limits). A phase other than start or end
is ignored.
| Field | Type | Description |
|---|---|---|
type required | "agent.speech" | |
phase required | "start" | "end" | |
utterance_id | string | Your id for the agent utterance. Echoed on barge-in events (null when you sent none). |
text | string | What the agent says. With |
duration_s | number | How long the utterance plays, in seconds. Accepted on |
words | array of object | Instead of |
expect | array of string |
|
{
"type": "agent.speech",
"phase": "start",
"utterance_id": "sp_1"
}
{
"type": "agent.speech",
"phase": "end",
"utterance_id": "sp_1"
}
bargein.onsetyou receiveThe user started speaking while your agent was talking.
Sent when the speech starts. bargein.class follows with the decision. Your
agent's own voice coming back through the user's speaker never opens one.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "bargein.onset" | |
t required | number | Audio time in seconds since the session's first sample. Not always increasing across events; |
agent_speaking required | true | |
utterance_id | string or null |
{
"type": "bargein.onset",
"seq": 7,
"t": 12.1,
"agent_speaking": true,
"utterance_id": "sp_1"
}
bargein.classyou receiveWhether the interruption claims the floor or is a backchannel.
claim means the user wants to talk: stop or yield. backchannel ("mm-hmm",
"right") means keep talking. Decided as soon as Baton is confident, typically a few
hundred milliseconds into the interruption. p_claim is the probability, from 0
to 1, that the user is taking the floor; it is null when the user stopped too
soon to judge (reported as a backchannel) and on a claim decided by a word.
A stop word ("stop", "wait", "hold on"), a floor grab ("no", "actually") or one
of your answer words decides a claim at once. Such a claim carries text (the
word or phrase, as in your list) and intent (stop or answer). It can follow
a backchannel for the same interruption, and it comes with its own
bargein.onset when none was open. One per agent utterance. Your agent's own
voice saying "stop" never triggers it.
Rooms only: confirmed_by: two_speakers marks a stop said by someone in the room
over your agent's own "stop".
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "bargein.class" | |
t required | number | Audio time in seconds since the session's first sample. Not always increasing across events; |
class required | "claim" | "backchannel" | |
text | string | On a claim decided by a word: the stop word, floor grab or answer heard, as in your list (or Baton's). Absent otherwise. |
intent | "stop" | "answer" | With |
confirmed_by | "two_speakers" | Rooms, with |
p_claim required | number or null | Probability, from 0 to 1, that the user is taking the floor (1 = certainly a claim, 0 = certainly a backchannel). Null when the user stopped too soon to judge, and on a claim decided by a word, which needs no probability. |
decided_after_ms required | integer | Milliseconds from the onset to this decision. |
utterance_id | string or null |
{
"type": "bargein.class",
"seq": 8,
"t": 12.4,
"class": "claim",
"p_claim": 0.9,
"decided_after_ms": 300,
"utterance_id": "sp_1"
}
{
"type": "bargein.class",
"seq": 9,
"t": 15.2,
"class": "claim",
"text": "stop",
"intent": "stop",
"p_claim": null,
"decided_after_ms": 100,
"utterance_id": "sp_2"
}