User access tokens

What are User Access Tokens?

User Access Tokens are the preferred way to authenticate an application or notebook to Hugging Face services. You can manage your access tokens in your settings.

Access tokens allow applications and notebooks to perform specific actions specified by the scope of the roles shown in the following:

How to manage User Access Tokens?

To create an access token, go to your settings, then click on the Access Tokens tab. Click on the New token button to create a new User Access Token.

Select a role and a name for your token and voilà - you’re ready to go!

You can delete and refresh User Access Tokens by clicking on the Manage button.

How to use User Access Tokens?

There are plenty of ways to use a User Access Token to access the Hugging Face Hub, granting you the flexibility you need to build awesome apps on top of it.

User Access Tokens can be:

from transformers import AutoModel

access_token = "hf_..."

model = AutoModel.from_pretrained("private/model", use_auth_token=access_token)
Try not to leak your token! Though you can always rotate it, anyone will be able to read or write your private repos in the meantime which is 💩

Best practices

We recommend you create one access token per app or usage. For instance, you could have a separate token for:

We also recommend only giving the appropriate role to each token you create. If you only need read access (i.e., loading a dataset with the datasets library or retrieving the weights of a model), only give your access token the read role.