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

# ROUTER 决策路由

ROUTER 决策路由是咏唱引擎的统一推理网关产品。它用一组**决策层**为每次请求择路：**语义**（YAML v0.3）做 chat 路由，**轻量 Agent** 在进程内跑工具循环，**afm-d** 经 aria-engine 做 System One Choice，然后在硬约束下转发到共享 providers。一次请求只走**一轨**。网关数据面实现标准 OpenAI `/v1/chat/completions` 与 `/v1/models`，现有 SDK 不用改动就能接入。

## 决策层

ROUTER 把请求在若干并列决策层之间择路。择路结果（层、决策、模型）随响应头回传，方便观测：

| 层 | 含义 | 入口示例 |
| - | - | - |
| **语义 semantic** | 依据 YAML v0.3 配方用路由信号匹配 chat 请求 | `ariacompute/semantic-auto` |
| **轻量 Agent** | 进程内固定工具 + 限定 turns 的工具循环 | `ariacompute/agent-auto` |
| **afm-d** | 经 [aria-engine](/sdks/engine-runtime) 的 System One Choice 选型 | `ariacompute/afm-d-auto` |

## 路由配置（YAML v0.3）

入口、provider 与路由规则都写在一份 YAML v0.3 配置里，ROUTER 会动态重新加载。各块含义如下：

| 块 | 含义 |
| - | - |
| `listeners` | 数据面绑定 |
| `providers` | 模型 / `backend_refs` |
| `entrypoints` | 虚拟模型 → `router: semantic\|agent\|afm-d` + `recipe` |
| `recipes` | 语义 `routing.*`、agent `agent.*`、afm-d `afm-d.*` |
| `global` | 认证 / 密钥路径（可选） |

## 黄金入口

常用虚拟入口（gold entrypoints）内置了配方，可以直接用：

* `ariacompute/semantic-auto`
* `ariacompute/agent-auto`
* `ariacompute/afm-d-auto`

**afm-d** 层需通过 `AFM_ENGINE_URL` 指向已运行的 [aria-engine](/sdks/engine-runtime)。一次请求只走一轨，层与决策随 `x-aria-router-*` 响应头回传。

```bash theme={null}
curl -s http://127.0.0.1:8899/v1/chat/completions \
  -H 'content-type: application/json' \
  -H 'Authorization: Bearer sk-aria_your_router_api_key' \
  -d '{
    "model": "ariacompute/semantic-auto",
    "messages": [{"role": "user", "content": "你好"}]
  }'
```

## 约束与治理

共享 provider 的模型与硬约束（成本、延迟、能力）在请求时求值。管理面覆盖认证、路由配置、成本追踪与密钥管理，接口都在 `/v1/router/*` 下；用 `AFM_ENGINE_URL` 可以把 afm-d 接入 System One。

## 如何运行

* **[ROUTER 运行时](/sdks/router-runtime)**：自托管 `aria-router` CLI / FFI，数据面默认 `--bind 127.0.0.1:8899`，管理面 `--mgmt-bind 127.0.0.1:8090`。
* **[AGENT 运行时](/sdks/agent-runtime)**：只需要工具调用与规划的 Agent 脚手架时，改用 `aria-agent`。
* 相关：[ROUTER 简介](/api-reference/router/introduction)、[AFM 基础模型](/concepts/models)。

## 另见

* [演练场体验](/guides/playground)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.