跳转至

账单接口文档

本文档包含两类与账单相关的接口:

  • 账单 Excel 导出接口
  • 账单统计接口 (Bill Stats API)

1. 账单 Excel 导出接口文档

该接口用于根据筛选条件导出账单数据,返回结果为二进制 Excel 文件流。

1.1 接口信息

  • 接口地址: https://monitor.ponderera.com/bill/excel
  • 请求方法: POST
  • 数据格式: application/json
  • 功能描述: 导出指定时间段内、特定模型或 Token 的账单详情。

1.2 请求参数 (Request)

参数名 必选 类型 说明 示例
token String 身份验证令牌 ************F99642E4AFF
Content-Type String 请求体格式 application/json

Body 参数

字段名 必选 类型 说明 示例
type Integer 导出类型 (例如:1=分钟 2=小时 3=天 4=周 5=月) 1
startTime Long 开始时间戳 (秒级) 1769443200
endTime Long 结束时间戳 (秒级) 1769616000
tokenName String 过滤指定的 Token 名称 ***
modelName String 过滤指定的模型名称 gemini-3-flash-preview

1.3 返回参数 (Response)

成功响应

  • 状态码: 200 OK
  • 内容类型: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
  • 返回内容: Excel 二进制文件流。

失败响应

  • 401 Unauthorized: Token 缺失或失效。
  • 400 Bad Request: 参数校验不通过(如时间戳格式错误)。

1.4 示例代码

请求示例 (cURL)

curl --location 'https://monitor.ponderera.com/bill/excel' \
--header 'token: ******' \
--header 'Content-Type: application/json' \
--data '{
    "type": 1,
    "startTime": 1769443200,
    "endTime": 1769616000,
    "tokenName": "****",
    "modelName": "gemini-3-flash-preview"
}' --output bill_export.xlsx

2. 账单统计接口文档 (Bill Stats API)

该接口用于根据时间范围、Token 名称或模型名称,查询特定用户的资源消耗统计信息(如 Token 消耗、调用时长及金额)。

2.1 接口信息

  • 请求地址: https://monitor.ponderera.com/bill/stats
  • 请求方式: POST
  • 数据格式: application/json

2.2 请求参数 (Request)

Header 参数

参数名 必选 类型 说明
token String 用户身份验证凭证
Content-Type String 固定为 application/json

Body 参数

参数名 必选 类型 示例 说明
type Integer 1 统计维度类型(例如:1=分钟 2=小时 3=天 4=周 5=月)
startTime Long 1769443200 起始时间戳(秒)
endTime Long 1769616000 截止时间戳(秒)
tokenName String "token1" 指定 Token 名称,用于过滤特定 token 的统计
modelName String "gemini-3-flash-preview" 指定模型名称,用于过滤特定模型的统计

2.3 返回参数 (Response)

基础结构

参数名 类型 说明
message String 状态消息(如 "SUCCESS"
code Integer 状态码(200 表示成功)
data Array 包含统计详情的数组

data 数组对象字段

参数名 类型 示例 说明
time String "2026-02-06 00:00:00" 该组统计数据对应的时间(格式化字符串)
timeGroup Long 1769591640 该组统计数据的时间戳(秒)
userName String "admin" 用户登录名
tokenName String "token1" 使用的 Token 名称
modelName String "gemini-3-flash-preview" 模型名称
totalPromptTokens Integer 4096 累计输入的 Prompt Token 数
totalCompletionTokens Integer 1386 累计输出的 Completion Token 数
totalCacheTokens Integer 1386 累计使用的 Cache Token 数
totalCacheCreationTokens Integer 1386 累计使用的 CacheCreation Token 数
totalUseTime Integer 15 总消耗时长(单位:秒)
callCount Integer 1 该时间段内的调用次数
totalAmount Float 0.006206 总消耗金额(单位:USD)

2.4 示例代码

请求示例 (cURL)

curl --location 'https://monitor.ponderera.com/bill/stats' \
--header 'token: ******10B8F1532F0C82F99642E4AFF' \
--header 'Content-Type: application/json' \
--data '{
   "type": 1,
   "startTime": 1769443200,
   "endTime": 1769616000,
   "tokenName": "token1",
   "modelName": "gemini-3-flash-preview"
}'

返回示例 (JSON)

{
  "message": "SUCCESS",
  "code": 200,
  "data": [
    {
      "time": "2026-02-06 00:00:00",
      "timeGroup": 1770307200,
      "userName": "**",
      "tokenName": "文献抽取",
      "modelName": "gemini-3-flash-preview",
      "totalPromptTokens": 8927,
      "totalCompletionTokens": 143,
      "totalCacheTokens": 0,
      "totalCacheCreationTokens": 0,
      "totalUseTime": 6,
      "callCount": 1,
      "totalAmount": 0.012588
    }
  ]
}