資源
密鑰模型許可列表
讀取或替換某個密鑰的模型許可列表(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>"
]
}