hf_set_token: Set Hugging Face API Token

View source: R/auth.R

hf_set_tokenR Documentation

Set Hugging Face API Token

Description

Set or update your Hugging Face API token for authentication. The token is written to the 'HF_TOKEN' environment variable used by current Hugging Face tooling, and mirrored to the legacy 'HUGGING_FACE_HUB_TOKEN' name.

Usage

hf_set_token(token = NULL, store = FALSE)

Arguments

token

Character string containing your HF token, or NULL to set interactively. If NULL, will prompt for token input (not echoed to console).

store

Logical. If TRUE, stores the token in .Renviron for future sessions. Default: FALSE (token only available for current session).

Details

Inference calls require a token with the "Make calls to Inference Providers" permission. See https://huggingface.co/docs/hub/security-tokens for token setup.

Value

Invisibly returns TRUE if token was set successfully.

Examples

## Not run: 
# Set token for current session only
hf_set_token("hf_xxxxxxxxxxxxx")

# Set token interactively and store permanently
hf_set_token(store = TRUE)

## End(Not run)

huggingfaceR documentation built on Aug. 30, 2026, 1:06 a.m.