Using Client Options with SDKs

Learn how to use different client options with Deepgram SDKs.

JS SDK

The JS SDK provides the ability to set connection-related client options. This is optional and is only needed when a specific need arises.

JS Client Options Interface

JavaScript
1export interface DeepgramClientOptions {
2 key?: string | IKeyFactory;
3 global?: NamespaceOptions & { url?: string; headers?: { [index: string]: any } };
4 listen?: NamespaceOptions;
5 manage?: NamespaceOptions;
6 onprem?: NamespaceOptions;
7 read?: NamespaceOptions;
8 speak?: NamespaceOptions;
9
10 /**
11 * @deprecated as of 3.4, use a namespace like `global` instead
12 */
13 fetch?: FetchOptions;
14
15 /**
16 * @deprecated as of 3.4, use a namespace like `global` instead
17 */
18 _experimentalCustomFetch?: Fetch;
19
20 /**
21 * @deprecated as of 3.4, use a namespace like `global` instead
22 */
23 restProxy?: {
24 url: null | string;
25 };
26}

Python SDK

The Python SDK provides the ability to set connection-related client options. This is optional and is only needed when a specific need arises.

Python Client Options Interface

The options field in the constructor is a simple dictionary of key/value pairs. Here are some notable options available:

  • keep_alive: This enables the client to automatically send KeepAlive messages for Live Transcription.
  • auto_flush_reply_delta: This value, set in milliseconds, will send a Finalize message if an is_final transcription has not been received after the set number of milliseconds.
Python
1class DeepgramClientOptions:
2 def __init__(
3 self,
4 api_key: str = "",
5 url: str = "",
6 verbose: int = verboselogs.WARNING, # logging level
7 headers: Optional[Dict] = None,
8 options: Optional[Dict] = None,
9 ):

.NET SDK

The .NET SDK provides the ability to set connection-related client options. This is optional and is only needed when a specific need arises.

.NET Client Options Interface

C#
1public interface IDeepgramClientOptions
2{
3 /*****************************/
4 // General Options
5 /*****************************/
6 /// <summary>
7 /// Deepgram API KEY
8 /// </summary>
9 public string ApiKey { get; }
10
11 /// <summary>
12 /// BaseAddress of the server :defaults to api.deepgram.com
13 /// no need to attach the protocol it will be added internally
14 /// </summary>
15 public string BaseAddress { get; }
16
17 /// <summary>
18 /// Api endpoint version
19 /// </summary>
20 public string APIVersion { get; }
21
22 /// <summary>
23 /// Global headers to always be added to the request
24 /// </summary>
25 public Dictionary<string, string> Headers { get; }
26
27 /*****************************/
28 // Prerecorded
29 /*****************************/
30 // No options currently
31
32 /*****************************/
33 // Live
34 /*****************************/
35 /// <summary>
36 /// Enable sending KeepAlives for Streaming
37 /// </summary>
38 public bool KeepAlive { get; }
39
40 /// <summary>
41 /// Enable sending KeepAlives for Streaming
42 /// </summary>
43 public decimal AutoFlushReplyDelta { get; }
44
45 /*****************************/
46 // OnPrem
47 /*****************************/
48 /// <summary>
49 /// Enable when using OnPrem mode
50 /// </summary>
51 public bool OnPrem { get; }
52
53 /*****************************/
54 // Manage
55 /*****************************/
56 // No options currently
57
58 /*****************************/
59 // Analyze
60 /*****************************/
61 // No options currently
62
63 /*****************************/
64 // Speak
65 /*****************************/
66 // No options currently
67}

Go SDK

The Go SDK provides the ability to set connection-related client options. This is optional and is only needed when a specific need arises.

Go Client Options Interface

Go
1type ClientOptions struct {
2 APIKey string
3 Host string // override for the host endpoint
4 APIVersion string // override for the version used
5 Path string // override for the endpoint path usually <version/listen> or <version/projects>
6 SelfHosted bool // set to true if using on-prem
7
8 // shared client options
9 SkipServerAuth bool // keeps the client from authenticating with the server
10
11 // prerecorded client options
12 // No options currently
13
14 // live client options
15 RedirectService bool // allows HTTP redirects to be followed
16 EnableKeepAlive bool // enables the keep alive feature
17
18 // these require inspecting messages, therefore you must update the InspectMessage() method
19 AutoFlushReplyDelta int64 // enables the auto flush feature
20}
Built with