> ## 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 配置重放一次先前捕获的请求。这对回归测试很有用：将新的路由决策与 provider 响应同原始结果进行比较，以验证配置变更。

除非处于受限环境，否则该请求会对实时下游 provider 重新执行。

## 接口

```http theme={null}
POST /v1/router/replay/{id}/reroute
```

## 认证

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

## 路径参数

<ParamField path="id" type="string" required>
  来自列出重放响应的唯一重放标识符。
</ParamField>

## 响应

<ResponseField name="new_id" type="string">
  分配给新重放请求的标识符。
</ResponseField>

<ResponseField name="decision" type="object">
  当前配置产生的路由决策。

  <Expandable title="属性">
    <ResponseField name="provider" type="string">
      选定的 provider 名称。
    </ResponseField>

    <ResponseField name="model" type="string">
      解析后的模型名称。
    </ResponseField>

    <ResponseField name="recipe" type="string">
      匹配的配方标识符。
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="response" type="object">
  重放请求产生的下游 provider 响应。

  <Expandable title="属性">
    <ResponseField name="id" type="string">
      补全标识符。
    </ResponseField>

    <ResponseField name="choices" type="array">
      生成的候选。
    </ResponseField>

    <ResponseField name="usage" type="object">
      令牌用量摘要。
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://router.example.com/v1/router/replay/req_9f3a2b/reroute" \
    -H "Authorization: Bearer <api-key>"
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "new_id": "req_7a4e1f",
    "decision": {
      "provider": "anthropic",
      "model": "claude-3-5-sonnet-20241022",
      "recipe": "semantic-router"
    },
    "response": {
      "id": "msg_01example",
      "choices": [
        {
          "index": 0,
          "message": {"role": "assistant", "content": "Hello again!"},
          "finish_reason": "stop"
        }
      ],
      "usage": {
        "prompt_tokens": 10,
        "completion_tokens": 8,
        "total_tokens": 18
      }
    }
  }
  ```
</ResponseExample>
