Deepgram.Config (Deepgram v0.1.0)

View Source

Configuration for the Deepgram client.

This module handles configuration options for the Deepgram client, including API keys, access tokens, base URLs, and other settings.

Summary

Functions

Returns the authorization header value based on the configuration.

Returns the default HTTP headers for requests.

Creates a new configuration.

Returns the user agent string.

Types

t()

@type t() :: %Deepgram.Config{
  access_token: String.t() | nil,
  api_key: String.t() | nil,
  base_url: String.t(),
  headers: map(),
  options: map(),
  timeout: integer()
}

Functions

auth_header(config)

@spec auth_header(t()) :: String.t()

Returns the authorization header value based on the configuration.

Prioritizes access token over API key for authentication.

default_headers(config)

@spec default_headers(t()) :: map()

Returns the default HTTP headers for requests.

new(opts \\ [])

@spec new(keyword()) :: t()

Creates a new configuration.

Options

  • :api_key - Your Deepgram API key (required, or set via DEEPGRAM_API_KEY env var)
  • :access_token - OAuth 2.0 access token (alternative to API key)
  • :base_url - Base URL for API requests (default: "https://api.deepgram.com")
  • :timeout - Request timeout in milliseconds (default: 30_000)
  • :headers - Additional HTTP headers (default: %{})
  • :options - Additional options (default: %{})

Examples

iex> config = Deepgram.Config.new(api_key: "your-api-key")
%Deepgram.Config{...}

iex> config = Deepgram.Config.new(access_token: "your-access-token")
%Deepgram.Config{...}

iex> config = Deepgram.Config.new()  # Uses DEEPGRAM_API_KEY env var
%Deepgram.Config{...}

user_agent()

@spec user_agent() :: String.t()

Returns the user agent string.