Create a Hugging Face API Token

Create a Hugging Face API Token

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')
Heroic Leap
The Unexpectedly Simple 5 Steps to Build Your First LLM-Powered Chatbot

Want to jump into AI development, but not sure where to start? I've created a free guide with 5 simple steps that will guide you step by step to build your own custom chatbot backed by an LLM.

Get My Free Guide