查询请求日志详情

查询一次模型调用的结果、正文预览和正文归档信息。

GET https://billing.moi.matrixorigin.cn/api/v1/taas/usage-logs/{id}

调用前准备

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

  2. 通过查询请求日志列表选择要查询的调用。

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

请求示例

将示例中的 $MOI_PERSONAL_ACCESS_TOKEN$USAGE_LOG_ID 分别替换为个人访问令牌和所选请求日志的 ID。

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

路径参数

参数

类型

是否必填

说明

id

string

所选请求日志的 ID,取自请求日志列表中的 items[].id

成功响应

返回 HTTP 200,响应包含所选请求日志的详情和正文归档信息。

{
  "id": "usage_example",
  "user_id": "user_example",
  "model_id": "model_example",
  "model_name": "example-chat-model",
  "requested_model": "example-chat-model",
  "called_at": 1788710400,
  "input_tokens": 12,
  "output_tokens": 8,
  "cache_read_tokens": 0,
  "cache_creation_tokens": 0,
  "cost": "0.0001",
  "status": "success",
  "latency_ms": 120,
  "request_body_ref_id": "body_request_example",
  "response_body_ref_id": "body_response_example",
  "request_body_sha256": "44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
  "response_body_sha256": "44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
  "request_body_bytes": 2,
  "response_body_bytes": 2,
  "created_at": 1788710400,
  "credential": {
    "type": "personal_access_token",
    "id": "credential_example"
  },
  "request_body": "{}",
  "response_body": "{}",
  "body_refs": [
    {
      "id": "body_request_example",
      "usage_log_id": "usage_example",
      "scope": "user_request",
      "preview_body": "{}",
      "full_sha256": "44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
      "status": "complete",
      "preview_bytes": 2,
      "full_bytes": 2,
      "created_at": 1788710400,
      "completed_at": 1788710401
    }
  ]
}

字段

类型

说明

id

string

请求日志 ID。

token_key_id

string

TaaS 本地密钥 ID;使用该类密钥时返回。

token_key_name

string

TaaS 本地密钥名称。

user_id

string

调用用户 ID。

user_name

string

调用用户名称;有值时返回。

model_id

string

模型目录对象 ID。

model_name

string

实际调用的模型名称。

requested_model

string

请求填写的模型名称。

caller_ip

string

调用方 IP。

called_at

integer

调用时间,Unix 秒。

input_tokens

integer

输入 Token 数。

output_tokens

integer

输出 Token 数。

cache_read_tokens

integer

缓存读取 Token 数。

cache_creation_tokens

integer

缓存写入 Token 数。

cost

string

本次调用费用,十进制字符串。

status

string

调用结果状态。

error_type

string

调用错误类别;有错误时返回。

error_message

string

调用错误说明;有错误时返回。

latency_ms

integer

调用耗时,毫秒。

request_body_ref_id

string

请求正文的归档引用 ID。 有值时返回。

response_body_ref_id

string

响应正文的归档引用 ID。 有值时返回。

request_body_sha256

string

完整请求正文的 SHA-256。 有值时返回。

response_body_sha256

string

完整响应正文的 SHA-256。 有值时返回。

request_id

string

请求追踪 ID。 有值时返回。

key_hash_prefix

string

密钥哈希前缀。 有值时返回。

meter_code

string

计费项代码。 有值时返回。

pricing_mode

string

调用计价方式。 有值时返回。

enterprise_plan_id

string

企业方案 ID。 有值时返回。

enterprise_plan_name

string

企业方案名称。 有值时返回。

enterprise_contract_no

string

企业合同编号。 有值时返回。

enterprise_plan_model_id

string

企业方案模型 ID。 有值时返回。

pricing_snapshot

string

计价快照,序列化字符串。 有值时返回。

settlement_method

string

结算方式。 有值时返回。

billing_report_status

string

用量上报状态。 有值时返回。

billing_report_group_id

string

用量上报批次 ID。 有值时返回。

billing_event_key

string

计费用量事件的幂等标识。 有值时返回。

billing_event_id

string

计费用量事件 ID。 有值时返回。

billing_record_id

string

计费记录 ID。 有值时返回。

billing_account_id

string

计费账户 ID。 有值时返回。

billing_rated_credit

string

本次计费的 Credit 数量。 有值时返回。

billing_credit_balance

string

上报结果记录的 Credit 余额。 有值时返回。

billing_credit_available

string

上报结果记录的可用 Credit。 有值时返回。

billing_last_error

string

最近一次计费用量上报错误。 有值时返回。

request_body_bytes

integer

完整请求正文的字节数。

response_body_bytes

integer

完整响应正文的字节数。

billing_reported_at

integer

计费用量上报时间,Unix 秒;有值时返回。

billing_report_attempts

integer

计费用量上报尝试次数。

created_at

integer

日志创建时间,Unix 秒。

credential

object

本次调用的凭据标识;有记录时返回。

credential.type

string

凭据类别:taas_token_keypersonal_access_tokenservice_account_api_key

credential.id

string

凭据对象 ID。

credential.service_account_id

string

服务账号 ID;仅服务账号凭据返回。

request_body

string

请求正文预览;可能截断。

response_body

string

响应正文预览;可能截断。

body_refs

array of object

关联的正文归档信息。

body_refs[].id

string

正文归档引用 ID。

body_refs[].usage_log_id

string

所属请求日志 ID。

body_refs[].provider_request_log_id

string

关联的上游请求日志 ID。

body_refs[].user_id

string

所属用户 ID。

body_refs[].token_key_id

string

关联的 TaaS 本地密钥 ID。

body_refs[].request_id

string

请求追踪 ID。

body_refs[].body_id

string

正文对象 ID。

body_refs[].scope

string

正文所属请求或响应阶段。

body_refs[].content_type

string

正文媒体类型;有值时返回。

body_refs[].preview_body

string

正文预览。

body_refs[].full_sha256

string

完整正文的 SHA-256。

body_refs[].status

string

归档状态。

body_refs[].error_message

string

归档错误说明;有错误时返回。

body_refs[].legacy

boolean

兼容历史归档的标记;有值时返回。

body_refs[].preview_bytes

integer

预览字节数。

body_refs[].full_bytes

integer

完整正文字节数。

body_refs[].created_at

integer

归档创建时间,Unix 秒。

body_refs[].completed_at

integer

归档完成时间,Unix 秒;完成时返回。

字段路径中的 [] 表示数组中的每一项。

后续操作

使用日志的 id 查询上游请求记录。需要完整正文时,使用该日志的正文引用 ID 下载请求或响应正文

最后更新于