# `Agentic.LLM.Credentials`

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.

# `t`

```elixir
@type t() :: %Agentic.LLM.Credentials{
  api_key: String.t() | nil,
  base_url_override: String.t() | nil,
  headers: [{String.t(), String.t()}],
  source: {:env, String.t()} | :injected | :none
}
```

# `available?`

```elixir
@spec available?(module()) :: boolean()
```

Returns `true` when the provider has a usable credential.

# `clear`

```elixir
@spec clear() :: :ok
```

Remove all credentials from the runtime ETS store.

# `delete`

```elixir
@spec delete(String.t()) :: :ok
```

Remove a single credential from the runtime ETS store.

# `init_store`

```elixir
@spec init_store() :: :ok
```

Initialize the ETS credential store. Call once at app startup.

# `put`

```elixir
@spec put(String.t(), String.t()) :: true
```

Store a credential in the runtime ETS store.

# `resolve`

```elixir
@spec resolve(
  module(),
  keyword()
) :: {:ok, t()} | :not_configured
```

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}}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
