View source: R/api_key_functions.R
set_api_key | R Documentation |
This function automatically sets/creates an interim R environment variable with the API key to call a given AI model (e.g. ChatGPT). Thereby users avoid exposing their API keys. If the API key is set in the console, it will/can be revealed via the .Rhistory. Find more information about this issue at https://httr2.r-lib.org/articles/wrapping-apis.html.
set_api_key(key, env_var = "CHATGPT_KEY")
key |
Character string with an (ideally encrypt) API key. See how to encrypt key here: https://httr2.r-lib.org/articles/wrapping-apis.html#basics. If not provided, it returns a password box in which the true API key can be secretly entered. |
env_var |
Character string indicating the name of the temporary R environment variable with
the API key and the used AI model. Currently, the argument only takes |
When set_api_key() has successfully been executed, get_api_key()
automatically
retrieves the API key from the R environment and the users do not need to specify the API when running
functions from the package that call the API. The API key can be permanently set by
using usethis::edit_r_environ()
. Then write CHATGPT_KEY=[insert your api key here]
and close
the .Renviron
window and restart R.
A temporary environment variable with the name from env_var
.
If key
is missing, it returns a password box in which the true API key can be entered.
Find your personal API key at https://platform.openai.com/account/api-keys.
get_api_key
## Not run:
set_api_key()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.