Skip to content

查询:令牌用量

简洁描述:查询当前 API key 的总令牌使用量。


概览

  • 请求方法:GET
  • 路径:/v1/dashboard/billing/usage
  • 内容类型:application/json

认证方式

  • Header:Authorization: Bearer <token>

请求示例

查询参数

参数类型必填说明
start_datestring开始时间戳,单位毫秒
end_datestring结束时间戳,单位毫秒

curl 示例

bash
curl -X GET "https://api.gpt.ge/v1/dashboard/billing/usage?start_date=1716149437000&end_date=1746517437000" \
  -H "Authorization: Bearer sk-xxxx"

JavaScript (fetch) 示例

javascript
fetch('https://api.gpt.ge/v1/dashboard/billing/usage?start_date=1716149437000&end_date=1746517437000', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer sk-xxxx'
  }
}).then(r => r.json()).then(console.log);

Python(requests)示例

python
import requests

url = 'https://api.gpt.ge/v1/dashboard/billing/usage'
headers = {
    'Authorization': 'Bearer sk-xxxx'
}
params = {
    'start_date': '1716149437000',
    'end_date': '1746517437000'
}

response = requests.get(url, headers=headers, params=params)
print(response.json())

返回示例(200)

json
{
  "object": "list",
  "total_usage": 695.9646
}

注意:返回的 total_usage 值需除以 100 才能计算出实际使用量。