Query Usage Returns the consumption summary of the API key's project over a given time range: totals plus per-model breakdowns. Usage is automatically scoped to the key's project and cannot be queried across projects.
Put the API key in the request header:
Authorization: Bearer sk_live_YOUR_API_KEY
GET /api/business/v1/customer/usage
查询用量
返回 [from, to) 时间范围内、API Key 所属项目的消耗汇总(总额与按模型分项)。 时间范围以 UTC 为准;消耗自动限定到 Key 所属项目,不能跨项目查询。
🔑 Bearer API Key Use the Authorization: Bearer sk_live_... header; x-api-key is also supported.
Request structure The section below confirms the method, URL and authentication scheme. It is an HTTP structure snippet, not a standalone runnable example.
GET https://www.silvamux.com/api/business/v1/customer/usage
Authorization: Bearer $SILVAMUX_API_KEYRequest parameters Parameter Type & location Required Description fromstring (date-time) · query Yes 起始时间(RFC3339,包含)。 tostring (date-time) · query Yes 结束时间(RFC3339,不包含);from 必须早于 to。
Response 200时间范围内的用量汇总。 application/json · CustomerUsageReportResponse
Field Type Description by_modelarray<CustomerUsageModelBreakdown> 按模型分项,按 cost_points 降序。 by_model.billable_prompt_tokensinteger (int64) 计费输入 token(prompt + cache creation)。 by_model.cache_creation_tokensinteger (int64) 缓存写 token。 by_model.cache_explicit_read_tokensinteger (int64) 显式缓存读 token。 by_model.cached_tokensinteger (int64) 缓存读 token。 by_model.completion_tokensinteger (int64) 输出 token。 by_model.cost_pointsstring 折后消耗(points)。 by_model.generated_artifactsinteger (int64) 异步任务产物数(视频/图片)。 by_model.modelstring 聚合键:请求时填写的 model(历史行回退配置模型 ID)。 by_model.original_coststring 折前消耗(points)。 by_model.prompt_tokensinteger (int64) 输入 token(未命中缓存)。 by_model.request_countinteger (int64) 计费请求数。 by_model.total_tokensinteger (int64) 总 token。 fromstring (date-time) 汇总起始(RFC3339,包含)。 project_idstring 该 API Key 绑定的项目。 tostring (date-time) 汇总结束(RFC3339,不包含)。 totalsCustomerUsageTotals 全部模型的汇总用量。 totals.billable_prompt_tokensinteger (int64) 计费输入 token(prompt + cache creation)。 totals.cache_creation_tokensinteger (int64) 缓存写 token。 totals.cache_explicit_read_tokensinteger (int64) 显式缓存读 token。 totals.cached_tokensinteger (int64) 缓存读 token。 totals.completion_tokensinteger (int64) 输出 token。 totals.cost_pointsstring 折后总消耗(points)。 totals.generated_artifactsinteger (int64) 异步任务产物数(视频/图片)。 totals.original_coststring 折前总消耗(points)。 totals.prompt_tokensinteger (int64) 输入 token(未命中缓存)。 totals.request_countinteger (int64) 计费请求数。 totals.total_tokensinteger (int64) 总 token。
defaultRFC 7807 problem+json 错误(Business API 形态)。 application/problem+json · BusinessError
Field Type Description detailstring 错误详情。 errorsarray<object> 字段级错误明细(422 校验失败时返回)。 errors.locationstring 出错位置(如 query.request_id)。 errors.messagestring 错误信息。 errors.valueany 出错字段的值。 instancestring 本次错误出现的 URI。 statusinteger HTTP 状态码。 titlestring 错误摘要。 typestring 错误类型标识(含错误码)。
from, to: required, RFC3339 timestamps defining a half-open interval [from, to); from must be earlier than to.The time range is in UTC. curl "https://www.silvamux.com/api/business/v1/customer/usage?from=2026-07-08T00:00:00Z&to=2026-07-09T00:00:00Z" \
-H "Authorization: Bearer $SILVAMUX_API_KEY "
# pip install requests
import os
import requests
resp = requests.get(
"https://www.silvamux.com/api/business/v1/customer/usage",
params={
"from": "2026-07-08T00:00:00Z",
"to": "2026-07-09T00:00:00Z",
},
headers={"Authorization": f"Bearer {os.environ['SILVAMUX_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json()["totals"])
// Node 18+ (built-in fetch)
const from = "2026-07-08T00:00:00Z";
const to = "2026-07-09T00:00:00Z";
const query = new URLSearchParams({ from, to });
const resp = await fetch(
`https://www.silvamux.com/api/business/v1/customer/usage?${query}`,
{
headers: { Authorization: `Bearer ${process.env.SILVAMUX_API_KEY}` },
},
);
const data = await resp.json();
console.log(data.totals);
// Standard library only
package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
url := "https://www.silvamux.com/api/business/v1/customer/usage?from=2026-07-08T00:00:00Z&to=2026-07-09T00:00:00Z"
req, err := http.NewRequest("GET", url, nil)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("SILVAMUX_API_KEY"))
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
cURL Python JavaScript Go
Response:
{
"from" : "2026-07-08T00:00:00Z" ,
"to" : "2026-07-09T00:00:00Z" ,
"project_id" : "PROJ-1" ,
"totals" : {
"cost_points" : "1.5" ,
"prompt_tokens" : 100 ,
"cached_tokens" : 0 ,
"billable_prompt_tokens" : 100 ,
"completion_tokens" : 50 ,
"cache_creation_tokens" : 0 ,
"total_tokens" : 150 ,
"generated_artifacts" : 0 ,
"request_count" : 2
},
"by_model" : [
{
"model" : "deepseek-v4-pro@tune" ,
"cost_points" : "1.5" ,
"prompt_tokens" : 100 ,
"cached_tokens" : 0 ,
"billable_prompt_tokens" : 100 ,
"completion_tokens" : 50 ,
"cache_creation_tokens" : 0 ,
"total_tokens" : 150 ,
"generated_artifacts" : 0 ,
"request_count" : 2
}
]
}
Field Description project_idThe project the API key is bound to totalsSummary across all models in the time range by_modelPer-model breakdown, ordered by cost_points descending
HTTP Code Description 401 INVALID_TOKENAPI key missing or invalid 400 INVALID_FROM_DATETIMEfrom missing or not RFC3339400 INVALID_TO_DATETIMEto missing or not RFC3339400 INVALID_TIME_RANGEfrom is not earlier than to