# Download models from the command line

The `soundbox` command downloads, tries and removes models without the server
or the app running. The **Models** page in the app uses the same catalogue and
the same downloader.

## Before you begin

- Build Mirli and install the audio.cpp runtime, as described in
  [Run Mirli from source](https://mirli.app/docs/install/index.md).
- If your data folder is not in the default place, set `MIRLI_DATA_DIR`.
  These commands do not read the server's `--data-dir` flag.

## Download and try a model

1. List the catalogue:

   ```bash
   soundbox list
   ```

   Each line shows a model's id and whether it is downloaded.

2. Download a model's weights:

   ```bash
   soundbox pull <MODEL_ID>
   ```

   Replace `<MODEL_ID>` with an id from the list, such as
   `audiocpp-stable-audio-3-sfx`. Mirli downloads only the model's own files,
   not the whole Hugging Face repository.

3. Render a sound to check the model works:

   ```bash
   soundbox run <MODEL_ID> "heavy wooden door slamming" --out test.wav
   ```

   A file named `test.wav` appears in the current folder.

Each model shows its licence before you download it. Some licences allow open
use of the weights but forbid selling what the model makes.

## Remove a model

To free the disk space a model uses, delete its weights:

```bash
soundbox rm <MODEL_ID>
```

## Download a gated model

None of the audio models is gated. The optional Stable Diffusion 3.5 Medium
artwork model is, and so is any custom model you point at a gated
repository. If a download fails with 401 or 403, the repository is gated and
Mirli needs your Hugging Face token. Mirli cannot accept the terms for you.

1. Sign in to Hugging Face and accept the licence on the model's page, such
   as `huggingface.co/stabilityai/stable-diffusion-3.5-medium`.
2. Create a token with **read** access at
   <https://huggingface.co/settings/tokens>.
3. In the app, go to **Settings > Models & engines > Hugging Face token** and
   paste the token. Alternatively, set `HF_TOKEN` in the server's
   environment.
4. Run `soundbox pull <MODEL_ID>` again.

The server stores the token in its `settings.json` and never returns it over
the API.

## Resume an interrupted download

If a download stops partway, the partial file is kept.

1. Run `soundbox pull <MODEL_ID>` again, or on the **Models** page, click
   **Repair** on the model.

   The download continues from where it stopped.

For what Mirli does at each stage of a download, see
[Download behaviour](https://mirli.app/docs/install-cli/index.md#download-behaviour).

## What's next

- [Add your own model](https://mirli.app/docs/audiocpp-models/index.md)
- [Configuration](https://mirli.app/docs/install-config/index.md)
- [Command-line reference](https://mirli.app/docs/install-cli/index.md)
