查询用量
curl --request GET \
--url https://kaienapi.com/v1/dashboard/billing/usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://kaienapi.com/v1/dashboard/billing/usage"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://kaienapi.com/v1/dashboard/billing/usage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://kaienapi.com/v1/dashboard/billing/usage"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}查询账号在指定日期范围内的 API 用量。
查询范围
start_date 和 end_date 使用 YYYY-MM-DD。显式传入日期范围,账单页、报表页和定时同步任务都能得到稳定结果。
读取结果
返回结构按 OpenAI Dashboard Usage 风格兼容,字段可能包含日期、请求量、消耗金额或分项统计。金额展示保留接口返回的精度,不要在前端强制压成两位小数。
错误定位
- 返回为空:确认日期范围是否覆盖请求发生日期。
- 401:检查 Authorization 是否使用当前账号的 API Key。
- 金额和页面预估不同:以接口返回的已结算用量为准,预估值只用于提交前展示。
GET
/
v1
/
dashboard
/
billing
/
usage
查询用量
curl --request GET \
--url https://kaienapi.com/v1/dashboard/billing/usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://kaienapi.com/v1/dashboard/billing/usage"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://kaienapi.com/v1/dashboard/billing/usage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://kaienapi.com/v1/dashboard/billing/usage"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}