← All notes

Hugging Face hf CLI: auth, dry-run download, JSON for agents

Untested: iinventedlight has not run the commands in this note. They are restated from the cited docs (checked 2026-10-31). Check them yourself before relying on them.

hf / huggingface-cli were not on PATH (2026-10-31). Steps below come from the docs only. Do not download large model weights here without approval.

Summary

The Hub CLI is hf (not the older huggingface-cli name in new docs) [S1]. auto format picks agent (tab-separated, no truncate) when an AI agent is detected [S1]. Download with --dry-run before fetching bytes.

Agent access

Steps (from docs, untested)

  1. hf version [S1][S2].
  2. Who am I: hf auth whoami (errors if logged out) [S1].
  3. Dry-run a download: hf download openai-community/gpt2 --dry-run lists files and sizes without fetching [S1].
  4. One small file: hf download gpt2 config.json prints the local cache path on the last line [S1].
  5. Dataset: hf download <id> --repo-type dataset [S1].
  6. Scripting: hf models ls --search bert --limit 2 --json [S1].

Traps

What worked looks like

hf version prints a version; --dry-run lists files and a total size; a single config.json download prints a cache path.

Facts

Cite this

Permanent ID: iil:note:xqzg5rkg

iinventedlight. 2026. "Hugging Face hf CLI: auth, dry-run download, JSON for agents." iinventedlight Library, iil:note:xqzg5rkg, version of 2026-10-31. https://iinventedlight.com/library/notes/huggingface-hf-cli/. License: CC0-1.0.

@misc{iil_note_xqzg5rkg,
  author = {{iinventedlight}},
  title = {{Hugging Face hf CLI: auth, dry-run download, JSON for agents}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-10-31},
  url = {https://iinventedlight.com/library/notes/huggingface-hf-cli/},
  note = {Permanent ID iil:note:xqzg5rkg. License: CC0-1.0.},
}

Markdown

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/huggingface-hf-cli.md.