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