This skill exposes the full Hugging Face Hub surface — both the huggingface-cli command-line tool and the huggingface_hub Python library — to every assistant interaction. It reads HF_TOKEN from the environment for authenticated operations; public read-only operations work without a token.
Token scope:
HF_TOKENis only required for private/gated model downloads, any upload, repo creation/deletion, and Space management. All public model/dataset browsing and downloads work without one.
HF_TOKEN in your shell environment or .env file — never hard-code it in scripts.HF_HUB_OFFLINE=1 prevents all network calls — safe for air-gapped or CI environments where the cache is pre-populated.bash
pip install huggingface_hub
bash
pip install "huggingface_hub[cli,torch,tensorflow,fastai,dev]"
ExtraAddscli``huggingface-cli commandhf_transferFast Rust-based multi-part downloads ( pip install hf_transfer)torchPyTorch model helperstensorflowTF model helpersfastaifastai helpers
bash
pip install hf_transfer
export HF_HUB_ENABLE_HF_TRANSFER=1
bash
huggingface-cli version
huggingface-cli whoami # requires HF_TOKEN
bash
huggingface-cli login
# or non-interactively:
huggingface-cli login --token $HF_TOKEN
bash
huggingface-cli logout
bash
huggingface-cli whoami
bash
export HF_TOKEN=hf_...
The library reads HF_TOKEN automatically — no explicit login needed when this var is set.
bash
huggingface-cli download <org/model>
# Example:
huggingface-cli download google/gemma-2b
bash
huggingface-cli download <org/model> <filename>
huggingface-cli download openai/whisper-large-v3 config.json
bash
huggingface-cli download <org/model> --local-dir ./models/mymodel
bash
huggingface-cli download <org/dataset> --repo-type dataset
bash
huggingface-cli download <org/model> --revision v1.0
huggingface-cli download <org/model> --revision abc1234
bash
huggingface-cli download <org/model> --include "*.safetensors"
huggingface-cli download <org/model> --exclude "*.bin" --include "*.safetensors"
bash
HF_TOKEN=hf_... huggingface-cli download meta-llama/Llama-3-8B
bash
huggingface-cli upload <org/repo> <local_file> <path_in_repo>
huggingface-cli upload myorg/mymodel weights.safetensors model/weights.safetensors
bash
huggingface-cli upload <org/repo> <local_folder> <path_in_repo>
huggingface-cli upload myorg/mymodel ./model_dir .
bash
huggingface-cli upload myorg/mydataset ./data . --repo-type dataset
bash
huggingface-cli upload myorg/myspace ./app . --repo-type space
bash
huggingface-cli upload myorg/mymodel ./weights . --commit-message "Add fp16 weights"
bash
huggingface-cli upload-large-folder myorg/mymodel --repo-type model ./large_model_dir
bash
huggingface-cli repo create <repo-name>
huggingface-cli repo create my-model --type model
huggingface-cli repo create my-dataset --type dataset
huggingface-cli repo create my-space --type space
bash
huggingface-cli repo delete <org/repo>
bash
huggingface-cli repo info <org/repo>
huggingface-cli repo info google/gemma-2b
bash
huggingface-cli tag create <org/repo> <tag> --message "Release v1.0"
huggingface-cli tag list <org/repo>
huggingface-cli tag delete <org/repo> <tag>
bash
huggingface-cli scan-cache
bash
huggingface-cli delete-cache
bash
huggingface-cli scan-cache --verbose
See templates/python_patterns.txt for full copy-paste code. Core entry point:
python
import os
from huggingface_hub import HfApi
api = HfApi(token=os.environ.get("HF_TOKEN"))
Use scripts/hf_helper.py as a CLI wrapper over the Python API for search, info, and cache operations without a browser.
VariableDefaultDescriptionHF_TOKEN—Access token; required for private/gated/write operationsHF_HOME``~/.cache/huggingfaceRoot cache directoryHF_HUB_CACHE``$HF_HOME/hubModel/dataset cacheHF_DATASETS_CACHE``$HF_HOME/datasetsDatasets library cacheHF_HUB_OFFLINE``0Set 1 to disable all network callsHF_HUB_ENABLE_HF_TRANSFER``0Set 1 to enable fast Rust downloaderHF_ENDPOINT``https://huggingface.coOverride for enterprise/mirror deploymentsHF_HUB_DISABLE_PROGRESS_BARS``0Set 1 to suppress tqdm bars (good for CI logs)HF_HUB_VERBOSITY``warningLog level: debug, info, warning, error``HUGGINGFACE_HUB_VERBOSITY—Legacy alias for HF_HUB_VERBOSITY
--local-dir over default cache for reproducible paths#The default cache uses content-addressed symlinks. Use --local-dir ./models/name when you need a stable, self-contained directory for an application.
Always pass --revision <commit-sha> in production downloads. Branches like main are mutable and can silently update between runs.
--include/ --exclude to skip unnecessary weights#Large models ship both .bin and .safetensors formats. Download only what your framework uses:
bash
huggingface-cli download <model> --include "*.safetensors" --exclude "*.bin"
bash
huggingface-cli download <model> # fills cache
export HF_HUB_OFFLINE=1 # subsequent loads use cache only
Create per-project tokens at https://huggingface.co/settings/tokens — read-only tokens cannot accidentally delete or overwrite repos.
Every upload is a git commit. Include a README.md (model card) in the upload folder so the repo is immediately browseable on the Hub.
upload-large-folder for models over ~50 GB#upload-large-folder uses multi-part upload with automatic retry and deduplication — far more reliable than upload for very large checkpoints.
SymptomFix401 UnauthorizedSet HF_TOKEN or run huggingface-cli login``403 Forbidden on gated modelAccept model terms on huggingface.co, then retryhuggingface-cli: command not found``pip install "huggingface_hub[cli]" and ensure pip bin is on PATHSlow downloadspip install hf_transfer and set HF_HUB_ENABLE_HF_TRANSFER=1``OSError: [Errno 28] No space leftRun huggingface-cli delete-cache to free cache spaceDownload resumes from wrong offsetUse --local-dir — the default cache can have stale partial blobsRepositoryNotFoundErrorCheck repo name spelling and that your token has accessRevisionNotFoundErrorVerify the branch/tag/SHA exists on the HubEntryNotFoundErrorFile not in this revision; check huggingface-cli repo infoEnterprise behind firewallSet HF_ENDPOINT=https://your-mirror.internal