查询 AI 服务用量

查询当前账户的 AI 服务用量及计费结果,支持按服务槽位和计费场景筛选。

GET https://billing.moi.matrixorigin.cn/api/v1/billing/usage

调用前准备

  1. 准备计费账户所属用户的有效个人访问令牌。

  2. 调用查询当前账户接口,获取目标账户的 ID。

查询参数

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

curl -X GET \
  "https://billing.moi.matrixorigin.cn/api/v1/billing/usage?account_id=$ACCOUNT_ID&page_size=2" \
  -H "X-API-Key: $MOI_PERSONAL_ACCESS_TOKEN"

参数

类型

是否必填

说明

account_id

string

否

目标账户的 ID,取自“查询当前账户”响应中的 items[].billing_account_id,对应示例中的 $ACCOUNT_ID。省略时使用当前用户可访问的第一个账户。

meter_code

string

否

仅接受 moi_ai_service_mtoken,省略时使用该值。

service_slot

string

否

按用量来源的服务槽位筛选。

billing_scenario

string

否

按用量来源的计费场景筛选。

workspace_id

string

否

按用量事件所属工作区筛选。

status

string

否

按计费记录状态筛选。未计费时按用量事件状态筛选。

from

string

否

按用量事件创建时间筛选的起点,包含该时刻。使用 RFC 3339 时间。

to

string

否

按用量事件创建时间筛选的终点,不包含该时刻。使用 RFC 3339 时间。

page_size

integer

否

每页数量,1–100。省略、非正数或大于 100 时使用 50。

page_token

string

否

下一页标记。首次请求省略。后续使用响应的 next_cursor。

成功响应

{
  "items": [],
  "total": 0,
  "as_of": 1788739200
}

字段

类型

说明

items

array of object

本次返回的记录。

items[].rated_record_id

string

计费用量记录 ID,计费后返回。

items[].usage_event_id

string

用量事件 ID。

items[].billing_account_id

string

计费账户 ID。

items[].parent_name

string

服务分类名称。

items[].service_slot

string

用量来源的服务槽位。

items[].billing_scenario

string

用量来源的计费场景。

items[].workspace_id

string

所属工作区 ID。

items[].meter_code

string

计量项代码,返回 moi_ai_service_mtoken

items[].quantity

string

用量,以十进制字符串返回。

items[].unit

string

计量单位。

items[].unit_price_credit

string

Credit 单价,完成计费后可能返回。

items[].credit

string

折扣后费用,单位为 Credit,完成计费后可能返回。

items[].status

string

记录状态,优先返回计费记录状态。

items[].occurred_at

string

用量发生时间。

items[].window_start

string

计费窗口开始时间。

items[].window_end

string

计费窗口结束时间。

items[].request_id

string

来源请求 ID。

items[].request_count

integer

来源请求数。

items[].source_rated_record_ids

array of string

来源计价记录 ID。

items[].created_at

integer

创建时间,Unix 秒。

total

integer

符合筛选条件的总记录数。

next_cursor

string

下一页标记。省略或为空时停止翻页。

as_of

integer

查询结果生成时间,Unix 秒。

错误响应

缺少认证信息时返回 HTTP 401。在请求头中提供有效的个人访问令牌。

{
  "code": "unauthenticated",
  "message": "missing bearer token",
  "error": "missing bearer token"
}

字段

类型

说明

code

string

错误代码。

message

string

错误说明。

error

string

错误说明,内容与 message 相同。

最后更新于