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

# Models

> Find, download, pause, resume, load, and remove models

Electron has the richest `models` namespace of any SDK. Download control exists only here.

## What is available

```ts theme={null}
const models = await RunAnywhere.models.list(filter?);
const model = await RunAnywhere.models.get('qwen3-0.6b');
await RunAnywhere.models.refresh(options?);
```

## Downloading

```ts theme={null}
for await (const event of RunAnywhere.models.download('qwen3-0.6b')) {
  if (event.type === 'progress') {
    win.setProgressBar(event.fraction ?? 0)
  }
}
```

On a desktop, models are the largest thing your app will ever fetch. Put the progress on the
taskbar or dock icon with `setProgressBar` as well as in the window.

### Pause, resume, cancel

```ts theme={null}
await RunAnywhere.models.pause('qwen3-0.6b')
await RunAnywhere.models.resume('qwen3-0.6b')
await RunAnywhere.models.cancel('qwen3-0.6b')
```

None of these exist on any other SDK. They are what makes a multi-gigabyte download survive a
user closing the laptop lid.

### After a crash

```ts theme={null}
const stalled = await RunAnywhere.models.interrupted() // string[]

for (const id of stalled) {
  if (await RunAnywhere.models.isResumable(id)) {
    // offer to continue rather than restart
  }
}
```

Call `interrupted()` on launch. It is the difference between a user losing a 4GB download and
not noticing it stopped.

## Loading

```ts theme={null}
const loaded = await RunAnywhere.models.load('qwen3-0.6b')

const tuned = await RunAnywhere.models.load('qwen3-0.6b', {
  contextLength: 8192,
  threads: 8,
})
```

| Field                | Meaning                                  |
| -------------------- | ---------------------------------------- |
| `backendPreferences` | Ordered preference; each can be required |
| `contextLength`      | Context window to allocate               |
| `threads`            | CPU threads                              |
| `forceReload`        | Reload even if already resident          |
| `framework`          | Pin to one backend                       |
| `useGpu`             | Request GPU execution                    |

A desktop has real headroom, so a larger `contextLength` and higher `threads` are reasonable
here in a way they are not on a phone.

### Which backend will serve it

```ts theme={null}
const capabilities = await RunAnywhere.capabilities()
console.log(capabilities.backends)
```

Generated from packaging facts about the linked addon. On `win32-arm64` you will see `qhexrt`
alone, with no CPU fallback behind it; on `win32-x64` and `darwin-arm64` you will see
llamacpp, onnx, and sherpa.

## Unloading

```ts theme={null}
await RunAnywhere.models.unload('qwen3-0.6b')
```

## Residency policy

```ts theme={null}
import { ResidencyPolicy } from '@runanywhere/electron'
```

`ResidencyPolicy`, `ResidencyDecision`, `ResidencySlots`, and `ResidentModel` control which
models stay loaded when memory is contended. On a desktop app with a chat model and a voice
session in play, this is what stops one evicting the other on every turn.

## Deleting, with a dry run

```ts theme={null}
const plan = await RunAnywhere.storage.deletePlan()
// show the user exactly what would go
await RunAnywhere.storage.delete(request)
```

`deletePlan` exists only on Electron. Show it before deleting, rather than deleting and
reporting afterwards.

```ts theme={null}
await RunAnywhere.models.delete('qwen3-0.6b')
await RunAnywhere.models.unregister('qwen3-0.6b')
await RunAnywhere.storage.clearCache()
await RunAnywhere.storage.cleanTempFiles()
```

### Will it fit

```ts theme={null}
const availability = await RunAnywhere.storage.availability(request)
```

Ask before starting a download rather than failing partway.

## Registering your own model

```ts theme={null}
const info = await RunAnywhere.models.register(registration)
```

### Gated repositories

```ts theme={null}
await RunAnywhere.setHfToken(token)
```

`null` falls back to the environment lookup the core resolves (`HF_TOKEN`, then
`$HF_TOKEN_PATH`, then `$HF_HOME/token`, then `~/.cache/huggingface/token`), so `hf auth login`
is honoured. An empty string clears the token and disables that fallback. The token lives in
the platform secure store and is re-applied on the next `initialize()`.

## Renderer access

Everything above works identically through `window.runanywhere` in the renderer, so a settings
page can drive downloads without the main process proxying each call:

```ts theme={null}
for await (const event of window.runanywhere.models.download(id)) {
  if (event.type === 'progress') bar.value = event.fraction ?? 0
}
```
