Connection keepalive
Learn how connection keepalive works.
Overview
In real-time transcription, you may have periods where you are not sending any audio frames — for example when using client-side VAD (voice activity detection), during pauses in speech, or when you intentionally stop streaming audio.
To keep the session alive and preserve context, you must send a keepalive control message:
This prevents the WebSocket connection from timing out when no audio is being sent.
When to use
Send a keepalive message whenever:
- You only stream audio during speech (client-side VAD).
- You temporarily pause audio streaming but want to keep the session active.
This ensures that:
- The connection stays open.
- Session context (e.g., speaker labels, language tracking, prompt) is preserved.
Key points
- Send at least once every 20 seconds when not sending audio.
- You may send more frequently (every 5–10s is common).
- If no keepalive or audio is received for 20 seconds, the stream ends with a
408
request_timeouterror, the connection is closed, and the stream stops counting against your concurrent requests limit. - Before the start request, send a keepalive at least every 40 seconds. See below.
Before the start request
A connection can be opened early and held: send a keepalive at least every
40 seconds until the start request, or the connection is closed as idle
with WebSocket status 1001. There is no deadline for the start request
itself. A held connection counts against your connection limit.
See WebSocket authentication.
A connection that still sends api_key in the start request follows the rules
in Migrate WebSocket authentication.
- You are charged for the full stream duration, not just the audio processed.