TypeSafe.Config (TypeSafe v0.2.2)

Copy Markdown View Source

Resolves and validates client configuration from explicit options and environment variables.

Explicit options always win over environment variables. Empty or whitespace-only environment values are ignored and fall back to the built-in defaults.

Summary

Types

t()

Resolved, validated configuration.

Functions

The environment variable names read during resolution.

Resolve configuration, raising TypeSafe.ConfigError when the API key or timeout is invalid.

Types

t()

@type t() :: %TypeSafe.Config{
  api_key: String.t(),
  base_url: String.t(),
  default_model: String.t(),
  headers: %{optional(String.t()) => String.t()},
  timeout: pos_integer()
}

Resolved, validated configuration.

Functions

env_vars()

@spec env_vars() :: %{
  api_key: String.t(),
  base_url: String.t(),
  default_model: String.t()
}

The environment variable names read during resolution.

resolve!(opts)

@spec resolve!(keyword()) :: t()

Resolve configuration, raising TypeSafe.ConfigError when the API key or timeout is invalid.

Recognized options: :api_key, :base_url, :model, :timeout (milliseconds), and :headers.