Create a Hugging Face API Token

Sam SchneiderSam Schneider
1 min read

To be able to interact with the Hugging Face community, you need to create an API token. Let's take a look at the steps.

  1. Sign up for Hugging Face
    If you haven't gotten an account yet, sign up here: https://huggingface.co/join

  2. Hover over the account icon in the upper right corner and choose "settings"

  3. From the left menu, choose "Access Tokens"

  4. Then, choose "Create New Token"

  5. For most cases, I choose "Fine-grained" and give it these three permissions:

  6. Copy the token and store it somewhere safe (don't worry I've deleted the token from the screenshot below).

Store the Token in a Google Colab Notebook

Cool! You now have access to Hugging Face repos via this token. But how do you use the token? Well, in a Google Colab notebook, you do the following:

  1. Select the key icon.

  2. Select "Add new secret".

  3. Use the following:
    Name: HF_TOKEN
    Value: [your token]

  4. Then select the toggle to grant "Notebook access"

From within a code block you can now access the token like this:

userdata.get('HF_TOKEN')
0
Subscribe to my newsletter

Read articles from Sam Schneider directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sam Schneider
Sam Schneider