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

# Hugging Face

> Push encoded `.serva` datasets to the Hugging Face Hub and pull them back with the Python client.

The client can push encoded **`.serva`** datasets to the Hugging Face Hub and pull them back later. The Hub support ships with `serva` so there is nothing extra to install.

## Authentication

Set your Hugging Face token as `HF_TOKEN` or pass `hf_token=` when you build the client.

```python theme={null}
from serva import Serva

client = Serva(api_key="sk_live_...")   # HF_TOKEN read from the environment
```

## Push

Encode a file, then push the result to a dataset repo. The repo is created if it does not exist, and `push` returns its URL.

```python theme={null}
result = client.encode("dataset.parquet")
client.hub.push(result, repo_id="your-name/my-dataset")
```

Passing the `EncodeResult` lets the dataset card show the compression savings. A plain file path works too, and the card leaves the savings out.

```python theme={null}
client.hub.push("encoded/dataset.serva", repo_id="your-name/my-dataset")
```

Pass `private=True` to create a private dataset repo.

> [!NOTE]
>
> Pushing writes a `README.md` dataset card next to the file with the encoded
> size, the original size, and the savings, plus a short snippet showing how to
> pull and decode it.

## Pull

Download a `.serva` file from a dataset repo. `pull` returns the local path, which you can hand straight to `decode`.

```python theme={null}
path = client.hub.pull("your-name/my-dataset", "dataset.serva")
client.decode(path, output="dataset.parquet")
```

Pass `revision=` to pull from a specific branch, tag, or commit. It defaults to `main`.

## List

List the dataset repos owned by the authenticated user.

```python theme={null}
for repo_id in client.hub.list():
    print(repo_id)
```

> [!NOTE]
>
> A failed Hub operation raises `HubError`, for example a missing token, a repo
> that does not exist, or one you cannot reach.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.