Skip to content
IntroducingSPEV, the first audio-in decision modelRead the launch →
SPEV, the first audio-in decision model →
sprag

Turn detection API

Send one clip of a caller's speech and read back the probability that the caller has finished their turn.

POST /v1/turns takes one clip of a caller's audio and returns the probability that the caller has finished their turn at the moment the clip ends.

Score a clip

curl https://api.sprag.ai/v1/turns \
  -H "Authorization: Bearer $SPRAG_API_KEY" \
  -F [email protected] \
  -F model=sprag-eot \
  -F agent_text="What is your date of birth?"
{
  "object": "turn.decision",
  "model": "sprag-eot",
  "probability": 0.87,
  "ended": true,
  "eot_threshold": 0.6,
  "usage": { "invocations": 1 }
}

The request is a multipart form.

FieldRequiredTypeNotes
fileYesfileThe caller's audio, ending at the moment to judge. WAV, FLAC, MP3, Ogg, WebM, M4A, AAC, or AIFF, at any sample rate and channel count.
modelYesstringA model id from the turn detection models.
agent_textNostringWhat the agent last said, up to 20,000 characters.
eot_thresholdNonumberThe probability that ends the turn, from 0 to 1. Defaults to 0.6.
FieldTypeNotes
objectstringturn.decision.
modelstringThe model id from the request.
probabilitynumberThe probability that the caller has finished the turn, from 0 to 1.
endedbooleantrue when probability reaches eot_threshold.
eot_thresholdnumberThe threshold probability was compared against.
usage.invocationsintegerThe pause determinations the request counts. See Usage.

Each model limits the length of the clip. If the clip is longer than the limit, the request returns HTTP 400 with the error code audio_too_long. The error message states the limit.

Usage

Turn detection is billed per pause determination: one reading of whether the caller has finished. usage.invocations counts the pause determinations the request is billed for. A POST /v1/turns request is one pause determination.

More information about the rate per pause determination can be found on the pricing page.

Errors

StatusMeaning
400The audio cannot be read or holds no samples; the error code is invalid_audio. The audio is longer than the model's limit; the error code is audio_too_long. A field is missing or out of range.
401Missing, invalid, or expired credentials.
402Out of credit. Also sent with the code payment_overdue when a plan invoice is unpaid. Also sent while billing for a new account is being set up; retry the request after a moment.
403Not a member of the requested organization.
404Unknown model id.
429Rate limit exceeded.
502The model returned an error. Retry the request.
503Temporarily unavailable. Retry after Retry-After when it is set.

See the errors reference for the full error shape and retry guidance.

Next steps

To score a live stream and receive an event at each turn boundary, see WebSocket.