> ## 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 的数据面与管理面认证。推理使用 Bearer API 密钥，管理路由使用会话 Cookie 或 X-Api-Key。

咏唱引擎 ROUTER 有两套认证面。**数据面**使用 OpenAI 风格的 `Authorization: Bearer <router-key>` 头。**管理面**接受来自登录的会话 Cookie、`X-Api-Key` 头，或 `Authorization: Bearer <session-token>` 头。

永远无需认证的公开路由包括 `/health`、`/v1/router/version`、`/v1/router/auth/register`、`/v1/router/auth/register-status`、`/v1/router/auth/login` 与 `/v1/router/auth/oauth/callback`。

## 数据面认证

推理接口（`/v1/chat/completions` 与 `/v1/models`）需要 ROUTER API 密钥。在 `Authorization` 头中以 Bearer 令牌的形式携带它。

```bash theme={null}
curl -H 'Authorization: Bearer sk-aria_...' \
  http://<router-host>:8080/v1/chat/completions
```

可通过管理面在 `/v1/router/keys` 创建与吊销 Router 密钥。

## 管理面认证

`/v1/router/*` 下的管理路由支持三种认证方式：

1. **会话 Cookie**：通过 `/v1/router/auth/login` 登录，收到包含 `aria_router_session` 的 `Set-Cookie` 响应。在后续请求中携带该 Cookie。
2. **X-Api-Key 头**：在 `X-Api-Key` 头中携带你的 API 密钥。
3. **Authorization: Bearer**：携带带非密钥前缀的有效会话令牌（密钥以 `sk-aria_` 或 `sk-bf-` 开头；会话令牌为十六进制字符串，会被解析为用户而非 API 密钥）。

使用会话 Cookie 的示例：

```bash theme={null}
curl -b cookies.txt http://<router-host>:8080/v1/router/auth/me
```

使用 `X-Api-Key` 的示例：

```bash theme={null}
curl -H 'X-Api-Key: $ARIA_ROUTER_KEY' http://<router-host>:8080/v1/router/keys
```

如果 Router 尚未配置本地用户，管理面是开放的（无需认证），以便你执行初始设置。
