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

# 查看密钥的有效路由

> 返回当前实际驱动该 API 密钥补全请求的路由规则。

返回将实际驱动指定密钥补全请求的 Routing Studio 快照,并附带一个 `source` 枚举,便于仪表盘向客户说明该规则的来源。这四种来源对应解析层级:

* `key` — 针对该密钥的规则(可能是隐藏偏好,也可能是显式绑定到该密钥的共享偏好)。
* `org_default` — 没有针对该密钥的绑定;回退到当前组织的默认偏好。
* `user_default` — 既没有针对该密钥的规则,也没有组织默认偏好;回退到用户的个人默认偏好。
* `none` — 没有任何规则生效;路由引擎按未修改的方式运行。

## 身份验证

需要具备 `billing` API 密钥作用域的 Bearer 令牌,且对该密钥拥有访问权限。

## 请求示例

<CodeGroup>
  ```bash curl theme={null}
  curl https://www.hitheo.ai/api/v1/keys/{id}/effective-routing \
    -H "Authorization: Bearer $THEO_API_KEY"
  ```

  ```typescript SDK theme={null}
  const eff = await theo.routingRules.effective(keyId);
  console.log(eff.source);             // "key" | "org_default" | "user_default" | "none"
  console.log(eff.preference_name);    // "This key's rules" | "ACME Legal Default" | null
  ```
</CodeGroup>

## 响应

```json theme={null}
{
  "key_id": "key_abc",
  "source": "key",
  "is_per_key": true,
  "preference_id": "1f4f2c1a-22ce-4b07-9c0b-9c4f4b9b1d2e",
  "preference_name": "This key's rules",
  "rules": [
    {
      "id": "r_a4b8c01x9y",
      "pattern": "\\b(clause|provision|indemnity|warranty)\\b",
      "target_mode": "think",
      "confidence": 0.92,
      "description": "Contract terms get the analytical engine."
    }
  ],
  "examples": [{ "prompt": "Look at this clause", "expected_mode": "think" }],
  "confidence_floor_overrides": { "think": 0.65 }
}
```

* `is_per_key: true` — 当前生效的来源是该密钥的隐藏专属偏好(即通过 [`/api/v1/keys/{id}/routing-rules`](/api-reference/routing-preferences/key-routing-rules) 保存的规则)。
* `preference_name` — 便于展示的名称。隐藏的密钥专属偏好会渲染为 `"This key's rules"`,以确保 `__key:` 标记不会泄露到面向客户的界面上。
* 当 `source` 为 `"none"` 时,`preference_id` 和 `preference_name` 均为 `null`,规则数组和示例数组均为空。

## 错误

* `404 not_found` — 密钥不存在、已被撤销,或调用者无权访问。


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