资源
密钥模型许可列表
读取或替换某个密钥的模型许可列表(allowlist),用于限制该密钥可运行的 Theo 模型。
GET
/
api
/
v1
/
keys
/
{id}
/
models
密钥模型许可列表
curl --request GET \
--url https://api.example.com/api/v1/keys/{id}/models \
--header 'Content-Type: application/json' \
--data '
{
"model_ids": [
"<string>"
]
}
'import requests
url = "https://api.example.com/api/v1/keys/{id}/models"
payload = { "model_ids": ["<string>"] }
headers = {"Content-Type": "application/json"}
response = requests.get(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({model_ids: ['<string>']})
};
fetch('https://api.example.com/api/v1/keys/{id}/models', 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/keys/{id}/models",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => json_encode([
'model_ids' => [
'<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/keys/{id}/models"
payload := strings.NewReader("{\n \"model_ids\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("GET", 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.get("https://api.example.com/api/v1/keys/{id}/models")
.header("Content-Type", "application/json")
.body("{\n \"model_ids\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/keys/{id}/models")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"model_ids\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"key_id": "<string>",
"inherits_all": true,
"model_ids": [
"<string>"
]
}每个 API 密钥都可以携带一份显式的模型许可列表,其中包含以 Theo 品牌命名的模型 id(例如
theo-1-flash、theo-1-reason)。空许可列表表示该密钥继承所有模型(默认行为)。非空许可列表则会限制该密钥:任何解析到列表之外模型的请求都会被拒绝,返回 403 model_not_allowed——在原生端点和兼容 OpenAI 的端点上均是如此。
身份验证
需要具有billing 权限范围的 API 密钥。调用方必须拥有该密钥(或是被允许管理密钥的团队成员)。
路径参数
string
必填
该 API 密钥的 UUID。
获取许可列表
GET /api/v1/keys/{id}/models
string
该 API 密钥的 UUID。
boolean
当许可列表为空时为
true(表示该密钥可以运行任意模型)。string[]
允许使用的 Theo 模型 id 列表(当
inherits_all 为 true 时为空)。替换许可列表
PUT /api/v1/keys/{id}/models
string[]
必填
要允许的完整 Theo 模型 id 集合(例如
["theo-1-reason", "theo-1-code"])。传入空数组可将该密钥重置为继承所有模型。未知的 id 会被拒绝。示例
curl -X PUT https://www.hitheo.ai/api/v1/keys/KEY_ID/models \
-H "Authorization: Bearer $THEO_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "model_ids": ["theo-1-reason", "theo-1-code"] }'
// Model binding is set via the dashboard or this REST endpoint.
// A request that resolves to a model outside the list throws TheoError(403, "model_not_allowed").
{ "key_id": "KEY_ID", "inherits_all": false, "model_ids": ["theo-1-reason", "theo-1-code"] }
此页面对您有帮助吗?
密钥模型许可列表
curl --request GET \
--url https://api.example.com/api/v1/keys/{id}/models \
--header 'Content-Type: application/json' \
--data '
{
"model_ids": [
"<string>"
]
}
'import requests
url = "https://api.example.com/api/v1/keys/{id}/models"
payload = { "model_ids": ["<string>"] }
headers = {"Content-Type": "application/json"}
response = requests.get(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({model_ids: ['<string>']})
};
fetch('https://api.example.com/api/v1/keys/{id}/models', 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/keys/{id}/models",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => json_encode([
'model_ids' => [
'<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/keys/{id}/models"
payload := strings.NewReader("{\n \"model_ids\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("GET", 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.get("https://api.example.com/api/v1/keys/{id}/models")
.header("Content-Type", "application/json")
.body("{\n \"model_ids\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/keys/{id}/models")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"model_ids\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"key_id": "<string>",
"inherits_all": true,
"model_ids": [
"<string>"
]
}