查询调用用量趋势

按时间统计当前用户的调用次数、Token 用量和费用。

GET https://billing.moi.matrixorigin.cn/api/v1/taas/usage-logs/trend

调用前准备

准备个人访问令牌。

查询参数

将示例中的 $MOI_PERSONAL_ACCESS_TOKEN 替换为实际值。

curl --get "https://billing.moi.matrixorigin.cn/api/v1/taas/usage-logs/trend" \
  -H "X-API-Key: $MOI_PERSONAL_ACCESS_TOKEN" \
  --data-urlencode "granularity=day"

参数

类型

是否必填

说明

start_time

integer

否

开始时间,非负 Unix 秒。不能晚于结束时间。

end_time

integer

否

结束时间,非负 Unix 秒。

model_id

string

否

模型目录对象 ID。

model_type

string

否

模型类型。

requested_model

string

否

调用请求填写的模型名称。

status

string

否

调用状态,例如 success 或 failed。

error_type

string

否

调用错误类别。

caller_ip

string

否

调用方 IP。

token_key_id

string

否

Genesis 本地密钥 ID。

token_key_ids

string

否

Genesis 本地密钥 ID 列表。可重复传递或用逗号分隔。

credential_type

string

填写 credential_id 时必填

凭据类别:taas_token_key、personal_access_token 或 service_account_api_key。必须同时填写 credential_id。

credential_id

string

填写 credential_type 时必填

凭据对象 ID。必须同时填写 credential_type。

billing_event_id

string

否

计费用量事件 ID。

billing_record_id

string

否

计费记录 ID。

pricing_mode

string

否

计价方式。

settlement_method

string

否

结算方式:genesis 或 ai_service。

enterprise_plan_id

string

否

企业方案 ID。

enterprise_contract_no

string

否

企业合同编号。

enterprise_plan_model_id

string

否

企业方案模型 ID。

response_id

string

否

Responses 响应 ID。

conversation_id

string

否

Conversation ID。

ids

string

否

请求日志 ID 列表。可重复传递或用逗号分隔。

usage_ids

string

否

ids 的别名。两个参数同时填写时,合并查询。

provider_id

string

否

供应商 ID。查询仍限定为当前用户的调用。

granularity

string

否

统计粒度:hour 或 day。默认 hour。

成功响应

{
  "points": [
    {
      "timestamp": 1788710400,
      "time": "2026-09-07T00:00:00Z",
      "calls": 2,
      "total_calls": 2,
      "input_tokens": 12,
      "output_tokens": 8,
      "total_input_tokens": 12,
      "total_output_tokens": 8,
      "total_user_tokens": 20,
      "cache_read_tokens": 0,
      "cache_creation_tokens": 0,
      "total_cost": "0.0001",
      "total_channel_cost": "0.00005",
      "total_channel_tokens": 20,
      "total_cache_read_tokens": 0,
      "total_cache_creation_tokens": 0
    }
  ],
  "granularity": "day",
  "start_time": 1788710400,
  "end_time": 1788796799,
  "truncated": false
}

字段

类型

说明

points

array of object

按时间升序排列的统计区间。无调用数据的区间不返回。

points[].timestamp

integer

统计区间起点,Unix 秒。

points[].time

string

统计区间起点的 UTC 时间,RFC 3339。

points[].calls

integer

该统计区间的调用次数。

points[].total_calls

integer

与 calls 相同。

points[].input_tokens

integer

输入 Token 数。

points[].output_tokens

integer

输出 Token 数。

points[].total_input_tokens

integer

与 input_tokens 相同。

points[].total_output_tokens

integer

与 output_tokens 相同。

points[].total_user_tokens

integer

输入、输出、缓存读取和缓存写入 Token 之和。

points[].cache_read_tokens

integer

缓存读取 Token 总数。

points[].cache_creation_tokens

integer

缓存写入 Token 总数。

points[].total_cost

string

调用费用合计,十进制字符串。

points[].total_channel_cost

string

关联上游请求的成本合计。

points[].total_channel_tokens

integer

关联上游请求的输入、输出及缓存 Token 总数。

points[].total_cache_read_tokens

integer

与 cache_read_tokens 相同。

points[].total_cache_creation_tokens

integer

与 cache_creation_tokens 相同。

granularity

string

使用的统计粒度。

start_time

integer

实际统计开始时间,Unix 秒。

end_time

integer

实际统计结束时间,Unix 秒。

truncated

boolean

开始时间默认或范围超过 999 个间隔时,缩短范围并返回 true。

错误响应

{
  "code": 400,
  "message": "start_time must be a non-negative unix timestamp"
}

字段

类型

说明

code

integer

HTTP 错误状态码。

message

string

错误说明。

最后更新于