Skip to content
Software capabilities
Hugging Face Hub

Download a file from a Hugging Face model revision

Download a model file with a Hub resolve URL or the hf CLI. Use a full commit hash to pin the same file across builds.

Documentation reviewed · 2 methods with sources

Ways to do it

  1. API: GET /{repo_id}/resolve/{revision}/{filename}
  2. CLI: hf download --revision
API

GET /{repo_id}/resolve/{revision}/{filename}

Download a model artifact from a repository at a named revision or commit hash using the Hub resolve URL.

Read source: Hugging Face Hub file URL reference
Requirements
A model repository ID, revision, and filename. Private and gated models require a token with access to that repository.
Limitations
A resolve URL downloads one file at a time. Follow redirects when the file is served from a separate download host.

Example shell

curl --fail --location \
  -o config.json "https://huggingface.co/ORG/MODEL/resolve/$REVISION/config.json"
CLI

hf download --revision

Download a selected model file with hf download and use --revision to choose the commit, branch, or tag.

Read source: Hugging Face CLI guide
Requirements
The hf CLI and the model repository ID and filename. Authenticate for a private or gated repository.
Limitations
Files go into the Hub cache by default. Set --local-dir to put the model file in a project directory.

Example shell

hf download ORG/MODEL config.json --revision "$REVISION" --local-dir ./model