护栏
列出预设模板
仪表盘在护栏空状态下提供的只读蓝图。
GET
/
api
/
v1
/
guardrail-policies
/
presets
列出预设模板
curl --request GET \
--url https://api.example.com/api/v1/guardrail-policies/presetsimport requests
url = "https://api.example.com/api/v1/guardrail-policies/presets"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/v1/guardrail-policies/presets', 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/guardrail-policies/presets",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/guardrail-policies/presets"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/api/v1/guardrail-policies/presets")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/guardrail-policies/presets")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body返回四个精心策划的预设模板:
pii-safe、strict-json、cost-conscious 和 enterprise-default。预设是只读的——应用某个预设只是一次普通的创建策略调用,只不过用该预设的 rules 数组作为初始值。
根据严格的显式启用(opt-in)约定,获取或应用预设永远不会自动将其绑定到某个 API 密钥。
身份验证
需要携带具备billing API 密钥权限范围的 Bearer 令牌。
请求示例
curl https://www.hitheo.ai/api/v1/guardrail-policies/presets \
-H "Authorization: Bearer $THEO_API_KEY"
const presets = await theo.guardrails.presets.list();
const enterprise = presets.find((p) => p.id === "enterprise-default")!;
const policy = await theo.guardrails.policies.create({
name: "Production defaults",
rules: enterprise.rules,
});
响应
每个预设都包含id、name、tagline、description 和 rules。目前提供的四个预设分别是:
- pii-safe —— 对输入进行 PII(个人身份信息)遮蔽。
- strict-json —— 提示注入拒绝 + 输出端 JSON 修复。
- cost-conscious —— 对输入和输出两个阶段都设置硬性长度上限(约 4K 令牌)。
- enterprise-default —— 完整组合:PII 遮蔽 + 注入拒绝 + 长度上限 + 不当言论标记 + JSON 修复。
{
"presets": [
{
"id": "pii-safe",
"name": "PII-safe",
"tagline": "Redact email / phone / SSN / credit-card / DL before the model sees them.",
"description": "Sensible default for compliance-sensitive teams. ...",
"rules": [
{
"guardrail_id": "pii_redactor",
"phase": "input",
"verdict": "redact",
"config": {},
"enabled": true,
"rule_order": 0
}
]
}
]
}
此页面对您有帮助吗?
列出预设模板
curl --request GET \
--url https://api.example.com/api/v1/guardrail-policies/presetsimport requests
url = "https://api.example.com/api/v1/guardrail-policies/presets"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/v1/guardrail-policies/presets', 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/guardrail-policies/presets",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/guardrail-policies/presets"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/api/v1/guardrail-policies/presets")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/guardrail-policies/presets")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body