For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Ask AIPlaygroundLoginFree API Key
HomeAPI ReferenceVoice AgentSpeech-to-TextText-to-SpeechIntelligenceSelf-Hosted Deployments
HomeAPI ReferenceVoice AgentSpeech-to-TextText-to-SpeechIntelligenceSelf-Hosted Deployments
    • Getting Started with Speech to Text
  • Pre-Recorded Audio
    • Getting Started
    • Feature Overview
    • Template Apps
  • Streaming Audio
      • Getting Started
      • Feature Overview
      • Template Apps
      • End-of-Turn Configuration
      • Flux Multilingual & Language Prompting
      • Build a Flux-enabled Voice Agent
      • Why Flux's State Machine Matters
        • Configure
        • Close Stream
    • Compare Flux to Nova-3
  • Models and Languages
    • Models & Languages Overview
    • Languages Support
    • Language Detection
    • Multilingual Codeswitching
    • Model Options
    • Version
  • Formatting
    • Speaker Diarization
    • Dictation
    • Filler Words
    • Measurements
    • Numerals
    • Paragraphs
    • Profanity Filtering
    • Punctuation
    • Redaction
    • Smart Formatting
    • Supported Entity Types
    • Utterances
    • Utterance Split
  • Custom Vocabulary
    • Find and Replace
    • Keyterm Prompting
    • Keywords
    • Search
  • Media Input Settings
    • Channels
    • Encoding
    • Multichannel
    • Sample Rate
  • Results Processing
    • Understanding Word Confidence Scores
    • STT Callback
    • STT Tagging
    • Extra Metadata
  • Migrating
    • Migrating From Amazon Web Services (AWS) Transcribe to Deepgram
    • Migrating From Google Speech-to-Text (STT) to Deepgram
    • Migrating From OpenAI Whisper to Deepgram
    • Migrating from AssemblyAI Speech-to-Text to Deepgram
LogoLogo
Ask AIPlaygroundLoginFree API Key
On this page
  • Purpose
  • Example Payloads
  • Related Resources
Streaming AudioConversational STT for Voice Agents (Flux)Control Messages

Close Stream

Send a CloseStream message to close the WebSocket stream.
Was this page helpful?
Previous

Migrating from Nova-3 to Flux

Migrate from Nova-3 to Flux, Deepgram’s conversational speech recognition purpose-built for interactive voice agents.

Next
Built with
Streaming: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}

Related Resources

  • Configure - Update stream configuration mid-stream
  • Getting Started with Flux - Quickstart guide with basic configuration