> ## 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 获取成本聚合数据，按用户、模型、入口点与时间段拆分。

成本接口返回来自咏唱引擎 ROUTER 的聚合推理成本指标。可用它分析在所选时间窗口内，跨用户、模型与入口点的支出模式。

结果可按你通过查询参数选择的维度分组。所有已认证调用者均可访问此接口。

## 接口

```http theme={null}
GET /v1/router/cost
```

## 认证

使用会话 Cookie 认证，或携带 `Authorization: Bearer <api-key>`。

## 查询参数

<ParamField query="from" type="string">
  时间范围起点，ISO 8601 格式。
</ParamField>

<ParamField query="to" type="string">
  时间范围终点，ISO 8601 格式。
</ParamField>

<ParamField query="group_by" type="string">
  逗号分隔的分组维度。支持的取值：`user`、`model`、`entrypoint`。
</ParamField>

## 响应

<ResponseField name="items" type="array">
  成本聚合行。

  <Expandable title="items">
    <ResponseField name="user" type="string">
      用户标识符，按用户分组时存在。
    </ResponseField>

    <ResponseField name="model" type="string">
      模型标识符，按模型分组时存在。
    </ResponseField>

    <ResponseField name="entrypoint" type="string">
      入口点标识符，按入口点分组时存在。
    </ResponseField>

    <ResponseField name="cost_usd" type="number">
      以美元计的聚合成本。
    </ResponseField>

    <ResponseField name="tokens" type="integer">
      该分组消耗的令牌总数。
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET "https://router.example.com/v1/router/cost?from=2024-06-01T00:00:00Z&to=2024-06-30T23:59:59Z&group_by=user,model" \
    -H "Authorization: Bearer <api-key>"
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "items": [
      {
        "user": "user_a",
        "model": "gpt-4o",
        "cost_usd": 12.45,
        "tokens": 41500
      },
      {
        "user": "user_a",
        "model": "claude-3-5-sonnet-20241022",
        "cost_usd": 8.20,
        "tokens": 27300
      }
    ]
  }
  ```
</ResponseExample>
