# Getting the Hugging Face API Key

Before deploying the LLaMA model, you need to obtain an API key from Hugging Face. Follow these steps to get your API key.

{% hint style="info" %}
Make sure you already have an account on Hugging Face.
{% endhint %}

Go to the [Hugging Face](https://huggingface.co/login) website and enter the "Username/Email address" and "password" you use. Click the Login button to enter Hugging Face.

<figure><img src="https://2882153758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9YWb69HFXLHYlXffReU%2Fuploads%2FVckJXNlI368wojQCLigx%2Fimage.png?alt=media&#x26;token=a6122987-fcf1-4753-a164-1f852e3c6e87" alt=""><figcaption><p>Login Hugging Face</p></figcaption></figure>

After entering the Hugging Face page, press profile at the top right and select Access Token.

<figure><img src="https://2882153758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9YWb69HFXLHYlXffReU%2Fuploads%2FCe37eyZA3CN2lxtSyJXr%2Fimage.png?alt=media&#x26;token=dca7aa7c-f555-4bbc-91a3-5c89822a4db7" alt=""><figcaption><p>Access Token</p></figcaption></figure>

On the Access Tokens page press the "+ Create new token" button.

<figure><img src="https://2882153758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9YWb69HFXLHYlXffReU%2Fuploads%2FRO30RTWm8q5ryJJ3qv8S%2Fimage.png?alt=media&#x26;token=da939305-4ab2-4185-84be-a485fe7046c6" alt=""><figcaption><p>Create New Token</p></figcaption></figure>

In this guide, the token type used is Write, enter the token name. Click the **Create Token** button to create a new token for Hugging Face.

<figure><img src="https://2882153758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9YWb69HFXLHYlXffReU%2Fuploads%2FABZ2JDfzjeHd1k2jtZyM%2Fimage.png?alt=media&#x26;token=a07a3690-ee94-4de6-8981-39ec638fe4eb" alt=""><figcaption><p>Create Token</p></figcaption></figure>

Once you have generated the token, save it securely. You will need it to authenticate your requests to Hugging Face models.

<figure><img src="https://2882153758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9YWb69HFXLHYlXffReU%2Fuploads%2FdRPWa1lVMjsecxUwb8dX%2Fimage.png?alt=media&#x26;token=e023cb47-aec6-4cd5-9dbb-31e4b03db493" alt=""><figcaption><p>Token</p></figcaption></figure>

## Encoding the Hugging Face API Token to Base64

To convert your Hugging Face API token into a text format represented by Base64 characters. You can run the following syntax according to the operating system your computer uses.

### Linux

On computers using the Linux operating system, you can follow the following steps. Open a terminal on your computer. Run the following command to encode your Hugging Face token to base64.

```bash
echo -n 'your-hugging-face-token' | base64
```

Replace `your-hugging-face-token` with your actual Hugging Face token. The command will output the base64-encoded token.

```bash
aGZfQUZiV0phb2RTR1RqUXhReENQUXhRekV5c1VIenp4d1hNWA==
```

### Windows

On computers using the Windows operating system, use PowerShell. Open PowerShell on your computer.

<figure><img src="https://2882153758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9YWb69HFXLHYlXffReU%2Fuploads%2FX9hP5vUBlDJh3YOym3vt%2Fimage.png?alt=media&#x26;token=09283bca-81c5-4599-a5de-de22f990a280" alt="" width="375"><figcaption><p>Open Powershell</p></figcaption></figure>

Use the following command to encode your token using Base64 in PowerShell.

```bash
[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("your-hugging-face-token"))
```

<figure><img src="https://2882153758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9YWb69HFXLHYlXffReU%2Fuploads%2FYbLvmNiHSdxrwsEZsN3r%2Fimage.png?alt=media&#x26;token=b2fafaa9-6d75-4835-be98-18e243ceec57" alt=""><figcaption><p>Encode Token</p></figcaption></figure>
