Close Stream

Send a CloseStream message to close the WebSocket stream.
Flux

Use the CloseStream message to close the WebSocket stream. This forces the server to immediately process any unprocessed audio data and return the final transcription results.

Purpose

In conversational audio processing, there are scenarios where you may need to force the server to close. Deepgram supports a CloseStream message to handle such situations. This message will send a shutdown command to the server instructing it to finish processing any cached data, send the response to the client, send a summary metadata object, and then terminate the WebSocket connection.

Example Payloads

To send the CloseStream message, you need to send the following JSON message to the server:

JSON
1{
2 "type": "CloseStream"
3}

Upon receiving the CloseStream message, the server will process all remaining audio data and return the following:

JSON
1{
2"type": "TurnInfo", // Message type
3"request_id": "uuid", // Unique identifier of the request (UUID format)
4"sequence_id": 0, // Message sequence number, starts at 0 and increments for each server message
5"event": "Update|StartOfTurn|EagerEndOfTurn|TurnResumed|EndOfTurn", // Event type enum
6"turn_index": 0, // The index of the current turn
7"audio_window_start": 0.0, // Start time in seconds of the transcribed audio range
8"audio_window_end": 0.0, // End time in seconds of the transcribed audio range
9"transcript": "string", // Current turn transcript
10"words": [...], // Array of word objects
11"end_of_turn_confidence": 0.0 // Confidence score 0-1
12}