查询调用用量汇总

汇总当前用户调用次数、Token 用量、费用和成功率。

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

调用前准备

准备个人访问令牌。创建和管理方法参阅创建和管理个人访问令牌

查询范围为当前用户有权访问的数据。

查询参数

将示例中的 $MOI_PERSONAL_ACCESS_TOKEN 替换为个人访问令牌。

curl --get "https://billing.moi.matrixorigin.cn/api/v1/taas/usage-logs/summary" \
  -H "X-API-Key: $MOI_PERSONAL_ACCESS_TOKEN"

参数

类型

是否必填

说明

start_time

integer

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

end_time

integer

结束时间,非负 Unix 秒。

model_id

string

模型目录对象 ID。

model_type

string

模型类型。

requested_model

string

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

status

string

调用状态,例如 successfailed

error_type

string

调用错误类别。

caller_ip

string

调用方 IP。

token_key_id

string

TaaS 本地密钥 ID。

token_key_ids

string

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

credential_type

string

填写 credential_id 时必填

凭据类别:taas_token_keypersonal_access_tokenservice_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 的兼容参数;与 ids 合并。

provider_id

string

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

成功响应

返回 HTTP 200,响应包含符合筛选条件的调用次数、Token 用量和费用汇总。

{
  "total_calls": 2,
  "total_input_tokens": 12,
  "total_output_tokens": 8,
  "cache_read_tokens": 0,
  "cache_creation_tokens": 0,
  "total_cost": "0.0001",
  "total_channel_cost": "0.00005",
  "total_channel_tokens": 20,
  "success_calls": 2,
  "failed_calls": 0,
  "success_rate": 1,
  "active_users": 1
}

字段

类型

说明

total_calls

integer

调用总次数。

total_input_tokens

integer

输入 Token 总数。

total_output_tokens

integer

输出 Token 总数。

cache_read_tokens

integer

缓存读取 Token 总数。

cache_creation_tokens

integer

缓存写入 Token 总数。

total_cost

string

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

total_channel_cost

string

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

total_channel_tokens

integer

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

success_calls

integer

成功调用次数。

failed_calls

integer

非成功调用次数。

success_rate

number

成功次数除以总次数;无调用时为 0。

active_users

integer

有调用记录的用户数量。

错误响应

{
  "code": 400,
  "message": "credential_type and credential_id must be provided together"
}

字段

类型

说明

code

integer

HTTP 错误状态码。

message

string

错误说明。

最后更新于