> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mirage.strukto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# HF Models

> Mount a Hugging Face Model repo as a Mirage filesystem in TypeScript.

`HfModelsResource` mounts a [Hugging Face Model](https://huggingface.co/models)
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](/python/resource/hf_models) and
returns identical results.

For credential setup, see [HF Models Setup](/home/setup/hf_models).

<Note>
  Node only. The backend uses the native [opendal](https://www.npmjs.com/package/opendal)
  binding, which does not run in the browser.
</Note>

## Node

```bash theme={null}
pnpm add @struktoai/mirage-node
```

```ts theme={null}
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:

```text theme={null}
/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](/typescript/setup/hf_buckets#shell-commands).
