# Hugging Face

The `huggingface` provider allows you to use [Hugging Face Models](https://huggingface.co/models?other=text-generation-inference) using [Text Generation Inference](https://huggingface.co/docs/text-generation-inference/index).

```js
script({
  model: "huggingface:microsoft/Phi-3-mini-4k-instruct",
});
```

To use Hugging Face models with GenAIScript, follow these steps:

1. Sign up for a [Hugging Face account](https://huggingface.co/) and obtain an API key from their [console](https://huggingface.co/settings/tokens). If you are creating a **Fined Grained** token, enable the **Make calls to the serverless inference API** option.

2. Add your Hugging Face API key to the `.env` file as `HUGGINGFACE_API_KEY`, `HF_TOKEN` or `HUGGINGFACE_TOKEN` variables.

   .env

   ```txt
   HUGGINGFACE_API_KEY=hf_...
   ```

3. Find the model that best suits your needs by visiting the [HuggingFace models](https://huggingface.co/models?other=text-generation-inference).

4. Update your script to use the `model` you choose.

   ```js
   script({
       ...
       model: "huggingface:microsoft/Phi-3-mini-4k-instruct",
   })
   ```

Note

Some models may require a Pro account.

### Logging

[Section titled “Logging”](#logging)

You can enable the `genaiscript:huggingface` and `genaiscript:huggingface:msg` [logging namespaces](/genaiscript/reference/scripts/logging) for more information about the requests and responses:

### Aliases

The following model aliases are attempted by default in GenAIScript.

| Alias      | Model identifier                         |
| ---------- | ---------------------------------------- |
| large      | meta-llama/Llama-3.3-70B-Instruct        |
| small      | microsoft/phi-4                          |
| vision     | meta-llama/Llama-3.2-11B-Vision-Instruct |
| embeddings | nomic-ai/nomic-embed-text-v1.5           |

### Limitations

* Uses [OpenAI compatibility layer](https://huggingface.github.io/text-generation-inference/)
* listModels
* Ignore prediction of output tokens