We encourage the use of the keyring package to securely store API keys. This function attempts to load your OpenAI API key from keyring if it is available, or from an environment variable otherwise.
Examples
Sys.setenv(TEMP_OAI_API_KEY = "test_value")
test_result <- oai_get_default_key("TEMP_OAI_API_KEY")
test_result
#> [1] "test_value"
Sys.unsetenv("TEMP_OAI_API_KEY")