Set Smart Turn timeout on streaming STT
Set Smart Turn timeout on streaming STT
When Smart Turn is on, the model controls when speech_final fires. Set smart_turn_timeout (1–5000 ms) so extended silence still forces utterance-final even if the model keeps scoring "not done" (user walks away, long think pause). Base Smart Turn setup: Enable Smart Turn on streaming speech-to-text. Base connect loop: Stream speech to text over WebSocket.
Add both query params
smart_turn_timeout only applies when smart_turn is set.
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 (enables Smart Turn). |
| smart_turn_timeout | 1–5000 ms | Max silence before forcing speech_final. |
Omit smart_turn_timeout for unlimited model control: speech_final fires only when confidence exceeds the threshold. Docs example uses 3000 ms with smart_turn=0.7.
Utterance-final (is_final=true and speech_final=true) fires when confidence clears the threshold, or when the timeout is exceeded. Below-threshold silence stays chunk final (is_final=true, speech_final=false).
Proxy the WebSocket through your backend so the API key stays off the client.
Pitfalls
- Batch REST has no
smart_turnorsmart_turn_timeout. Streaming WebSocket only. - Timeout without
smart_turndoes nothing. - Without a timeout, a session can hang if the model keeps predicting "not done."
endpointingis a separate silence knob for non–Smart Turn (and remains available): Set streaming STT endpointing silence.- Console API credits are separate from SuperGrok's weekly pool on grok.com.