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
export interface DeepgramClientOptions {
key?: string | IKeyFactory;
global?: NamespaceOptions & { url?: string; headers?: { [index: string]: any } };
listen?: NamespaceOptions;
manage?: NamespaceOptions;
onprem?: NamespaceOptions;
read?: NamespaceOptions;
speak?: NamespaceOptions;
/**
* @deprecated as of 3.4, use a namespace like `global` instead
*/
fetch?: FetchOptions;
/**
* @deprecated as of 3.4, use a namespace like `global` instead
*/
_experimentalCustomFetch?: Fetch;
/**
* @deprecated as of 3.4, use a namespace like `global` instead
*/
restProxy?: {
url: null | string;
};
}
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 sendKeepAlive
messages for Live Transcription.auto_flush_reply_delta
: This value, set in milliseconds, will send aFinalize
message if anis_final
transcription has not been received after the set number of milliseconds.
class DeepgramClientOptions:
def __init__(
self,
api_key: str = "",
url: str = "",
verbose: int = verboselogs.WARNING, # logging level
headers: Optional[Dict] = None,
options: Optional[Dict] = None,
):
.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
public interface IDeepgramClientOptions
{
/*****************************/
// General Options
/*****************************/
/// <summary>
/// Deepgram API KEY
/// </summary>
public string ApiKey { get; }
/// <summary>
/// BaseAddress of the server :defaults to api.deepgram.com
/// no need to attach the protocol it will be added internally
/// </summary>
public string BaseAddress { get; }
/// <summary>
/// Api endpoint version
/// </summary>
public string APIVersion { get; }
/// <summary>
/// Global headers to always be added to the request
/// </summary>
public Dictionary<string, string> Headers { get; }
/*****************************/
// Prerecorded
/*****************************/
// No options currently
/*****************************/
// Live
/*****************************/
/// <summary>
/// Enable sending KeepAlives for Streaming
/// </summary>
public bool KeepAlive { get; }
/// <summary>
/// Enable sending KeepAlives for Streaming
/// </summary>
public decimal AutoFlushReplyDelta { get; }
/*****************************/
// OnPrem
/*****************************/
/// <summary>
/// Enable when using OnPrem mode
/// </summary>
public bool OnPrem { get; }
/*****************************/
// Manage
/*****************************/
// No options currently
/*****************************/
// Analyze
/*****************************/
// No options currently
/*****************************/
// Speak
/*****************************/
// No options currently
}
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
type ClientOptions struct {
APIKey string
Host string // override for the host endpoint
APIVersion string // override for the version used
Path string // override for the endpoint path usually <version/listen> or <version/projects>
SelfHosted bool // set to true if using on-prem
// shared client options
SkipServerAuth bool // keeps the client from authenticating with the server
// prerecorded client options
// No options currently
// live client options
RedirectService bool // allows HTTP redirects to be followed
EnableKeepAlive bool // enables the keep alive feature
// these require inspecting messages, therefore you must update the InspectMessage() method
AutoFlushReplyDelta int64 // enables the auto flush feature
}
Updated about 2 months ago