How to Use a Hugging Face Mirror With HF_ENDPOINT

Set up a Hugging Face mirror with HF_ENDPOINT in one line. Learn how mirrors work, then point hf download at Hippius Hub. Read the step-by-step guide.

Brittany Seales
Uploaded on:
Est. Read time:
7 min
Hippius article about how to use a hugging face mirror with HF_ENDPOINT.

Hippius Hub works as a Hugging Face mirror and a full model hub at the same time: set one environment variable, HF_ENDPOINT=https://hub.hippius.com, and the Hugging Face tools you already use download from Hippius instead. The same variable is what every huggingface mirror relies on, whether it's a public mirror, a company proxy, or a hub you push your own models to.

This guide covers what a mirror actually is, how HF_ENDPOINT redirects your tools, how to set it on each operating system, and how to choose between a public mirror, a private proxy, and a hub of your own. If you're weighing up where to keep models long term, our post on Hugging Face alternatives covers that side of the decision.

Contents

What is a Hugging Face mirror?

A Hugging Face mirror is a server that answers the same requests as huggingface.co, so your tools can fetch models and datasets from it without knowing the difference. It speaks the same API, uses the same repo names, and returns files in the layout the huggingface_hub library expects. To your code, meta-llama/... or your-org/your-model resolves the same way it always did.

People use mirrors for a few practical reasons. Some are in regions where huggingface.co is slow or unreachable. Some work in companies that route every external download through an approved proxy. Others want a second copy of the models they depend on, held somewhere they control, so a training run doesn't fail because one site had a bad afternoon.

How does HF_ENDPOINT work?

Every request the huggingface_hub library makes starts from a base URL. By default that's https://huggingface.co. The library reads the HF_ENDPOINT environment variable when it loads, and if it's set, that value replaces the default for every call that follows. Hugging Face's own documentation describes it as the setting to configure the Hub base URL, originally intended for organisations running a private hub.

Because the CLI, Transformers, Datasets and Diffusers all go through huggingface_hub to fetch files, one variable redirects all of them. That's why so many products use it as their integration point: enterprise artifact managers such as JFrog Artifactory document setting HF_ENDPOINT to point clients at their proxy, and public mirrors give out the same one-line instruction.

Diagram showing HF_ENDPOINT redirecting huggingface_hub requests from the default hub to a Hugging Face mirror

Setting HF_ENDPOINT on Linux, macOS and Windows

Set the variable in the shell or environment your code runs in. The examples below use Hippius Hub; swap in another mirror's URL if you're using one.

  1. Linux or macOS, current session. Run this before starting Python or the CLI:

    Bash
    export HF_ENDPOINT=https://hub.hippius.com
    
  2. Linux or macOS, every session. Add the same line to ~/.bashrc or ~/.zshrc, then open a new terminal.

  3. Windows PowerShell.

    POWERSHELL
    $env:HF_ENDPOINT = "https://hub.hippius.com"
    
  4. Inside a script or notebook. Set it before importing anything from Hugging Face, because the library reads it at import time:

    PYTHON
    import os
    os.environ["HF_ENDPOINT"] = "https://hub.hippius.com"
    
    from huggingface_hub import snapshot_download
    
  5. Docker and CI. Pass it as an environment variable (-e HF_ENDPOINT=... or an env: block) so builds and test runners use the mirror too.

For private repos or uploads, sign in with an API key from your Hippius console settings in the same way you'd use a Hugging Face token.

Downloading models through a mirror with hf download

Once the variable is set, nothing else changes. The hf download command fetches from the mirror:

Bash
hf download your-org/your-model

Older guides use huggingface-cli download, which does the same job; the hf command is the newer name. In Python, hf_hub_download, snapshot_download and from_pretrained all respect the endpoint too, and they keep using the normal local cache, so models you've already downloaded aren't fetched again.

A quick way to confirm the switch worked is to print the endpoint the library is using:

PYTHON
from huggingface_hub import constants
print(constants.ENDPOINT)

If it shows your mirror's URL, every download in that process goes there.

Public mirror, private proxy, or your own hub?

Not every mirror does the same job, and the right one depends on what you need from it.

A public mirror is the quickest fix when huggingface.co is hard to reach. You don't sign up for anything, but you also don't control what it holds, how long it keeps files, or whether it'll still be there next year. It's a read-only window onto someone else's copy.

A private proxy inside your company caches whatever your team downloads and gives security teams one place to apply policy. It's the common choice in large organisations, but it means running and paying for the proxy yourself, and it still depends on Hugging Face for anything not already cached.

A hub of your own goes a step further: it's somewhere you can upload, version and share models as well as download them. That's where Hippius Hub sits. It mirrors popular open models from Hugging Face and refreshes them daily, and it's also a complete model hub, with private and public repos, organisations, pull requests, and a container registry for the images that serve your models. Uploads go through a malware and unsafe-format scan first. What it doesn't do is mirror the whole of Hugging Face on demand, so a model outside the mirrored set needs to be pushed to your own namespace first.

Comparison of a public Hugging Face mirror, a private proxy and a model hub you can upload to

Common questions about Hugging Face mirrors

Is it safe to download models from a Hugging Face mirror?

It depends on who runs it. A mirror serves you files, so you're trusting it the same way you trust the original source. Prefer safetensors over pickle-based formats, and use a mirror that scans what it serves. Hippius Hub scans every upload for malware and unsafe formats before it's available to download.

Does HF_ENDPOINT work with Transformers and Datasets?

Yes. Transformers, Datasets and Diffusers fetch files through huggingface_hub, so they follow HF_ENDPOINT without any code changes. Set it before the libraries are imported.

How do I switch back to huggingface.co?

Unset the variable (unset HF_ENDPOINT on Linux or macOS) or remove it from your shell profile. The library falls back to its default of https://huggingface.co.

Final thoughts

  • A huggingface mirror answers the same API as huggingface.co, so your tools don't need to change.
  • HF_ENDPOINT is the one setting that redirects the CLI, Python library, Transformers and Datasets.
  • Set it before importing Hugging Face libraries, and pass it through to Docker and CI.
  • Public mirrors are quick, proxies suit large companies, and a hub of your own lets you upload and version models as well as download them.

If you want a mirror you can also build on, try Hippius Hub: browse the mirrored models on Hippius Hub, then set HF_ENDPOINT and run your next download through it.

About Hippius

Hippius is a distributed cloud platform built to give users a verifiable alternative to providers like AWS and Google Cloud. Files are encrypted and distributed across an independent network rather than held in a single provider's data center. Every storage claim, payment, and miner action is recorded on Hippius's own blockchain, so instead of asking users to trust the platform, Hippius lets them check it for themselves. On top of that foundation sits a full product suite: personal cloud storage, S3-compatible object storage with no egress fees, a CDN that serves stored files from the edge, confidential computing on secure hardware, and a container and model registry for AI.

Website | Discord | Twitter | Docs | Blog | Medium | Forum | Github | LinkedIn