#/v1/listen Request Cancellation

1 messages · Page 1 of 1 (latest)

slate solstice
#

Does the /v1/listen endpoint provide any way to cancel a running transcription?

signal peakBOT
#

Hey there! This channel allows you to ask Kapa.ai for assistance. But it looks like you haven't connected your Discord profile to your Deepgram account yet. You can do so at https://community.deepgram.com - by doing so, you'll be able to ask questions in #1115960287183511643 if you need human assistance!

neat jettyBOT
#

Hi @slate solstice. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the knowledge sources, the behavior differs depending on whether you're using the pre-recorded (REST) or streaming (WebSocket) version of /v1/listen:

Pre-Recorded (REST) /v1/listen

There is no way to cancel a pre-recorded transcription request once it has been submitted. As stated in the knowledge sources, "all requests that [Deepgram] receives will eventually either complete or fail" and "there is no ability or need to delete or cancel a request once it has been submitted." [Cancel Request discussion]

Streaming (WebSocket) /v1/listen

For the streaming endpoint, you have two relevant control messages:

  1. CloseStream — Signals to Deepgram that you won't be sending any more audio. Deepgram will transcribe any buffered audio, return the final transcript, and then close the WebSocket. This is the recommended way to gracefully end a streaming session:

    { "type": "CloseStream" }
    

    [Streaming short connections; Pending requests discussion]

  2. Finalize — Flushes any messages that might be in the queue without closing the connection entirely:

    { "type": "Finalize" }
    

    [Finalize discussion]

In the Python SDK, these are exposed as connection.send_close_stream() and connection.send_finalize() respectively. [Python SDK reference]

#

Important: Simply closing the WebSocket connection without sending CloseStream first can leave the request in a "Pending" state in your usage logs and may not properly finalize billing. Always prefer sending CloseStream before closing the socket. [Pending requests discussion]

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: