Routing Studio
记录一次路由纠正
提交 playground 中的“重新路由(Reroute)”操作,帮助 Theo 了解全局分类器在哪里出错。
POST
/
api
/
v1
/
routing-preferences
/
corrections
记录一次路由纠正
curl --request POST \
--url https://api.example.com/api/v1/routing-preferences/corrections \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"expected_mode": "<string>",
"source_message_id": "<string>"
}
'import requests
url = "https://api.example.com/api/v1/routing-preferences/corrections"
payload = {
"prompt": "<string>",
"expected_mode": "<string>",
"source_message_id": "<string>"
}
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({prompt: '<string>', expected_mode: '<string>', source_message_id: '<string>'})
};
fetch('https://api.example.com/api/v1/routing-preferences/corrections', 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/corrections",
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([
'prompt' => '<string>',
'expected_mode' => '<string>',
'source_message_id' => '<string>'
]),
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/corrections"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"expected_mode\": \"<string>\",\n \"source_message_id\": \"<string>\"\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/corrections")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"expected_mode\": \"<string>\",\n \"source_message_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/routing-preferences/corrections")
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 \"prompt\": \"<string>\",\n \"expected_mode\": \"<string>\",\n \"source_message_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body记录一次路由纠正——即开发者对已解析的模式表示不认同,并提供了他们期望的模式的一次对话轮次。Theo 会为每个调用方保留最近 30 天的纠正记录,并按
当
expected_mode 对其进行聚类;一旦某个聚类超过阈值,playground 就会显示一条“我发现了一个规律”的提示,开发者可以据此让 Theo 建议一条规则,该规则由该聚类推导而来。
纠正记录的作用域为个人或团队级别(与调用方当前激活的组织上下文一致),因此个人的纠正记录不会触发团队级别的建议提示条。
身份验证
需要携带具备billing API 密钥作用域的 Bearer 令牌。该接口是幂等的:相同的 Idempotency-Key 请求头会重放相同的响应。
请求体
string
必填
产生了非预期模式的提示词。长度为 1–4096 个字符。会在服务层做供应商名称脱敏处理。
string
必填
开发者期望的 Theo 模式(例如
"think"、"image"、"insurance_quote")。string
可选参数,指该纠正所关联对话轮次的消息 id。长度不超过 128 个字符。
请求示例
curl
curl -X POST https://www.hitheo.ai/api/v1/routing-preferences/corrections \
-H "Authorization: Bearer $THEO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Look at this indemnity clause",
"expected_mode": "think"
}'
响应
{
"id": "corr_abc123",
"ok": true,
"cluster_threshold": 3,
"pattern_suggestion_available": true,
"pattern_expected_mode": "think",
"pattern_count": 3
}
pattern_suggestion_available 为 true 时,可调用 POST /api/v1/routing-preferences/suggest-rule,并传入匹配的 expected_mode,即可获得一条由该聚类推导出的确定性正则表达式。
错误
400 routing_correction_invalid—— 通用的请求结构校验失败。400 routing_correction_vendor_name—— 提示词中提及了上游供应商名称(如 Claude、OpenAI 等)。400 routing_correction_invalid_mode——expected_mode不是已知的 Theo 模式。
此页面对您有帮助吗?
记录一次路由纠正
curl --request POST \
--url https://api.example.com/api/v1/routing-preferences/corrections \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"expected_mode": "<string>",
"source_message_id": "<string>"
}
'import requests
url = "https://api.example.com/api/v1/routing-preferences/corrections"
payload = {
"prompt": "<string>",
"expected_mode": "<string>",
"source_message_id": "<string>"
}
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({prompt: '<string>', expected_mode: '<string>', source_message_id: '<string>'})
};
fetch('https://api.example.com/api/v1/routing-preferences/corrections', 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/corrections",
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([
'prompt' => '<string>',
'expected_mode' => '<string>',
'source_message_id' => '<string>'
]),
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/corrections"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"expected_mode\": \"<string>\",\n \"source_message_id\": \"<string>\"\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/corrections")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"expected_mode\": \"<string>\",\n \"source_message_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/routing-preferences/corrections")
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 \"prompt\": \"<string>\",\n \"expected_mode\": \"<string>\",\n \"source_message_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body