查询请求明细
按组织 + 时间窗查询逐笔请求明细(T-1 就绪:当日数据次日早 7:00 CST 起可查),游标分页。金额为毫分;支持 project_id/key 过滤。
GET
/
v1
/
admin
/
organizations
/
billings
/
request_details
查询请求明细
curl --request GET \
--url https://api.moonshot.cn/v1/admin/organizations/billings/request_details \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.moonshot.cn/v1/admin/organizations/billings/request_details"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.moonshot.cn/v1/admin/organizations/billings/request_details', 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.moonshot.cn/v1/admin/organizations/billings/request_details",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$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.moonshot.cn/v1/admin/organizations/billings/request_details"
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))
}HttpResponse<String> response = Unirest.get("https://api.moonshot.cn/v1/admin/organizations/billings/request_details")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.cn/v1/admin/organizations/billings/request_details")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": [
{
"id": "<string>",
"time": "2023-11-07T05:31:56Z",
"model_id": "<string>",
"key": "<string>",
"key_name": "<string>",
"project_id": "<string>",
"project_name": "<string>",
"prompt_tokens": 1,
"completion_tokens": 1,
"cached_tokens": 1,
"is_off_peak": true,
"off_peak_ratio": "<string>",
"client_request_id": "<string>",
"cache_write_5m_tokens": 1,
"cache_write_1h_tokens": 1
}
],
"has_more": true,
"next": "<string>"
}{
"error": {
"type": "invalid_request_error",
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}本接口要求 Admin Key 具备
billing:read 作用域。用
X-Msh-Client-Request-Id 精确对行:调用推理 API 时在请求头带上你自己系统的请求 ID(X-Msh-Client-Request-Id: <你的请求ID>),我方计费明细会把该值落表记录为 client_request_id。对账时拉取本 feed,用你的 request_id 与记录里的 client_request_id 精确对行——这笔有没有记、记成什么样(tokens 量、是否闲时命中),逐笔可核,无需按「时间 + tokens」推断。断连核实请改用中断请求专用 feed(interrupted_requests);金额核对以日账单/产品账单为准(本 feed 只给 token 量、不含金额),用 client_request_id 可在两类接口间精确关联。例:「我们网关 request_id=abc123 的这笔请求被扣费了,为什么?」→ 用该 ID 在 request_details 里查 client_request_id=abc123 的记录确认 token 量,再到日账单核对当日金额。授权
Authorization 请求头携带 Admin API secret 作为 Bearer 令牌,格式为 Bearer sk-admin-***。Admin Key 可在「控制台 → 组织管理 → Admin API Keys」创建。
查询参数
起始时间(epoch 毫秒),含边界。例如 1790784000000(2026-10-01 00:00 CST)。
必填范围:
x >= 0结束时间(epoch 毫秒),不含边界。例如 1792598400000(2026-10-22 00:00 CST)。
必填范围:
x >= 0项目 ID 列表。每个项目都必须属于当前认证组织。
推理 API 密钥 ID 列表。每个 key 都必须属于当前认证组织。
是否按服务端写入时间降序排列。排序键是写入时间,而非 time 字段,因此同一秒内的行不保证按请求时间单调。默认 true(降序)。
页大小。交互式查询默认 100;批量拉取可调大(最高 10000)—— 大批量拉取可能增加单页延迟(非 SLA 承诺)。
必填范围:
1 <= x <= 10000上一次响应 next 字段返回的游标。游标只携带页位置;每次翻页都需原样重复全部查询参数(limit 除外),服务端不校验参数一致性。
此页面对您有帮助吗?
⌘I
查询请求明细
curl --request GET \
--url https://api.moonshot.cn/v1/admin/organizations/billings/request_details \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.moonshot.cn/v1/admin/organizations/billings/request_details"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.moonshot.cn/v1/admin/organizations/billings/request_details', 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.moonshot.cn/v1/admin/organizations/billings/request_details",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$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.moonshot.cn/v1/admin/organizations/billings/request_details"
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))
}HttpResponse<String> response = Unirest.get("https://api.moonshot.cn/v1/admin/organizations/billings/request_details")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.cn/v1/admin/organizations/billings/request_details")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": [
{
"id": "<string>",
"time": "2023-11-07T05:31:56Z",
"model_id": "<string>",
"key": "<string>",
"key_name": "<string>",
"project_id": "<string>",
"project_name": "<string>",
"prompt_tokens": 1,
"completion_tokens": 1,
"cached_tokens": 1,
"is_off_peak": true,
"off_peak_ratio": "<string>",
"client_request_id": "<string>",
"cache_write_5m_tokens": 1,
"cache_write_1h_tokens": 1
}
],
"has_more": true,
"next": "<string>"
}{
"error": {
"type": "invalid_request_error",
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "invalid_request",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}