查询用量
curl --request GET \
--url https://openp.ai/v1/dashboard/billing/usageimport requests
url = "https://openp.ai/v1/dashboard/billing/usage"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://openp.ai/v1/dashboard/billing/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://openp.ai/v1/dashboard/billing/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://openp.ai/v1/dashboard/billing/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://openp.ai/v1/dashboard/billing/usage")
.asString();require 'uri'
require 'net/http'
url = URI("https://openp.ai/v1/dashboard/billing/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账户管理
查询用量
GET /v1/dashboard/billing/usage —— 时间段内的消耗
GET
/
v1
/
dashboard
/
billing
/
usage
查询用量
curl --request GET \
--url https://openp.ai/v1/dashboard/billing/usageimport requests
url = "https://openp.ai/v1/dashboard/billing/usage"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://openp.ai/v1/dashboard/billing/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://openp.ai/v1/dashboard/billing/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://openp.ai/v1/dashboard/billing/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://openp.ai/v1/dashboard/billing/usage")
.asString();require 'uri'
require 'net/http'
url = URI("https://openp.ai/v1/dashboard/billing/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查询指定时间区间内的累计消耗(单位:USD)。
最长跨度 100 天。
返回每一条调用的:模型、token、耗时、扣费、Request ID、IP 等。
请求
curl "https://openp.ai/v1/dashboard/billing/usage?start_date=2026-05-01&end_date=2026-05-15" \
-H "Authorization: Bearer $OPENPAI_API_KEY"
Query 参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
start_date | string | ✅ | YYYY-MM-DD,包含此日 |
end_date | string | ✅ | YYYY-MM-DD,不包含此日 |
响应
{
"object": "list",
"total_usage": 12.43,
"daily_costs": [
{
"timestamp": 1714521600,
"line_items": [
{"name": "gpt-5.5", "cost": 1.20},
{"name": "gpt-5.5", "cost": 0.15}
]
}
]
}
total_usage 单位是 USD ×100(即 12.43 = $0.1243),与 OpenAI 官方约定一致。
但 OpenPAI 控制台 / 日志使用人民币展示,具体换算请以控制台为准。
更细粒度
如需逐请求级别的日志,使用控制台 → 日志 页面,或专用 API:curl "https://openp.ai/api/log/self?page=1&page_size=50" \
-H "Authorization: Bearer $OPENPAI_USER_TOKEN"
客户端兼容
NextChat / ChatBox / LobeChat 等会调用此接口在 UI 上展示消耗趋势, OpenPAI 完整支持以保证客户端 “Account 信息” 面板可用。⌘I