Skip to main content
GET
国内用户请注意: 中国大陆用户请使用 https://toapis.cn 作为接口地址(Base URL)。文档示例中的 https://toapis.com 请替换为 https://toapis.cn。
  • 查询名下所有 API Key 的逐请求 Token 消耗与费用,也可按单个 Key 过滤
  • 输入、输出、缓存命中 Token 分别统计
  • 汇总接口按 Key 聚合总量
  • 游标分页,时间窗口最长 31 天
这两个接口读取计费日志,返回每笔计费请求的 Token 明细与费用,以及按 Key 的汇总。与只能查询单个 Key 总额度的 查询令牌余额 接口互补。

认证方式

string
必填
本接口以用户账号身份认证,不使用 sk- API Key。
  1. 打开 账户设置页,在“系统访问令牌”卡片点击生成,得到访问令牌(不是 sk- key)。再次生成会使旧令牌失效。
  2. 请求时同时携带访问令牌和用户 ID:
数字形式的用户 ID 显示在同一设置页。
string
必填
数字形式的用户 ID,必须与访问令牌一起提供。

接口地址

查询参数

两个接口参数相同。出现未定义或重复的参数会返回 422。
integer
必填
时间窗口起点,Unix 秒时间戳(含该时刻)。
integer
必填
时间窗口终点,Unix 秒时间戳(不含该时刻)。必须大于 start_timestamp,窗口最长 31 天。
integer
可选。按数字 ID 过滤为单个 API Key,不传则包含所有 Key。
integer
默认值:"50"
每页行数,1–100。
string
上一次响应中 meta.next_cursor 返回的分页游标。仅对生成它的同一接口、同一时间窗口和相同 token_id 过滤条件有效。

响应说明

GET /api/usage/tokens/requests 每笔计费请求返回一行,按时间倒序排列。
integer
请求对应的内部日志 ID,在响应内唯一。
integer
请求计费时间,Unix 秒时间戳。
integer
发起请求的 API Key ID。
string
API Key 名称。
string
实际服务的模型。
string
异步请求(图片/视频生成)的任务 ID;同步请求为空。
integer
计费的输入 Token 数。
integer
计费的输出 Token 数。
integer | null
命中的缓存输入 Token 数(缓存读取)。上游未上报时为 null。
integer | null
写入缓存的 Token 数,未上报时为 null。
integer | null
上游服务商上报的总 Token 数(如有)。
integer
prompt_tokens + completion_tokens。
string
pre_consumed、settled,或对早期缺少计费元数据的日志返回 unknown。
integer
消耗的额度,平台内部单位。
string
折算后的美元费用,计算方式 quota / quota_per_usd(见 meta)。以字符串返回以保持精度。
GET /api/usage/tokens/summary 每个 API Key 返回一行,按 token_id 升序。
integer
API Key ID。
integer
窗口内计费请求数。
integer
该 Key 的输入 Token 总量。
integer
该 Key 的输出 Token 总量。
integer
prompt_tokens + completion_tokens。
integer
该 Key 消耗的额度总量。
string
该 Key 的美元总费用。

Meta

boolean
是否还有下一页。
string
作为 cursor 参数传回即可获取下一页;has_more 为 false 时为空。
string
cost_usd 折算使用的内部额度/美元比率。
boolean
消费日志开关是否开启;关闭时返回数据可能为空。
boolean
当前恒为 false,退款金额不做扣减。

注意事项

  • 仅列出已计费的请求。未计费的失败请求不会出现在结果中,响应中也不包含逐请求的成功标记。
  • 费用按计费时记录的额度折算,不按当前目录价重算,且不扣减退款。
  • 接口不会暴露原始 Key、渠道、IP 及请求/响应内容。
  • cursor 与接口、时间窗口、token_id 过滤条件绑定,不同查询之间不能复用。
  • 查询超时时间较短;如收到 query_timeout,请缩短时间窗口后重试。