Agentic.LLM.Credentials
(agentic v0.2.2)
Copy Markdown
Resolved credentials for a single provider.
resolve/1 walks the provider's declared env_vars/0 in priority
order and returns the first non-empty value wrapped in a %Credentials{}
struct. The provider knows its own env var names; nothing else does.
resolve/2 accepts an opts keyword list. If opts[:api_key] is set,
it is used directly instead of looking up env vars. This allows the
host application to inject keys per-call (e.g. from an encrypted store).
Runtime credentials can also be stored via put/2 and are checked
before environment variables.
Summary
Functions
Returns true when the provider has a usable credential.
Remove all credentials from the runtime ETS store.
Remove a single credential from the runtime ETS store.
Initialize the ETS credential store. Call once at app startup.
Store a credential in the runtime ETS store.
Resolve credentials for a provider module.
Types
Functions
Returns true when the provider has a usable credential.
@spec clear() :: :ok
Remove all credentials from the runtime ETS store.
@spec delete(String.t()) :: :ok
Remove a single credential from the runtime ETS store.
@spec init_store() :: :ok
Initialize the ETS credential store. Call once at app startup.
Store a credential in the runtime ETS store.
Resolve credentials for a provider module.
When opts[:api_key] is provided, uses that directly instead of
looking up environment variables. Falls back to the runtime ETS store,
then to env var lookup.
iex> Credentials.resolve(Agentic.LLM.Provider.OpenAI)
{:ok, %Credentials{api_key: "sk-...", source: {:env, "OPENAI_API_KEY"}}}
iex> Credentials.resolve(Agentic.LLM.Provider.OpenAI, api_key: "sk-direct")
{:ok, %Credentials{api_key: "sk-direct", source: :injected}}