hf-hub

Rust client for the Hugging Face Hub API with async and blocking interfaces

SDK
Cargo
v1.0.0
321stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
72/100Good
Development Activity76
Maintenance52
Community80
Maturity52
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
71/100Good
Architecture76
Code Quality78
Innovation70
Learning Curve60

hf-hub is a typed, ergonomic Rust client for the Hugging Face Hub API, serving as the Rust equivalent of the Python huggingface_hub library. It covers repository, file, commit, branch/tag, bucket, and user/organization operations against the Hub, including support for Hugging Face’s high-performance Xet storage backend.

The crate ships both an async interface (HFClient) built on tokio and reqwest, and a synchronous interface (HFClientSync) for callers that don’t want to manage their own async runtime, alongside a companion hfrs CLI for terminal-based Hub interaction.

What You Get

  • Async (HFClient) and blocking (HFClientSync) client interfaces that mirror each other method-for-method
  • Repository operations: query/create/delete/update/move models, datasets, and spaces
  • File and commit operations including streaming uploads, downloads, and revision diffs
  • Streaming pagination via impl Stream<Item = Result<T>> for memory-efficient async listing
  • Support for Hugging Face’s Xet high-performance transfer backend and bucket storage operations

Common Use Cases

  • Downloading model weights and dataset files from the Hugging Face Hub in a Rust application
  • Automating repository and branch/tag management for models hosted on the Hub
  • Building Rust ML tooling (e.g. inference servers) that needs to fetch artifacts from the Hub at runtime
  • Scripting Hub operations via the bundled hfrs CLI instead of the Python huggingface-cli
  • Uploading large model files efficiently using Xet-backed transfers

Under The Hood

Architecture - The repo is a Cargo workspace (hf-hub, hfrs CLI, benches, examples, integration-tests) where the hf-hub crate exposes HFClient (async, default) and HFClientSync (blocking, feature-gated) that both delegate to shared request-building logic in client.rs, with domain modules split by resource: repository/, buckets/, spaces.rs, users.rs, and a dedicated xet.rs for Hugging Face’s high-throughput transfer protocol. Tech Stack - Built on reqwest for HTTP, tokio for async execution, bon for builder-pattern request construction, serde/serde_json for (de)serialization, and thiserror for structured error types, targeting Rust 2024 edition. Code Quality - The workspace separates unit tests colocated with modules from a dedicated integration-tests crate covering blocking calls, bucket sync/streaming/Xet transfers, downloads, and caching, indicating deliberate coverage of both the sync and async surfaces against real Hub behavior. API Design - The parallel HFClient/HFClientSync design lets callers pick sync or async without learning two different APIs, and the builder-style request pattern (.model(...).info().send().await?) keeps call sites readable, though the breadth of resource types (repos, buckets, spaces, users) means newcomers need to learn several submodules to use the client fully.

Used by 5 apps in this directory

Rust
52%
Apache 2.0

cocoindex

Data Engineering · AI Development

11,350

An incremental data indexing engine that keeps AI agent context perpetually fresh by reprocessing only what changed.

View details
87
Repo Health
85
Technical
64
Dependency
Built with
Rust52%
Python48%
Updated yesterday
TypeScript
72%
Other

Epicenter

Knowledge Management · Note Taking · Developer Tools

4,761

A local-first monorepo led by Whispering, an open-source speech-to-text app, built on an MIT toolkit that turns your data into plain Markdown and SQLite files you own instead of a database you rent.

View details
88
Repo Health
90
Technical
68
Dependency
Built with
TypeScript72%
Svelte15%
Updated today
Python
80%
Apache 2.0

headroom

AI Development · Developer Tools

66,835

Compress everything your AI agent reads — tool outputs, logs, RAG chunks, and files — before it reaches the LLM, achieving 60–95% fewer tokens with the same answers.

View details
84
Repo Health
86
Technical
73
Dependency
Built with
Python80%
Rust14%
Updated today
Rust
36%
Apache 2.0

LanceDB

Databases · AI Development

11,190

Open-source, embedded vector database built on the Lance columnar format for fast multimodal search across billions of vectors, backed by Y Combinator (W23).

View details
90
Repo Health
86
Technical
72
Dependency
Built with
Rust36%
HTML30%
Python26%
Updated today
Rust
100%
Other

Meilisearch

Search

59,012

Lightning-fast hybrid search engine with AI-powered semantic and full-text retrieval for modern applications.

View details
90
Repo Health
88
Technical
68
Dependency
Built with
Rust100%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search