> ## 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.

# 通過偏好設置重放提示詞

> 在保存的偏好設置（或未保存的草稿）中運行一個測試用提示詞，而不消耗一次實際的補全調用。

通過路由引擎重放一次測試用提示詞兩次——一次在禁用該偏好設置的情況下（基線），一次在應用該偏好設置的情況下——這樣你就能在保存之前，準確看到你的調整會帶來什麼變化。

兩個路由共享相同的響應結構：

* `POST /api/v1/routing-preferences/{id}/test` — 針對**已保存**的偏好設置進行重放。
* `POST /api/v1/routing-preferences/test` — 針對**未保存的草稿**請求體進行重放（不寫入數據庫）。儀表盤的測試台在每次按鍵時都會調用它。

## 身份驗證

需要攜帶具有 `billing` API 密鑰作用域的 Bearer 令牌。

## 已保存偏好設置的請求體

<ParamField body="prompt" type="string" required>
  要重放的提示詞。最多 4096 個字符。
</ParamField>

<ParamField body="mode" type="string" required>
  要模擬的調用方模式（例如 `"auto"`、`"fast"`、`"think"`）。
</ParamField>

## 草稿請求體

<ParamField body="prompt" type="string" required>
  要重放的提示詞。最多 4096 個字符。
</ParamField>

<ParamField body="mode" type="string" required>
  要模擬的調用方模式。
</ParamField>

<ParamField body="draft" type="object" required>
  未保存的偏好設置數據體。結構與創建請求體相同，但不含 `scope` 和 `is_default`。字段包括：`name`、可選的 `description`、`rules`、`examples`、`confidence_floor_overrides`。其品牌安全校驗、正則表達式編譯校驗以及供應商名稱清理規則，與已持久化的路由完全一致。
</ParamField>

## 請求示例

<CodeGroup>
  ```bash saved theme={null}
  curl -X POST "https://www.hitheo.ai/api/v1/routing-preferences/$PREF_ID/test" \
    -H "Authorization: Bearer $THEO_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{ "prompt": "Compare these two warranty sections", "mode": "auto" }'
  ```

  ```bash draft theme={null}
  curl -X POST https://www.hitheo.ai/api/v1/routing-preferences/test \
    -H "Authorization: Bearer $THEO_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "prompt": "Look at this clause",
      "mode": "auto",
      "draft": {
        "name": "ContractIQ Legal (draft)",
        "rules": [
          { "pattern": "\\b(clause|provision)\\b", "target_mode": "think", "confidence": 0.92 }
        ],
        "examples": []
      }
    }'
  ```

  ```typescript SDK theme={null}
  const diff = await theo.routingPreferences.test(prefId, {
    prompt: "Compare these two warranty sections",
    mode: "auto",
  });
  console.log(diff.baseline.resolved_mode);        // "fast"
  console.log(diff.with_preference.resolved_mode); // "think"
  ```
</CodeGroup>

## 響應

兩個路由返回相同的結構。每個數據塊都與你的調用方在真實補全請求中收到的 `routing` 遙測數據格式一致。

```json theme={null}
{
  "baseline": {
    "requested_mode": "auto",
    "resolved_mode": "fast",
    "promoted": false,
    "reason": "default"
  },
  "with_preference": {
    "requested_mode": "auto",
    "resolved_mode": "think",
    "promoted": true,
    "reason": "customer_preference",
    "explanation": "Routing Studio rule matched: \"clause\".",
    "customer_preference": {
      "rule_matched": "r_a4b8c01x9y",
      "examples_injected": 2
    }
  }
}
```

## 錯誤

* `400 routing_preference_invalid` — 草稿校驗失敗（供應商名稱、無法編譯的正則表達式等）。
* `404 not_found` — 已保存的偏好設置不存在，或調用方無權查看。


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