BACK TO CHANGELOG

Real-Time Debugging Improvements

BY Shir Goldberg  | November 08 2022

Deepgram’s live streaming transcription API has been updated for enhanced usability.

Deepgram will now return the request ID and any applicable error messages in the headers for the pre-WebSocket HTTP connection created for all streaming requests.

The request ID is stored in the HTTP header named dg-request-id. This header is present in all requests, regardless of success or failure.

In case of request failure, an additional HTTP header named dg-error will be included with the body of the error.

Here’s an example of accessing this information using the Python websocket library:

try:
    async with websockets.connect('wss://api.deepgram.com/v1/listen') as ws:
        print(ws.response_headers['dg-request-id'])
except websockets.exceptions.InvalidStatusCode as e:
    print(f'🔴 ERROR: Could not connect to Deepgram! {e.headers.get("dg-error")}')
    print(f'🔴 Please contact Deepgram Support with request ID {e.headers.get("dg-request-id")}')

Please note: if using Javascript in the browser, HTTP header information is not accessible due to inherent limitations in the Javascript WebSocket API. However, the headers are accessible if using NodeJS.

I’m Shir, the product manager for Deepgram’s streaming. If you have any feedback about this change, or anything else around Deepgram, we’d love to hear from you. Please let us know in our GitHub discussions.