JidoKeys (Jido Keys v1.0.0)
View SourceEasy access to LLM API keys and environment configuration.
Provides fast lookups with hierarchical resolution from session values, environment variables (via Dotenvy), application config, and defaults.
Basic Usage
# Returns value or `nil`
JidoKeys.get(:openai_api_key)
# Provide a default
JidoKeys.get(:openai_api_key, "demo-key")
# Bang variant raises ArgumentError
JidoKeys.get!(:openai_api_key)
# Boolean predicate
JidoKeys.has?(:openai_api_key)
# Inspect available keys (strings, already normalised)
JidoKeys.list()
Summary
Functions
Returns the value or default when the key is missing.
Returns the value or raises ArgumentError when the key is missing.
Returns true when the key exists and the value is non-empty.
Returns true when the key is present and its value is not nil or an empty string.
Returns the list of all loaded environment keys (as strings).
Sets a configuration value in the session store.
Reloads configuration from environment variables and files.
Safely converts a normalized string key to an atom if it's a known LLM key.
Types
Functions
Returns the value or default when the key is missing.
Examples
iex> JidoKeys.get(:my_api_key)
"secret_value"
iex> JidoKeys.get(:missing_key, "fallback")
"fallback"
Returns the value or raises ArgumentError when the key is missing.
Examples
iex> JidoKeys.get!(:my_api_key)
"secret_value"
iex> JidoKeys.get!(:missing)
** (ArgumentError) Configuration key :missing not found
Returns true when the key exists and the value is non-empty.
Examples
iex> JidoKeys.has?(:my_api_key)
true
iex> JidoKeys.has?(:missing_key)
false
Returns true when the key is present and its value is not nil or an empty string.
Examples
iex> JidoKeys.has_value?(:my_api_key)
true
iex> JidoKeys.has_value?(:empty_key)
false
@spec list() :: [String.t()]
Returns the list of all loaded environment keys (as strings).
Examples
iex> JidoKeys.list()
["openai_api_key", "database_url", "secret_key_base"]
Sets a configuration value in the session store.
Examples
iex> JidoKeys.put(:my_test_key, "test_value")
:ok
iex> JidoKeys.put("another_key", "another_value")
:ok
@spec reload(keyword()) :: :ok
Reloads configuration from environment variables and files.
Optional opts can be provided for future extensions.
Examples
iex> JidoKeys.reload()
:ok
iex> JidoKeys.reload(force: true)
:ok
Safely converts a normalized string key to an atom if it's a known LLM key.
This prevents memory leaks by only allowing predefined LLM keys to be converted to atoms. Unknown keys are returned as strings.
Examples
iex> JidoKeys.to_llm_atom("openai_api_key")
:openai_api_key
iex> JidoKeys.to_llm_atom("anthropic_api_key")
:anthropic_api_key
iex> JidoKeys.to_llm_atom("unknown_key")
"unknown_key"