Close Stream
Streaming:Flux
Use the CloseStream message to close the WebSocket stream. Flux decodes the audio it has already received — emitting the corresponding interim Update messages — and then closes the connection.
Purpose
Section titled “Purpose”In conversational audio processing, there are scenarios where you need to stop a stream and close the connection. The CloseStream message instructs the server to finish decoding the audio it has already received, emit the corresponding Update messages, and then terminate the WebSocket connection.
Example Payloads
Section titled “Example Payloads”To send the CloseStream message, you need to send the following JSON message to the server:
{
"type": "CloseStream"
}Upon receiving CloseStream, the server emits Update messages for any audio it has already received, then closes the connection. A representative interim Update:
{
"type": "TurnInfo", // Message type
"request_id": "uuid", // Unique identifier of the request (UUID format)
"sequence_id": 0, // Message sequence number, starts at 0 and increments for each server message
"event": "Update", // Interim result — CloseStream does not emit an EndOfTurn
"turn_index": 0, // The index of the current turn
"audio_window_start": 0.0, // Start time in seconds of the transcribed audio range
"audio_window_end": 0.0, // End time in seconds of the transcribed audio range
"transcript": "string", // Interim transcript — treat the latest as final
"words": [...], // Array of word objects
"end_of_turn_confidence": 0.0 // Confidence score 0-1
}Related Resources
Section titled “Related Resources”- Configure - Update stream configuration mid-stream
- Force End Turn - End the current turn immediately from an external signal
- Getting Started with Flux - Quickstart guide with basic configuration