Skip to main content
HfModelsResource mounts a Hugging Face Model repo at a prefix such as /m/. You can inspect configs, tokenizers, and READMEs without downloading the weights, weights stream only when you actually cat them. The TypeScript backend mirrors the Python one and returns identical results. For credential setup, see HF Models Setup.
Node only. The backend uses the native opendal binding, which does not run in the browser.

Node

pnpm add @struktoai/mirage-node
import { HfModelsResource, MountMode, Workspace } from '@struktoai/mirage-node'

const model = new HfModelsResource({
  repoId: 'sapientinc/HRM-Text-1B', // "namespace/model-name"
  token: process.env.HF_TOKEN, // optional for public repos
  // Optional:
  // endpoint: 'https://huggingface.co',
  // revision: 'main',
})

const ws = new Workspace({ '/m/': model }, { mode: MountMode.READ })

// ls is cheap: one HTTP list call
console.log((await ws.execute('ls -lh /m/')).stdoutText)

// Read the config (small, fast)
console.log((await ws.execute('cat /m/config.json')).stdoutText)

// Stat the weights without downloading them
console.log((await ws.execute('stat /m/model.safetensors')).stdoutText)

Filesystem Layout

Maps model repo files (config, tokenizer, weights, etc.) to virtual paths. For example, sapientinc/HRM-Text-1B mounted at /m/ exposes:
/m/
  README.md
  config.json
  tokenizer.json
  tokenizer_config.json
  model.safetensors        โ† never downloaded unless you cat it

Shell Commands

Same set as HF Buckets.