End-of-turn detection
POST /v1/audio/eot and WSS /v1/audio/eot/stream score whether a
speaker has finished their conversational turn · the signal a voice
agent needs to decide "reply now" instead of waiting on a fixed
silence timeout (which is either too slow after a short utterance or
cuts people off mid-thought when they pause to think).
The canonical contract (every field, every frame, every error code)
lives at api.tryhakim.ai/docs
(interactive Scalar reference) and
api.tryhakim.ai/openapi.json
(machine-readable). When this guide and the OpenAPI disagree, the
OpenAPI wins.
Quick start (batch)
Send a short trailing clip of audio · the model's native window is 8 seconds, and clips longer than 15 seconds are rejected. If you have a longer recording, trim to the relevant trailing window before calling.
curl https://api.tryhakim.ai/v1/audio/eot \
-H "Authorization: Bearer $HAKIM_API_KEY" \
-F "file=@./trailing-clip.wav" \
-F "threshold=0.5"
{
"model": "hakim-eot-v1",
"probability": 0.87,
"complete": true,
"threshold": 0.5,
"audio_ms": 2400,
"usage": {
"request_id": "req_…",
"kind": "eot_batch",
"units": 3,
"unit_type": "seconds",
"credits": 1,
"cost_usd": "0.00",
"model": "hakim-eot-v1",
"billing_period_start": "2026-07-01T00:00:00Z",
"billing_period_end": "2026-08-01T00:00:00Z"
}
}
complete is computed server-side as probability >= threshold · it
isn't a fixed cutoff baked into the model. Tune threshold per
request rather than post-processing probability yourself; see
Tuning threshold below.
Tuning threshold
threshold defaults to 0.5. The right value depends on which
mistake costs you more:
- Lower it (e.g.
0.35) to reply sooner · the agent interjects more readily, at the cost of occasionally cutting off a speaker who paused mid-thought. - Raise it (e.g.
0.65) to wait longer for confirmation · fewer interruptions, at the cost of a slower-feeling agent on short, unambiguous utterances.
Most voice-agent integrations land between 0.4 and 0.6 and adjust
from there against real call recordings rather than guessing blind.
Realtime detection
For a live conversation, stream audio continuously instead of scoring one clip at a time:
import { WebSocket } from 'ws';
const ws = new WebSocket('wss://api.tryhakim.ai/v1/audio/eot/stream', {
headers: { Authorization: `Bearer ${process.env.HAKIM_API_KEY}` },
});
ws.on('message', (raw) => {
const event = JSON.parse(raw.toString());
if (event.type === 'turn.update' && event.complete) {
console.log('turn complete, probability', event.probability);
}
});
// Stream 16kHz mono PCM-16 frames continuously, base64-encoded:
function pushFrame(pcm16) {
ws.send(
JSON.stringify({
type: 'input_audio_buffer.append',
audio: pcm16.toString('base64'),
}),
);
}
A few things that differ from the realtime STT/TTS surfaces:
- No
commitframe. There's no discrete per-utterance boundary — the proxy continuously re-scores a rolling trailing window (8 seconds) as audio arrives, and pushes aturn.updateframe on its own internal cadence (roughly every 300ms), not once per client frame you send. pcm16@ 16kHz only in this release. No opus/mulaw yet.- Keep streaming through pauses. Don't gate sending audio on your own local VAD · the model's signal depends partly on the trailing silence already present in the window, so starving it of audio during a pause removes the very thing it's measuring.
evaluated: falseis not an error. If the detector didn't answer in time for a given tick, thatturn.updateframe carriesevaluated: falseand repeats the last known-goodprobability/complete· the session stays open. Treat it as "no new information this tick," not as a failure to handle specially.
Billing is by total audio-seconds streamed, reported periodically in
session.usage frames and once more when the session closes · not by
how many turn.update ticks fired.
Pricing
Both surfaces bill the eot_batch / eot_realtime usage kinds, by
audio-seconds evaluated (ceiled to the nearest second), against your
plan's included credits. See the pricing page for the
per-plan overage rate, and usage reporting
for how these events show up in the x-hakim-* headers and the
GET /v1/usage/events API.