Learn R Programming

LLMR (version 0.6.0)

llm_api_key_env: Declare an API key sourced from an environment variable

Description

Use this when creating an LLM config to avoid placing secrets inside R objects. Store your key in your shell or in ~/.Renviron and reference it here by name.

Usage

llm_api_key_env(var, required = TRUE, default = NULL)

Value

An internal secret handle to be used as api_key = llm_api_key_env("VARNAME").

Arguments

var

Name of the environment variable (e.g., "OPENAI_API_KEY").

required

If TRUE, missing variables cause an authentication error at call time.

default

Optional default if the environment variable is not set.