JoinInDocs
Baton
v2 (beta)
Get a key
Baton v2 Streaming (WebSocket) BetaMarkdown

Stream

One speaker, highest accuracy. VAD, end of turn and barge-in.

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.

FieldTypeDescription
type required"session.start"
api_key requiredstring
mode"transactional_call" | "working_session" | "one_on_one" | "brainstorm" | "formal"

Default "transactional_call".

languageone 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 {"pin": "en"}.

eotobject

Choose an end-of-turn operating point by name, or by the mean latency you can afford (the closest of the cutoff_* points wins; ties go to the faster one). Give at most one. Setting eot overrides mode; omit it to use the mode's default point. patient is chosen by name only. What each point is for.

Operating point Mean latency False cut-offs
cutoff_10pct 317 ms about 10 %
cutoff_5pct 563 ms about 5 %
cutoff_2pct 861 ms about 2 %
patient 1658 ms about 1 %

English figures, /v2/stream and /v2/room; every language's points are at GET /v2/eot/profiles.

action_delay_ms and timeout_ms replace the chosen point's own values; the rest of the point stays as published. timeout_ms may not be below action_delay_ms. Examples: {"profile": "cutoff_5pct"}, {"latency_budget_ms": 600}, {"profile": "patient", "timeout_ms": 8000}.

signalsarray of "vad" | "bargein"

Optional event families to receive besides the turn events, which every session gets: vad (vad.start, vad.end) and bargein (bargein.onset, bargein.class). Default: none. Only what you are sent changes, never how turns are decided. An unknown name closes with 1008, except eot (turn events once had to be asked for), which is accepted and ignored. What each event is for: Events.

keywordsobject

Words that interrupt your agent at once, said over it (bargein.class claim). A list you send REPLACES Baton's default for that list; a list you leave out keeps its default. Entries are one or two words (answer: up to three); case and punctuation are ignored. A bad list or entry closes the session with 1008.

echo"on" | "off"

on: Baton ignores your agent's own voice when the microphone picks it up again (speakerphone, laptop without headphones), using what agent.speech tells it. off: your audio is already free of your agent's voice (headphones, or your own echo cancellation), so speech over your agent is the user's at once: it opens a turn and counts as barge-in. agent.speech still drives barge-in either way. Any other value closes with 1008. Default "on".

idle_timeout_snumber

Close after this many seconds without speech. 0 or less disables it. Default 600.

inference_intervalnumber

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 0.1.

messagesarray of object

Conversation so far, used to judge whether an utterance is complete. Read once, at session.start; nothing updates it later.

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.

FieldTypeDescription
type required"session.started"
schema_version required2

The protocol version, sent once per connection on session.started. Events do not repeat it.

session_id requiredstring
tier requiredstring

The scoring tier: full on /v2/stream. A room's session.started has no tier.

signals requiredarray of "vad" | "bargein"

The optional event families this session receives, as you asked for them (in this order).

eot requiredobject

The policy this session uses. mean_latency_ms and cutoff_rate were measured for the operating point's own delay and timeout, so they are null once you set action_delay_ms or timeout_ms.

echo"on" | "off"

Whether Baton ignores your agent's echo in this session, as session.start set it.

modelsobject

Present when bargein was requested.

