| name | hugging-face-cli |
| description | Execute Hugging Face Hub operations using the `hf` CLI. Use when the user needs to download models/datasets/spaces, upload files to Hub repositories, create repos, manage local cache, or run compute jobs on HF infrastructure. Covers authentication, file transfers, repository creation, cache operations, and cloud compute. |
Hugging Face CLI
The hf CLI provides direct terminal access to the Hugging Face Hub for downloading, uploading, and managing repositories, cache, and compute resources.
Quick Command Reference
| Task | Command |
|---|
| Login | hf auth login |
| Download model | hf download <repo_id> |
| Download to folder | hf download <repo_id> --local-dir ./path |
| Upload folder | hf upload <repo_id> . . |
| Create repo | hf repo create <name> |
| Create tag | hf repo tag create <repo_id> <tag> |
| Delete files | hf repo-files delete <repo_id> <files> |
| List cache | hf cache ls |
| Remove from cache | hf cache rm <repo_or_revision> |
| List models | hf models ls |
| Get model info | hf models info <model_id> |
| List datasets | hf datasets ls |
| Get dataset info | hf datasets info <dataset_id> |
| List spaces | hf spaces ls |
| Get space info | hf spaces info <space_id> |
| List endpoints | hf endpoints ls |
| Run GPU job | hf jobs run --flavor a10g-small <image> <cmd> |
| Environment info | hf env |
Core Commands
Authentication
hf auth login
hf auth login --token $HF_TOKEN
hf auth whoami
hf auth list
hf auth switch
hf auth logout
Download
hf download <repo_id>
hf download <repo_id> file.safetensors
hf download <repo_id> --local-dir ./models
hf download <repo_id> --include "*.safetensors"
hf download <repo_id> --repo-type dataset
hf download <repo_id> --revision v1.0
Upload
hf upload <repo_id> . .
hf upload <repo_id> ./models /weights
hf upload <repo_id> model.safetensors
hf upload <repo_id> . . --repo-type dataset
hf upload <repo_id> . . --create-pr
hf upload <repo_id> . . --commit-message="msg"
Repository Management
hf repo create <name>
hf repo create <name> --repo-type dataset
hf repo create <name> --private
hf repo create <name> --repo-type space --space_sdk gradio
hf repo delete <repo_id>
hf repo move <from_id> <to_id>
hf repo settings <repo_id> --private true
hf repo list --repo-type model
hf repo branch create <repo_id> release-v1
hf repo branch delete <repo_id> release-v1
hf repo tag create <repo_id> v1.0
hf repo tag list <repo_id>
hf repo tag delete <repo_id> v1.0
Delete Files from Repo
hf repo-files delete <repo_id> folder/
hf repo-files delete <repo_id> "*.txt"
Cache Management
hf cache ls
hf cache ls --revisions
hf cache rm model/gpt2
hf cache rm <revision_hash>
hf cache prune
hf cache verify gpt2
Browse Hub
hf models ls
hf models ls --search "MiniMax" --author MiniMaxAI
hf models ls --filter "text-generation" --limit 20
hf models info MiniMaxAI/MiniMax-M2.1
hf datasets ls
hf datasets ls --search "finepdfs" --sort downloads
hf datasets info HuggingFaceFW/finepdfs
hf spaces ls
hf spaces ls --filter "3d" --limit 10
hf spaces info enzostvs/deepsite
Jobs (Cloud Compute)
hf jobs run python:3.12 python script.py
hf jobs run --flavor a10g-small <image> <cmd>
hf jobs run --secrets HF_TOKEN <image> <cmd>
hf jobs ps
hf jobs logs <job_id>
hf jobs cancel <job_id>
Inference Endpoints
hf endpoints ls
hf endpoints deploy my-endpoint \
--repo openai/gpt-oss-120b \
--framework vllm \
--accelerator gpu \
--instance-size x4 \
--instance-type nvidia-a10g \
--region us-east-1 \
--vendor aws
hf endpoints describe my-endpoint
hf endpoints pause my-endpoint
hf endpoints resume my-endpoint
hf endpoints scale-to-zero my-endpoint
hf endpoints delete my-endpoint --yes
GPU Flavors: cpu-basic, cpu-upgrade, cpu-xl, t4-small, t4-medium, l4x1, l4x4, l40sx1, l40sx4, l40sx8, a10g-small, a10g-large, a10g-largex2, a10g-largex4, a100-large, h100, h100x8
Common Patterns
Download and Use Model Locally
hf download meta-llama/Llama-3.2-1B-Instruct --local-dir ./model
MODEL_PATH=$(hf download meta-llama/Llama-3.2-1B-Instruct --quiet)
Publish Model/Dataset
hf repo create my-username/my-model --private
hf upload my-username/my-model ./output . --commit-message="Initial release"
hf repo tag create my-username/my-model v1.0
Sync Space with Local
hf upload my-username/my-space . . --repo-type space \
--exclude="logs/*" --delete="*" --commit-message="Sync"
Check Cache Usage
hf cache ls
hf cache rm model/gpt2
Key Options
--repo-type: model (default), dataset, space
--revision: Branch, tag, or commit hash
--token: Override authentication
--quiet: Output only essential info (paths/URLs)
References