Routing Studio
創建路由偏好
創建一個新的 Routing Studio 偏好設置。
POST
/
api
/
v1
/
routing-preferences
創建路由偏好
curl --request POST \
--url https://api.example.com/api/v1/routing-preferences \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"description": "<string>",
"rules": [
{}
],
"examples": [
{}
],
"confidence_floor_overrides": {},
"scope": "<string>",
"is_default": true
}
'import requests
url = "https://api.example.com/api/v1/routing-preferences"
payload = {
"name": "<string>",
"description": "<string>",
"rules": [{}],
"examples": [{}],
"confidence_floor_overrides": {},
"scope": "<string>",
"is_default": True
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
description: '<string>',
rules: [{}],
examples: [{}],
confidence_floor_overrides: {},
scope: '<string>',
is_default: true
})
};
fetch('https://api.example.com/api/v1/routing-preferences', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v1/routing-preferences",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'description' => '<string>',
'rules' => [
[
]
],
'examples' => [
[
]
],
'confidence_floor_overrides' => [
],
'scope' => '<string>',
'is_default' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/routing-preferences"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"rules\": [\n {}\n ],\n \"examples\": [\n {}\n ],\n \"confidence_floor_overrides\": {},\n \"scope\": \"<string>\",\n \"is_default\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/v1/routing-preferences")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"rules\": [\n {}\n ],\n \"examples\": [\n {}\n ],\n \"confidence_floor_overrides\": {},\n \"scope\": \"<string>\",\n \"is_default\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/routing-preferences")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"rules\": [\n {}\n ],\n \"examples\": [\n {}\n ],\n \"confidence_floor_overrides\": {},\n \"scope\": \"<string>\",\n \"is_default\": true\n}"
response = http.request(request)
puts response.read_body創建一個新的 Routing Studio 偏好設置。該接口具有冪等性——使用相同的
Idempotency-Key 請求頭會重放相同的響應。
創建偏好設置不會自動將其綁定到某個密鑰。請使用 PUT /api/v1/keys//routing-preference 讓某個密鑰選用它,或通過 PUT /api/v1/keys//routing-rules 直接在密鑰上編輯規則。
身份驗證
需要攜帶具備billing API 密鑰作用域的 Bearer 令牌。
請求體
string
必填
偏好設置名稱。長度為 1–128 個字符。不得包含上游供應商名稱(如 Claude、OpenAI、Anthropic、Gemini、fal.ai 等)。
string
自由文本描述,最多 512 個字符。
object[]
最多 50 條關鍵詞/正則規則。每條規則包含
pattern(ECMAScript 正則表達式源碼,≤512 字符)、target_mode(一個 Theo 模式)、可選的 target_engine(Theo 品牌化的引擎 id)、confidence(服務端會將其限制在 [0.5, 0.99] 範圍內)以及可選的 description。object[]
最多 30 條少樣本(few-shot)示例,會被注入分類器的系統提示詞中。每條示例包含
prompt(≤1024 字符)、expected_mode,以及可選的 expected_engine。object
按模式覆蓋全局
0.85 的晉升閾值下限。取值會被限制在 [0.5, 0.99] 範圍內。string
"personal"(默認)或 "team"。團隊作用域需要一個處於激活狀態的組織,並且需要具備 manageWebhooks 權限。boolean
將此偏好設置標記為其所屬作用域的默認項。每個作用域最多隻能有一個默認項。
請求示例
curl -X POST https://www.hitheo.ai/api/v1/routing-preferences \
-H "Authorization: Bearer $THEO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "ContractIQ Legal",
"description": "Contract terms get the analytical engine.",
"rules": [
{
"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" }
]
}'
const pref = await theo.routingPreferences.create({
name: "ContractIQ Legal",
description: "Contract terms get the analytical engine.",
rules: [
{
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" }],
});
錯誤
400 routing_preference_invalid—— 標籤或規則中包含供應商名稱、正則表達式無法編譯、引擎未知,或規則/示例數量超出上限。400 org_required——scope: "team"但沒有處於激活狀態的組織。403 missing_scope—— API 密鑰缺少billing作用域。409 conflict—— 該作用域下已存在is_default: true的偏好設置。
這個頁面有幫助嗎?
創建路由偏好
curl --request POST \
--url https://api.example.com/api/v1/routing-preferences \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"description": "<string>",
"rules": [
{}
],
"examples": [
{}
],
"confidence_floor_overrides": {},
"scope": "<string>",
"is_default": true
}
'import requests
url = "https://api.example.com/api/v1/routing-preferences"
payload = {
"name": "<string>",
"description": "<string>",
"rules": [{}],
"examples": [{}],
"confidence_floor_overrides": {},
"scope": "<string>",
"is_default": True
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
description: '<string>',
rules: [{}],
examples: [{}],
confidence_floor_overrides: {},
scope: '<string>',
is_default: true
})
};
fetch('https://api.example.com/api/v1/routing-preferences', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v1/routing-preferences",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'description' => '<string>',
'rules' => [
[
]
],
'examples' => [
[
]
],
'confidence_floor_overrides' => [
],
'scope' => '<string>',
'is_default' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/routing-preferences"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"rules\": [\n {}\n ],\n \"examples\": [\n {}\n ],\n \"confidence_floor_overrides\": {},\n \"scope\": \"<string>\",\n \"is_default\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/v1/routing-preferences")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"rules\": [\n {}\n ],\n \"examples\": [\n {}\n ],\n \"confidence_floor_overrides\": {},\n \"scope\": \"<string>\",\n \"is_default\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/routing-preferences")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"rules\": [\n {}\n ],\n \"examples\": [\n {}\n ],\n \"confidence_floor_overrides\": {},\n \"scope\": \"<string>\",\n \"is_default\": true\n}"
response = http.request(request)
puts response.read_body