# Use your own audio.cpp build

This guide points Mirli at an audio.cpp binary you built or downloaded, such
as a ROCm build or a CUDA build for Linux, and forces the backend it runs
with.

## Before you begin

- Get an `audiocpp_cli` for your system from one of these sources:

  | Source | How |
  |---|---|
  | Prebuilt packages | The [audio.cpp releases page](https://github.com/0xShug0/audio.cpp/releases) |
  | Homebrew on macOS | `brew tap 0xShug0/audio-cpp`, then `brew install audio-cpp` |
  | Source, for Linux with an NVIDIA card | `scripts/build_linux.sh --backend cuda --target audiocpp_cli` in audio.cpp's repository. Upstream's Linux packages include no CUDA `audiocpp_cli`. |

  The CUDA [Docker image](https://mirli.app/docs/install-docker/index.md) is another way to get CUDA on
  Linux.

## Point Mirli at the binary

1. Set `MIRLI_AUDIOCPP_BIN` to the binary's absolute path in the server's
   environment:

   ```bash title="macOS / Linux"
   export MIRLI_AUDIOCPP_BIN=/opt/audiocpp/audiocpp_cli
   ```

   ```powershell title="Windows"
   $env:MIRLI_AUDIOCPP_BIN = "C:\audiocpp\audiocpp_cli.exe"
   ```

   Alternatively, put `audiocpp_cli` on your `PATH`. A Homebrew install is
   found without either.

2. Check which binary Mirli resolved:

   ```bash
   soundbox model status audiocpp
   ```

   It reports `external (env)` for the variable, or `external (PATH)` for a
   binary on `PATH`.

3. Restart the server.

The prompt-assistant engine works the same way through
`MIRLI_LLAMA_SERVER_BIN`; check it with `soundbox model status llm`. The
order Mirli searches in is listed in
[Resolution order](https://mirli.app/docs/install-engines/index.md#resolution-order).

## Choose a backend

Mirli detects a backend and falls back to CPU. To override the guess, or to
compare backends:

1. Set `MIRLI_AUDIOCPP_BACKEND` in the server's environment:

   ```bash title="macOS / Linux"
   export MIRLI_AUDIOCPP_BACKEND=cuda
   ```

   ```powershell title="Windows"
   $env:MIRLI_AUDIOCPP_BACKEND = "cuda"
   ```

   The values are `cpu`, `cuda`, `vulkan`, `metal`, `hip` and `best`.

2. Restart the server.
3. Check the `device` field of `GET /api/health`. It shows the backend in
   force.

`soundbox model status audiocpp` shows the detected backend and ignores this
variable. The variable does not change which build is downloaded; for that,
pass `--backend` to `soundbox model install audiocpp`.

## What's next

- [About audio.cpp](https://mirli.app/docs/audiocpp/index.md)
- [Engines and GPU backends](https://mirli.app/docs/install-engines/index.md)
- [Add your own model](https://mirli.app/docs/audiocpp-models/index.md)
