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 参数
| Param | Type | Notes |
|---|---|---|
page | integer | 默认 1。 |
page_size | integer | 默认 50,最大 200。 |
kind | string | 过滤:topup / refund / admin_credit / admin_debit / subscription_renew。 |
since | string | ISO 时间戳 —— 仅返回此刻起(含)的条目。 |
until | string | ISO 时间戳 —— 仅返回此刻前(不含)的条目。 |
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 字段
| Field | Type | Notes |
|---|---|---|
items[].kind | string | topup(卡 / 电汇)、refund(失败调用回滚)、admin_credit / admin_debit、subscription_renew。 |
items[].amount_usd | number | 带符号:credit 为正,debit 为负。 |
items[].balance_after_usd | number | 该条目入账后的钱包快照。便于对账。 |
items[].source | object | 按 kind 不同结构 —— topup 是 provider + receipt_id;admin 条目是 actor。 |
items[].note | string | null | 写入时附的自由文本(仅 admin 条目)。 |
total | integer | 匹配过滤的总行数(与 page 无关)。 |
错误
| Status | error.type | 触发条件 |
|---|---|---|
| 400 | invalid_request_error | page / page_size 越界,或 since 无法解析。 |
| 401 | authentication_error | key 缺失 / 已撤销。 |
示例 —— 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})