Learn R Programming

fuzzylink (version 0.4.1)

anthropic_api_key: Install an ANTHROPIC API KEY in Your .Renviron File for Repeated Use

Description

This function will add your Anthropic API key to your .Renviron file so it can be called securely without being stored in your code. After you have installed your key, it can be called any time by typing Sys.getenv("ANTHROPIC_API_KEY") and will be automatically called in package functions. If you do not have an .Renviron file, the function will create one for you. If you already have an .Renviron file, the function will append the key to your existing file, while making a backup of your original file for disaster recovery purposes.

Usage

anthropic_api_key(key, overwrite = FALSE, install = FALSE)

Value

No return value, called for side effects.

Arguments

key

The API key provided to you from Anthropic formatted in quotes. A key can be acquired at https://console.anthropic.com/settings/keys

overwrite

If this is set to TRUE, it will overwrite an existing ANTHROPIC_API_KEY that you already have in your .Renviron file.

install

if TRUE, will install the key in your .Renviron file for use in future sessions. Defaults to FALSE.

Examples

Run this code

if (FALSE) {
anthropic_api_key("111111abc", install = TRUE)
# First time, reload your environment so you can use the key without restarting R.
readRenviron("~/.Renviron")
# You can check it with:
Sys.getenv("ANTHROPIC_API_KEY")
}

if (FALSE) {
# If you need to overwrite an existing key:
anthropic_api_key("111111abc", overwrite = TRUE, install = TRUE)
# First time, reload your environment so you can use the key without restarting R.
readRenviron("~/.Renviron")
# You can check it with:
Sys.getenv("ANTHROPIC_API_KEY")
}

Run the code above in your browser using DataLab