<!-- generated: do not edit. source: content/docs/turns/api.md -->

# Turn detection API

`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

```bash
curl https://api.sprag.ai/v1/turns \
  -H "Authorization: Bearer $SPRAG_API_KEY" \
  -F file=@caller.wav \
  -F model=sprag-eot \
  -F agent_text="What is your date of birth?"
```

```json
{
  "object": "turn.decision",
  "model": "sprag-eot",
  "probability": 0.87,
  "ended": true,
  "eot_threshold": 0.6,
  "usage": { "invocations": 1 }
}
```

The request is a multipart form.

| Field | Required | Type | Notes |
| --- | --- | --- | --- |
| `file` | Yes | file | The 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. |
| `model` | Yes | string | A model id from the [turn detection models](/docs/turns/models). |
| `agent_text` | No | string | What the agent last said, up to 20,000 characters. |
| `eot_threshold` | No | number | The probability that ends the turn, from 0 to 1. Defaults to `0.6`. |

| Field | Type | Notes |
| --- | --- | --- |
| `object` | string | `turn.decision`. |
| `model` | string | The model id from the request. |
| `probability` | number | The probability that the caller has finished the turn, from 0 to 1. |
| `ended` | boolean | `true` when `probability` reaches `eot_threshold`. |
| `eot_threshold` | number | The threshold `probability` was compared against. |
| `usage.invocations` | integer | The pause determinations the request counts. See [Usage](#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](/pricing) page.

## Errors

| Status | Meaning |
| --- | --- |
| `400` | The 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. |
| `401` | Missing, invalid, or expired credentials. |
| `402` | Out 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. |
| `403` | Not a member of the requested organization. |
| `404` | Unknown model id. |
| `429` | Rate limit exceeded. |
| `502` | The model returned an error. Retry the request. |
| `503` | Temporarily unavailable. Retry after `Retry-After` when it is set. |

See the [errors reference](/docs/api/errors) 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](/docs/turns/websocket).
