Skip to main content
The HF Buckets resource mounts a Hugging Face Bucket at some prefix such as /hf/. Speaks HF’s HTTP API natively (async, streaming, no Python SDK dependency). For credential setup, see HF Buckets Setup.

Install

Config

HfBucketsResource(config) takes an HfBucketsConfig object with the bucket in namespace/bucket-name form plus an optional access token. Both READ and WRITE modes are supported out of the box.

Filesystem Layout

The HF Buckets resource maps bucket object keys to virtual paths under the mount prefix. For example, if bucket your-user/my-data contains:
Then mounting at /hf/ exposes:
Path mapping: virtual /hf/data/file.txt maps to bucket key data/file.txt.

Cache

The HF Buckets resource uses IndexCacheStore with index_ttl = 600 (10 minutes). Directory listings are cached and populate file-size/type entries that stat reads via a fast path, so a readdir followed by per-entry stat calls (which is what ls, FUSE getattr, and most shell commands trigger) costs one HTTP request instead of N.

Example

Shell Commands

The HF Buckets resource supports the full set of shell commands since it operates on real file content (text, binary, JSON, CSV, etc.). Large files benefit from range reads to avoid downloading entire objects.

Read Commands

Text Processing

File Operations

Path Utilities

Compression

Encoding

Data Format Support

Commands with format-specific variants for structured data files: These variants auto-detect the format by extension and convert to tabular text (CSV) for processing.

Use Cases

  • AI agents accessing HF datasets: Mount HF Buckets for agents to read and process datasets stored on the Hub
  • Data pipelines: Read and write HF bucket objects with shell-like commands
  • Sandboxed bucket access: Restrict agent operations to a specific bucket and prefix
  • FUSE mounting: Expose HF Buckets through a virtual FUSE mount for external tools

Scoping a resource to a key prefix

Pass key_prefix: str | None = None to HfBucketsConfig to transparently scope every operation to a subpath of the bucket:
When set, every read/write/list/stat operation is transparently scoped to that bucket subpath. Agents see clean paths like /data/notes.md; the underlying bucket key is users/{user_id}/data/notes.md. Useful for multi-tenant systems. Normalization: leading slashes are stripped and a trailing slash is added automatically. Both None and an empty string are treated as “no prefix.”