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.

Authentication

Put the API key in the request header:

Authorization: Bearer sk_live_YOUR_API_KEY

API

GET/api/business/v1/customer/usage

查询用量

返回 [from, to) 时间范围内、API Key 所属项目的消耗汇总(总额与按模型分项)。 时间范围以 UTC 为准;消耗自动限定到 Key 所属项目,不能跨项目查询。

Bearer API KeyUse 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.

HTTP
GET https://www.silvamux.com/api/business/v1/customer/usage
Authorization: Bearer $SILVAMUX_API_KEY

Request parameters

ParameterType & locationRequiredDescription
fromstring (date-time) · queryYes起始时间(RFC3339,包含)。
tostring (date-time) · queryYes结束时间(RFC3339,不包含);from 必须早于 to。

Response

200时间范围内的用量汇总。

application/json · CustomerUsageReportResponse

FieldTypeDescription
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

FieldTypeDescription
detailstring错误详情。
errorsarray<object>字段级错误明细(422 校验失败时返回)。
errors.locationstring出错位置(如 query.request_id)。
errors.messagestring错误信息。
errors.valueany出错字段的值。
instancestring本次错误出现的 URI。
statusintegerHTTP 状态码。
titlestring错误摘要。
typestring错误类型标识(含错误码)。

Parameters

  • from, to: required, RFC3339 timestamps defining a half-open interval [from, to); from must be earlier than to.
  • The time range is in UTC.

Examples

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"

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
    }
  ]
}
FieldDescription
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

Error Handling

HTTPCodeDescription
401INVALID_TOKENAPI key missing or invalid
400INVALID_FROM_DATETIMEfrom missing or not RFC3339
400INVALID_TO_DATETIMEto missing or not RFC3339
400INVALID_TIME_RANGEfrom is not earlier than to