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

# aria-router runtime and FFI

> Dispatch requests across multiple Aria model bundles with the aria-router binary, or link libaria-router_ffi into your own service.

`aria-router` sits in front of one or more `aria-engine` instances and routes requests to the right model based on request metadata (model slug, quant, capability). Ship it standalone or embed the FFI shared library.

## Install

Fetch the latest release for your platform:

```bash theme={null}
curl -s https://ariacompute.com/api/download/router-latest \
  | jq -r '.assets[] | select(.name | test("linux-x86_64.tar.gz$")) | .url' \
  | xargs curl -L -o aria-router.tar.gz
tar xf aria-router.tar.gz
```

On the China site the same endpoint mirrors from Gitee at `https://ariacompute.cn/api/download/router-latest`.

## Configure

Provide a routing config that lists each backend engine and the models it serves:

```yaml router.yaml theme={null}
listen: 0.0.0.0:9090
backends:
  - name: gemma-e2b
    url: http://127.0.0.1:8080
    models: [gemma-4-e2b-it_q4]
  - name: qwen-e4b
    url: http://127.0.0.1:8081
    models: [qwen-3-e4b-instruct_q4]
routing:
  policy: model_slug
```

## Run

```bash theme={null}
./aria-router --config ./router.yaml
```

Clients then send requests to `http://<host>:9090/v1/chat/completions` and set the `model` field to a slug listed in the config. `aria-router` forwards the request to the matching backend.

## Embed with libaria-router\_ffi

Each release ships `libaria-router_ffi-<platform>.{so,dylib,dll}` and a C header. Link it from any language with a C ABI.

```c router.c icon=c theme={null}
#include "aria_router.h"

int main(void) {
    AriaRouter *r = aria_router_new_from_file("./router.yaml");
    aria_router_serve(r); // blocks
    aria_router_free(r);
    return 0;
}
```

<Tip>
  Refer to the bundled `include/aria_router.h` for the full FFI surface: reload config at runtime, hot-swap backends, and inspect routing metrics.
</Tip>

## When to use aria-router vs aria-engine directly

* **Single model, single process**: run `aria-engine serve` and point clients at it.
* **Multiple models on one host**: run one `aria-engine` per model and put `aria-router` in front so clients pick a model by slug.
* **Multi-host, multi-tenant**: use `aria-router` as the ingress and configure per-backend health checks and weights.


## Related topics

- [aria-engine runtime and FFI](/sdks/engine-runtime.md)
- [Aria Compute SDKs and client libraries](/sdks/overview.md)
- [GET /api/download/router-latest — latest aria-router release](/api-reference/downloads/router-latest.md)
- [Latest engine, router, agent, and memo releases](/resources/downloads.md)
- [Download Aria model bundles from the registry](/guides/download-models.md)
