# 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

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.

:::callout{intent="warning"}
`CloseStream` does not finalize the active turn. No `EndOfTurn` event is emitted, so the last message you receive is an interim `Update`, not a confirmed final transcript — treat the most recent `Update` as the final transcript for the stream. Flux does not emit a summary metadata object, and the server closes the connection without sending a WebSocket close status code.
:::

## Example Payloads

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

**`JSON`**

```json JSON
{
  "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`:

**`JSON`**

```json JSON
{
"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

- [Configure](/guides/streaming-audio-flux-configure) - Update stream configuration mid-stream
- [Force End Turn](/guides/streaming-audio-flux-force-end-turn) - End the current turn immediately from an external signal
- [Getting Started with Flux](/guides/streaming-audio-flux-quickstart) - Quickstart guide with basic configuration

***

## Related pages

- [Configure](./streaming-audio-flux-configure.md)
- [Force End Turn](./streaming-audio-flux-force-end-turn.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