{
  "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.

FieldTypeDescription
seq requiredinteger

Event sequence number. Starts at 1 and increases by one per event.

type required"warning"
code required"idle_timeout"
close_in_s requirednumber

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.

FieldTypeDescription
type required"session.end"
{"type": "session.end"}

session.summaryyou receiveTotals for the session. Sent in reply to session.end.

FieldTypeDescription
seq requiredinteger

Event sequence number. Starts at 1 and increases by one per event.

type required"session.summary"
audio_s requirednumber

Seconds of audio received.

turns requiredinteger

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.

FieldTypeDescription
seq requiredinteger

Event sequence number. Starts at 1 and increases by one per event.

type required"vad.start"
t requirednumber

Audio time in seconds since the session's first sample. Not always increasing across events; vad.start and vad.end may be dated earlier than the event before them.

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.

FieldTypeDescription
seq requiredinteger

Event sequence number. Starts at 1 and increases by one per event.

type required"vad.end"
t requirednumber

Audio time in seconds since the session's first sample. Not always increasing across events; vad.start and vad.end may be dated earlier than the event before them.

speaker required"user"
duration requirednumber

Seconds since vad.start.

{
  "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.

FieldTypeDescription
seq requiredinteger

Event sequence number. Starts at 1 and increases by one per event.

type required"turn.end"
t requirednumber

Audio time in seconds since the session's first sample. Not always increasing across events; vad.start and vad.end may be dated earlier than the event before them.

speaker required"user"
p_eot requirednumber

Probability, from 0 to 1, that the user has finished their turn, at the moment the turn ended. With by: timeout it is usually low: Baton was not confident and the silence reached the timeout.

latency_ms requiredinteger

Silence between vad.end and this event.

by required"score" | "timeout"
profile requiredstring
hintobject

Baton heard speech in this turn but no clear words. hint carries its best guess at what was said, with a confidence. It comes on turn.end when ready, otherwise in a turn.hint shortly after. Never logged or stored.

answerobject or null

Which of your expect answers the user gave, with a confidence, so your agent can act on it without interpreting a transcript. Present only on the turn that followed an agent.speech with expect. null when Baton could not tell (a session in a language other than English, or no result within 6 s). Never logged or stored.

{
  "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.

FieldTypeDescription
seq requiredinteger

Event sequence number. Starts at 1 and increases by one per event.

type required"turn.resumed"
t requirednumber

Audio time in seconds since the session's first sample. Not always increasing across events; vad.start and vad.end may be dated earlier than the event before them.

speaker required"user"
after_ms requiredinteger

Milliseconds since the cancelled turn.end.

{
  "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.

FieldTypeDescription
seq requiredinteger

Event sequence number. Starts at 1 and increases by one per event.

type required"turn.answer"
turn_t requirednumber

The t of the turn.end this answer is about.

answer requiredobject or null

Which of your expect answers the user gave, with a confidence, so your agent can act on it without interpreting a transcript. Present only on the turn that followed an agent.speech with expect. null when Baton could not tell (a session in a language other than English, or no result within 6 s). Never logged or stored.

{
  "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.

FieldTypeDescription
seq requiredinteger

Event sequence number. Starts at 1 and increases by one per event.

type required"turn.hint"
turn_t requirednumber

The t of the turn.end this hint is about.

hint requiredobject

Baton heard speech in this turn but no clear words. hint carries its best guess at what was said, with a confidence. It comes on turn.end when ready, otherwise in a turn.hint shortly after. Never logged or stored.

{
  "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 (and duration_s) or words, 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 expect on the question, Baton tells you which answer the user gave, with a confidence, so your agent can act on it at once (answer on turn.end, or turn.answer).
  • Barge-in. start and end tell 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.

FieldTypeDescription
type required"agent.speech"
phase required"start" | "end"
utterance_idstring

Your id for the agent utterance. Echoed on barge-in events (null when you sent none).

textstring

What the agent says. With duration_s, enough for Baton to ignore your agent's voice coming back through the user's speaker.

duration_snumber

How long the utterance plays, in seconds. Accepted on start and on end.

wordsarray of object

Instead of text, the agent's words with play times in seconds from this utterance's start message, if your TTS gives them.

expectarray of string

start only. The answers the agent expects to this question, e.g. ["feel good", "feel bad"]. Baton tells you which one the user gave in their NEXT turn (answer on its turn.end, or a turn.answer); then the list is cleared. A later start with expect replaces it, and one without clears it. Once the agent has finished, a one-word answer from the list opens the user's turn at once, even while the agent's voice is still dying away. Candidates must differ after ignoring case, punctuation and number spelling ("seven" = "7"), and none is reserved. Anything else closes the session with 1008. English only (session language en or auto). Never logged or stored.

{
  "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.

FieldTypeDescription
seq requiredinteger

Event sequence number. Starts at 1 and increases by one per event.

type required"bargein.onset"
t requirednumber

Audio time in seconds since the session's first sample. Not always increasing across events; vad.start and vad.end may be dated earlier than the event before them.

agent_speaking requiredtrue
utterance_idstring 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".

FieldTypeDescription
seq requiredinteger

Event sequence number. Starts at 1 and increases by one per event.

type required"bargein.class"
t requirednumber

Audio time in seconds since the session's first sample. Not always increasing across events; vad.start and vad.end may be dated earlier than the event before them.

class required"claim" | "backchannel"
textstring

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 text: stop for a stop word or floor grab, answer for one of your answers.

confirmed_by"two_speakers"

Rooms, with text: a stop said by someone in the room over your agent's own "stop".

p_claim requirednumber 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 requiredinteger

Milliseconds from the onset to this decision.

utterance_idstring 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"
}
Last updated 21 Oct 2026