Enable Smart Turn on streaming speech-to-text
Enable Smart Turn on streaming speech-to-text
On streaming STT, brief mid-sentence pauses can fire speech_final early (phone numbers, dictation, thinking between clauses). Set smart_turn on the WebSocket URL so the model scores end-of-turn confidence at each VAD silence boundary and holds the utterance until confidence clears the threshold (or the timeout fires). See Stream speech to text over WebSocket for the base connect loop.
Add the query params
Smart Turn is configured on the URL. There is no setup message.
wss://api.x.ai/v1/stt?sample_rate=16000&encoding=pcm&interim_results=true&smart_turn=0.7&smart_turn_timeout=3000
| Param | Range | Role |
|---|---|---|
smart_turn |
0.0–1.0 | End-of-turn confidence threshold. Setting it enables Smart Turn. |
smart_turn_timeout |
1–5000 ms | Max silence before forcing speech_final. Only applies when smart_turn is set. |
Suggested thresholds from the docs:
| Threshold | Behavior |
|---|---|
0.5 |
Balanced. Catches most natural turn endings. |
0.7 |
Conservative. Better for dictation and number sequences. |
0.9 |
Very conservative. Only ends on highly confident completions. |
Omit smart_turn_timeout for unlimited model control. Then speech_final fires only when confidence exceeds the threshold.
Read the confidence field
Every transcript.partial includes end_of_turn_confidence (0.0–1.0) when Smart Turn is on. During active speech the value is 0.0 (the model runs at silence boundaries).
{
"type": "transcript.partial",
"text": "I will buy two of those, please.",
"is_final": true,
"speech_final": true,
"start": 0.0,
"duration": 2.4,
"end_of_turn_confidence": 0.983
}
When confidence is below the threshold, the event is demoted to chunk final: is_final=true, speech_final=false. Text locks; the utterance continues. Utterance-final (is_final=true and speech_final=true) fires when confidence exceeds the threshold, or when smart_turn_timeout is exceeded.
endpointing (default 400 ms, range 0–5000) remains a separate query param for silence length. Proxy the WebSocket through your backend so the API key stays off the client.
Pitfalls
- Batch REST multipart (
POST /v1/stt) has nosmart_turnfield. Streaming WebSocket only. smart_turn_timeoutonly applies whensmart_turnis set.- Omit the timeout and the session can hang if the model keeps predicting "not done."
- Console API credits are separate from SuperGrok's weekly pool on grok.com.