计费
获取用量
获取 API 用量分析和成本追踪数据。
GET
/
api
/
v1
/
usage
获取用量
curl --request GET \
--url https://api.example.com/api/v1/usageimport requests
url = "https://api.example.com/api/v1/usage"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/v1/usage', 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/usage",
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/usage"
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/usage")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/usage")
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获取用量分析数据,包括请求次数、令牌消耗、按模式/模型划分的成本明细,以及延迟百分位数。
身份验证
需要 Bearer 令牌。参见身份验证。查询参数
string
起始日期(ISO 8601 格式,例如
"2026-04-01")。string
结束日期(ISO 8601 格式,例如
"2026-04-14")。string
"user"(在团队之外时为默认值)或 "org"(在团队内部时为默认值)。当取值为
"org" 时,响应会反映团队的共享额度池、所有成员的交易记录,以及每一行对应操作者的显示名称
/ 邮箱。需要在当前团队中拥有 viewUsage 权限。请求示例
curl "https://www.hitheo.ai/api/v1/usage?from=2026-04-01&to=2026-04-14&scope=org" \
-H "Authorization: Bearer $THEO_API_KEY"
const usage = await theo.usage({ from: "2026-04-01", to: "2026-04-14", scope: "org" });
响应
返回的用量数据包括:- 总请求数 —— 按天/周/月统计
- 成本明细 —— 按模式、模型和技能划分
- 模型分布 —— 处理你请求的引擎分布情况
- 延迟百分位数 —— p50、p95、p99 响应时间
- 缓存命中率 —— 由语义缓存提供服务的请求所占比例
端点
GET /api/v1/usage
需要通过 Bearer 令牌进行身份验证。参见身份验证。此页面对您有帮助吗?
获取用量
curl --request GET \
--url https://api.example.com/api/v1/usageimport requests
url = "https://api.example.com/api/v1/usage"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/v1/usage', 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/usage",
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/usage"
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/usage")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/usage")
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