Skip to content

查询账户日志

GET /api/open/v1/logs
参数位置类型必填默认值说明
start_timestampqueryinteger否见说明起始时间(含),unix 秒
end_timestampqueryinteger否见说明结束时间(含),unix 秒
model_namequerystring否—按模型名精确过滤;多值需重复参数(?model_name=a&model_name=b),也支持逗号分隔
key_namequerystring否—按 Key 名称精确过滤;多值需重复参数,不支持逗号分隔(名称本身可能含逗号)
key_idqueryinteger否—Key ID,正整数;多值需重复参数或逗号分隔。其他用户的 Key ID 只会返回空
typequeryinteger否2日志类型:2 消费(计费)请求,7 最终失败请求(不计费)。多值需重复参数或逗号分隔(?type=2,7);其他值返回 400
pqueryinteger否1页码,取值 1–1000000
page_sizequeryinteger否10每页条数,取值 1–1000

时间范围规则:

  • 两端都省略:最近 30 天。
  • 只传 start_timestamp:向后 30 天,且不超过当前时间。
  • 只传 end_timestamp:向前 30 天。
  • 范围最长 366 天。

多值参数每个最多 50 个值,超过返回 400 invalid_request。p / page_size 显式传入非法值返回 400,详见 分页。时间参数必须是非负整数,否则返回 400。

Terminal window
curl "https://www.routeapi.ai/api/open/v1/logs?start_timestamp=1726408000&end_timestamp=1729000000&key_name=bot&model_name=gpt-4o&p=1&page_size=20" \
-H "Authorization: Bearer $ROUTEAPI_MANAGEMENT_KEY"
{
"success": true,
"message": "",
"data": {
"items": [
{
"id": 12345,
"created_at": 1729000000,
"type": 2,
"key_id": 12,
"key_name": "bot",
"key": "sk-abcd**********wxyz",
"model_name": "gpt-4o",
"prompt_tokens": 1200,
"completion_tokens": 300,
"total_tokens": 1500,
"amount": 0.05,
"use_time": 3,
"is_stream": true,
"first_response_ms": 420,
"cache_read_tokens": 800,
"cache_creation_tokens": 0,
"reasoning_effort": "medium",
"request_path": "/v1/chat/completions",
"web_search_calls": 0,
"audio_input_tokens": 0,
"audio_output_tokens": 0,
"billing_source": "wallet",
"request_id": "20261020120000123456789"
}
],
"total": 1,
"page": 1,
"page_size": 20,
"start_timestamp": 1726408000,
"end_timestamp": 1729000000
}
}
字段类型说明
items[].idinteger日志 ID
items[].created_atinteger记录时间,unix 秒
items[].typeinteger2 消费,7 最终失败
items[].key_idinteger发起请求的 Key ID
items[].key_namestring请求发生时该 Key 的名称
items[].keystring脱敏 Key 值,格式与 列出 API Key 一致,如 sk-abcd**********wxyz;Key 已被永久删除时为空字符串
items[].model_namestring模型名
items[].prompt_tokensinteger输入 token 数
items[].completion_tokensinteger输出 token 数
items[].total_tokensinteger输入与输出 token 合计
items[].amountnumber本次消耗金额,站点币种,两位小数;金额很小时可能为 0.00
items[].use_timeinteger请求耗时,秒
items[].is_streamboolean是否为流式请求
items[].first_response_msinteger首个响应耗时,毫秒;未知时为 0(如非流式请求)
items[].cache_read_tokensinteger提示词缓存命中 token 数
items[].cache_creation_tokensinteger提示词缓存写入 token 数
items[].reasoning_effortstring推理强度,如 low / medium / high;未设置时为空字符串
items[].request_pathstring请求路径,如 /v1/chat/completions
items[].web_search_callsinteger本次请求调用的联网搜索次数
items[].audio_input_tokensinteger音频输入 token 数
items[].audio_output_tokensinteger音频输出 token 数
items[].billing_sourcestringwallet 表示钱包余额、subscription 表示订阅套餐,未知时为空字符串
items[].request_idstring请求 ID,可用于排查问题
totalinteger符合条件的日志总数,最多统计到 10000
pageinteger当前页码
page_sizeinteger实际生效的每页条数
start_timestampinteger实际生效的起始时间
end_timestampinteger实际生效的结束时间
HTTPcode场景
400invalid_request时间戳非数字或为负数、时间范围超过 366 天、start_timestamp 大于 end_timestamp、分页参数非法、多值参数超过 50 个值、key_id 不是正整数,或 type 不是 2 或 7
429—超过按用户的查询频率限制(默认 30 次/分钟),响应体可能为空

其他通用错误码见 开放平台 API 错误。

  • 默认只返回消费(计费)日志;需要同时包含最终失败请求(不计费)时传 type=2,7。
  • 结果按记录时间倒序(created_at 降序);同一秒的记录按日志 ID 倒序,分页顺序稳定。
  • key_name 是请求发生时 Key 的名称;改名不会回溯改写历史记录。
  • key 是脱敏值;Key 被永久删除后为空字符串。
  • use_time、first_response_ms、缓存、搜索、音频与推理强度等字段在未记录对应数据时为 0 或空字符串;字段本身始终存在。
  • token 数为原始计数,不是百万单位。
  • 金额使用站点展示币种,见 查询余额。
  • 本接口与 导出日志、用量统计、按模型统计、按 Key 统计 共享按用户的查询频率限制(默认 30 次/分钟),见 频率限制。
  • 需要一次性导出全部匹配记录(CSV 或 JSONL)时,用 导出日志,不要分页拉取再自行拼接。