跳转到主要内容
钱包流水。每一笔触及余额的 credit 或 debit,按 created_at 倒序。 镜像 console.bytespike.ai/billing 上的表格。免费。

何时选用

  • 对账某笔 Stripe 收据与余额变动
  • 导出 CSV 给会计
  • 检测平台管理员的调整admin_credit / admin_debit
要看每次调用的花费(而非余额变动),用 GET /me/usage。 要看 per-key 汇总,用 GET /balance

Request

curl 'https://llm.bytespike.ai/api/v1/me/billing/transactions?page=1&page_size=50' \
  -H "Authorization: Bearer $BYTESPIKE_API_KEY"

Query 参数

ParamTypeNotes
pageinteger默认 1
page_sizeinteger默认 50,最大 200
kindstring过滤:topup / refund / admin_credit / admin_debit / subscription_renew
sincestringISO 时间戳 —— 仅返回此刻起(含)的条目。
untilstringISO 时间戳 —— 仅返回此刻前(不含)的条目。

Response

{
  "items": [
    {
      "id": 901234,
      "created_at": "2026-05-21T14:08:11Z",
      "kind": "topup",
      "amount_usd": 50.00,
      "balance_after_usd": 81.40,
      "source": {
        "provider": "stripe",
        "receipt_id": "ch_3PYj...mock-49",
        "method": "card_visa_4242"
      },
      "note": null
    },
    {
      "id": 901188,
      "created_at": "2026-05-15T08:14:02Z",
      "kind": "admin_credit",
      "amount_usd": 5.00,
      "balance_after_usd": 31.40,
      "source": {"actor": "ops@bytespike.ai"},
      "note": "Goodwill credit — failed Doubao call burst, ticket #312"
    }
  ],
  "total": 47,
  "page": 1,
  "page_size": 50
}

Response 字段

FieldTypeNotes
items[].kindstringtopup(卡 / 电汇)、refund(失败调用回滚)、admin_credit / admin_debitsubscription_renew
items[].amount_usdnumber带符号:credit 为正,debit 为负。
items[].balance_after_usdnumber该条目入账后的钱包快照。便于对账。
items[].sourceobject按 kind 不同结构 —— topupprovider + receipt_id;admin 条目是 actor
items[].notestring | null写入时附的自由文本(仅 admin 条目)。
totalinteger匹配过滤的总行数(与 page 无关)。

错误

Statuserror.type触发条件
400invalid_request_errorpage / page_size 越界,或 since 无法解析。
401authentication_errorkey 缺失 / 已撤销。

示例 —— CSV 导出

import csv, requests, os, sys

headers = {"Authorization": f"Bearer {os.environ['BYTESPIKE_API_KEY']}"}
page, all_rows = 1, []
while True:
    r = requests.get(
        "https://llm.bytespike.ai/api/v1/me/billing/transactions",
        params={"page": page, "page_size": 200},
        headers=headers,
        timeout=10,
    ).json()
    all_rows.extend(r["items"])
    if page * r["page_size"] >= r["total"]:
        break
    page += 1

w = csv.DictWriter(sys.stdout, fieldnames=["created_at", "kind", "amount_usd", "balance_after_usd"])
w.writeheader()
for row in all_rows:
    w.writerow({k: row[k] for k in w.fieldnames})