Function er_set_tokens sets access tokens of embedding and inference APIs.

er_set_tokens(..., hard = FALSE)

Arguments

...

one or more api-token (name-value) pairs (e.g., huggingface = "TOKEN"). Names can be one or more of c("huggingface","openai","cohere").

hard

a logical specifying whether existing tokens should be overwritten.

Details

To obtain API tokens users must register with the respective services:

  • "Hugging Face"Sign up at huggingface.co/inference-api. Then go to profile and click on settings. Generate access token in the Access Tokens sub-menu.

  • "OpenAI"Sign up at openai.com/blog/openai-api. Select API. Click on Personal (top-right) and select View API keys. Then Create new secret key.

  • "Cohere"Sign up at cohere.com. Select API keys in your personal dashboard. Either Create Trial key (free of charge, but rate limited) or Create Production key (costly, but unlimited).

Hugging Face and Cohere both offer free-of-charge rate-limited API use.

References

Wulff, D. U., Aeschbach, S., Hussain, Z., & Mata, R. (2024). embeddeR. In preparation.

Examples

if (FALSE) {
# set hugging face token
set_tokens("huggingface" = "TOKEN")
}