> ## Documentation Index
> Fetch the complete documentation index at: https://docs.upsonic.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Huggingface

> Using Huggingface models with Upsonic

## Overview

Huggingface provides access to thousands of open-source models through their Inference API. Great for experimentation with cutting-edge models.

**Model Class:** `HuggingFaceModel`

## Authentication

```bash theme={null}
export HF_TOKEN="hf_..."
```

## Examples

```python theme={null}
from upsonic import Agent, Task
from upsonic.models.huggingface import HuggingFaceModel

model = HuggingFaceModel(model_name="meta-llama/Llama-3.3-70B-Instruct")
agent = Agent(model=model)

task = Task("Hello, how are you?")
result = agent.do(task)
print(result)
```

## Model Settings

You can set model parameters in two ways: on the model or on the Agent.

**On the model:**

```python theme={null}
from upsonic import Agent, Task
from upsonic.models.huggingface import HuggingFaceModel, HuggingFaceModelSettings

model = HuggingFaceModel(
    model_name="meta-llama/Llama-3.3-70B-Instruct",
    settings=HuggingFaceModelSettings(max_tokens=1024, temperature=0.7)
)
agent = Agent(model=model)
```

**On the Agent:**

```python theme={null}
from upsonic import Agent, Task
from upsonic.models.huggingface import HuggingFaceModelSettings

agent = Agent(
    model="huggingface/meta-llama/Llama-3.3-70B-Instruct",
    settings=HuggingFaceModelSettings(max_tokens=1024)
)
```

## Parameters

| Parameter        | Type        | Description                    | Default | Source |
| ---------------- | ----------- | ------------------------------ | ------- | ------ |
| `max_tokens`     | `int`       | Maximum tokens to generate     | 2048    | Base   |
| `temperature`    | `float`     | Sampling temperature (0.0-1.0) | 0.7     | Base   |
| `top_p`          | `float`     | Nucleus sampling               | 0.95    | Base   |
| `seed`           | `int`       | Random seed                    | None    | Base   |
| `stop_sequences` | `list[str]` | Stop sequences                 | None    | Base   |
| `timeout`        | `float`     | Request timeout (seconds)      | 600     | Base   |
