llm_api_key_env: Declare an API key sourced from an environment variable

View source: R/secrets.R

llm_api_key_envR Documentation

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)

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.

Value

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


LLMR documentation built on Aug. 26, 2025, 9:08 a.m.