BACK TO CHANGELOG

API,
Realtime

New Method for Closing Streams

BY Shir Goldberg  | October 17 2022

Deepgram’s real-time API has been updated for enhanced usability.

Streaming connections should now be closed by sending the JSON message { "type": "CloseStream" } . Previously, streaming connections were closed by sending an empty byte.

Here’s an example of sending a CloseStream message in Javascript:

socket.send(JSON.stringify({
    "type": "CloseStream"
}))

And an example in Python:

await ws.send(json.dumps({
    "type": "CloseStream"
}))

In the future, we will deprecate the ability to close the connection with an empty byte.  We recommend customers using our API move to using the CloseStream method to avoid potential disruptions. Any customers using our SDK will not need to make changes.