查询缓存账单

GET/v1/billing/caches/{cache_id}

返回一个显式缓存已结算的创建费用、存储费用和计费用量。缓存过期或删除后仍可查询。

推理请求的缓存读取费用不包含在此处。请通过查询请求用量查询相应推理请求的费用。

Authentication

Authorization Bearer

在 Authorization 请求头中发送 API Key(sk-...)或用户 JWT。只能查询当前账户拥有的缓存。

Path Parameters

cache_idstringrequired

缓存标识,即创建响应 name 中 cachedContents/ 后面的部分。

Response

codeinteger

响应状态码。

msgstring

响应消息。

dataobject | null
data.cache_idstring

缓存标识,即创建响应 name 中 cachedContents/ 后面的部分。

data.namestring

缓存资源名称。

data.modelstring

创建缓存使用的模型。

data.currencystring

费用币种,USD。

data.statusstring

缓存状态:pending、active、expired、deleted 或 failed。

data.billing_statusstring

pending:尚未结算创建费用;in_progress:已结算部分费用,仍可能产生后续费用;final:结算完成。

data.billing_finalboolean

仅当缓存计费已完成且不会继续结算时为 true。

data.creationobject
data.storageobject
data.total_amountnumber

已结算创建费用与存储费用之和,不包含使用此缓存进行推理的费用。

data.settled_throughstring | null

存储费用已结算至的 UTC 时间(ISO 8601);尚未结算存储时为 null。

data.checked_atstring

查询时间,UTC ISO 8601。

service_codestring | null

可用时返回稳定错误码。

trace_idstring | null

可用时返回诊断标识。

结算状态

total_amount 表示已结算费用,不是未来费用预估。缓存仍在使用时,存储费用会继续累积。删除或过期后,最终结算也可能尚未完成;请以 billing_final 为准。

创建或存储尚未结算时,相应的 billed 为 false、金额为 0,不代表该项免费。

Error Handling

检查响应中的 code,与其他账单查询接口保持一致:

  • 401 / unauthenticated:缺少身份凭证或凭证无效。
  • 404:缓存不存在、标识无效,或当前账户无法访问。返回 data: null。
  • 503 / CACHE_BILLING_UNAVAILABLE:暂时无法提供可靠的账单汇总。请稍后重试;持续失败时联系支持。

请求

Shell
1curl -sS "https://api.token360.ai/v1/billing/caches/0123456789abcdef0123456789abcdef" \
2  -H "Authorization: Bearer sk-your-api-key"

响应

JSON
1{
2  "code": 200,
3  "msg": "success",
4  "data": {
5    "cache_id": "0123456789abcdef0123456789abcdef",
6    "name": "cachedContents/0123456789abcdef0123456789abcdef",
7    "model": "example-gemini-model",
8    "currency": "USD",
9    "status": "expired",
10    "billing_status": "final",
11    "billing_final": true,
12    "creation": {
13      "billed": true,
14      "total_amount": 0.2,
15      "usage": {
16        "input_tokens": 1000000
17      }
18    },
19    "storage": {
20      "billed": true,
21      "total_amount": 0.5,
22      "usage": {
23        "cache_tokens_stored_hours": 500000
24      }
25    },
26    "total_amount": 0.7,
27    "settled_through": "2026-11-06T12:30:00Z",
28    "checked_at": "2026-11-06T12:31:00Z"
29  },
30  "service_code": null,
31  "trace_id": null
32}
此页面对您有帮助吗?
查询缓存账单 · Token360