Query Request Usage

Returns the actual usage of a single request — token counts and cost — identified by its request ID (the X-Request-Id response header value, prefixed with REQ-). Useful for reconciling the real billing of a single call once it completes, e.g. asynchronous video generation tasks.

A request that failed over between providers produces multiple ledger entries: failed attempts are voided (status is upstream_failed, cost 0) and the final successful one is billed. All entries are returned, ordered by creation time ascending.

Authentication

Put the API key in the request header:

Authorization: Bearer sk_live_YOUR_API_KEY

API

GET/api/business/v1/customer/request-usage

查询单次请求消耗

按请求 ID(响应头 X-Request-Id 的值,REQ- 开头)返回该次请求的实际消耗 (token 用量与费用),适用于异步任务结算核对。一次请求在供应商间切换时会产生 多条记录:失败尝试已作废(upstream_failed,费用 0),最终成功一条为 billed, 按创建时间升序返回。只能查询属于该 API Key 组织的请求,否则 404。

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/request-usage
Authorization: Bearer $SILVAMUX_API_KEY

Request parameters

ParameterType & locationRequiredDescription
request_idstring · queryYes响应头 X-Request-Id 的值(REQ- 开头)。

Response

200该请求产生的全部计费记录。

application/json · CustomerRequestUsageResponse

FieldTypeDescription
ledgersarray<CustomerRequestUsageEntry>该请求产生的全部计费记录,按创建时间升序。
ledgers.cost_pointsstring折后实际扣费(points)。
ledgers.created_atstring (date-time)记录创建时间(RFC3339)。
ledgers.first_token_latency_msinteger (int64)首 token 延迟(ms,流式请求;0 表示未记录)。
ledgers.generated_artifactsinteger (int64)异步任务产物数(视频/图片)。
ledgers.is_streamboolean是否流式请求。
ledgers.original_coststring折前费用(points)。
ledgers.project_namestring项目名。
ledgers.request_modelstring请求时填写的模型名。
ledgers.statusstring (billed | upstream_failed | pending)billed 已计费 / upstream_failed 上游失败已作废(费用 0)/ pending 待结算。
ledgers.tokensCustomerRequestUsageTokens单条计费记录的 token 用量明细。
ledgers.tokens.billable_prompt_tokensinteger (int64)计费输入 token(prompt + cache creation)。
ledgers.tokens.cached_tokensinteger (int64)缓存读 token。
ledgers.tokens.completion_tokensinteger (int64)输出 token。
ledgers.tokens.prompt_tokensinteger (int64)输入 token(未命中缓存)。
ledgers.tokens.total_tokensinteger (int64)总 token。
ledgers.total_latency_msinteger (int64)总耗时(ms;0 表示未记录)。
request_idstring查询的请求 ID。

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

  • request_id: required, the X-Request-Id response header value (REQ- prefixed).
  • Only requests belonging to the API key's organization can be queried; anything else returns 404.

Examples

curl "https://www.silvamux.com/api/business/v1/customer/request-usage?request_id=REQ-01M2JBYGGVY77KPRWNZFDFTWZR" \
  -H "Authorization: Bearer $SILVAMUX_API_KEY"

Response:

{
  "request_id": "REQ-01M2JBYGGVY77KPRWNZFDFTWZR",
  "ledgers": [
    {
      "request_model": "deepseek-v4-pro",
      "project_name": "Default Project",
      "status": "billed",
      "tokens": {
        "prompt_tokens": 85,
        "cached_tokens": 0,
        "billable_prompt_tokens": 85,
        "completion_tokens": 10,
        "total_tokens": 95
      },
      "generated_artifacts": 0,
      "is_stream": false,
      "first_token_latency_ms": 0,
      "total_latency_ms": 1358,
      "original_cost": "0.001035",
      "cost_points": "0.001035",
      "created_at": "2026-09-15T11:06:32.861800Z"
    }
  ]
}
FieldDescription
request_idThe queried request ID
ledgersAll ledger entries produced by this request, ordered by creation time ascending
ledgers[].request_modelThe model name as supplied in the request
ledgers[].statusbilled / upstream_failed (voided, cost 0) / pending
ledgers[].tokensToken usage breakdown
ledgers[].generated_artifactsArtifact count for async tasks (video/image)
ledgers[].original_costCost before discount
ledgers[].cost_pointsActual charged cost after discount

Error Handling

HTTPCodeDescription
401INVALID_TOKENAPI key missing or invalid
404REQUEST_USAGE_NOT_FOUNDRequest ID not found, or not owned by the API key's organization
422—request_id parameter missing