# Hugging Face mirror (pkg.shecan.ir)

> Mirror of the Hugging Face Hub (HF_ENDPOINT) for huggingface_hub, the hf CLI, transformers, diffusers and datasets: public models and datasets.

- Upstream: huggingface.co
- Mirror URL: <https://mirror-hf.pkg.shecan.ir/>
- Clients: huggingface-hub, hf, transformers
- Service status: <https://pkg.shecan.ir/status.json> (key `huggingface`; up/down, refreshed every minute)
- Guide (Persian, HTML): <https://pkg.shecan.ir/mirrors/huggingface/>
- JSON: <https://pkg.shecan.ir/api/v1/mirrors/huggingface.json>

## Limitations

- Public repositories only; gated and private repositories (tokens) are not supported.
- Set HF_HUB_DISABLE_XET=1: Xet downloads bypass the mirror.
- Files of 5 GB or more are downloaded through the mirror but not cached.
- Uploads and other write operations are not supported.

## Setup

Every block below is the exact text of the Persian guide. Unless marked otherwise it is run against the live mirror in a disposable container on every catalog change; "checked by hand" blocks cannot run in a container. Change a machine only with its owner's permission: back up existing configuration first, merge into existing files instead of overwriting them, and keep the "Undo" step at hand.

### huggingface-hub, hf, transformers: persistent (user- or system-wide configuration)

Run (linux, macos)

```sh
export HF_ENDPOINT=https://mirror-hf.pkg.shecan.ir
export HF_HUB_DISABLE_XET=1
```

Undo / restore the default (linux, macos)

```sh
unset HF_ENDPOINT HF_HUB_DISABLE_XET
sed -i.bak -E '/^export (HF_ENDPOINT|HF_HUB_DISABLE_XET)=/d' ~/.bashrc ~/.zshrc ~/.profile 2>/dev/null || true
```

Run (windows) (checked by hand)

```powershell
[Environment]::SetEnvironmentVariable('HF_ENDPOINT', 'https://mirror-hf.pkg.shecan.ir', 'User')
[Environment]::SetEnvironmentVariable('HF_HUB_DISABLE_XET', '1', 'User')
```

Undo / restore the default (windows) (checked by hand)

```powershell
[Environment]::SetEnvironmentVariable('HF_ENDPOINT', $null, 'User')
[Environment]::SetEnvironmentVariable('HF_HUB_DISABLE_XET', $null, 'User')
```

### huggingface-hub, transformers: project (files inside the project)

Example

```python
import os
os.environ["HF_ENDPOINT"] = "https://mirror-hf.pkg.shecan.ir"
os.environ["HF_HUB_DISABLE_XET"] = "1"

from huggingface_hub import hf_hub_download
print(hf_hub_download("openai-community/gpt2", "config.json"))
```
