计费 API
用量、账单、交易与计费方案管理。组前缀 /api/v1/billing,需 Authorization: Bearer <token>。
版本说明:本组端点两者都提供;
departments(部门成本)为企业版管理台能力。
端点一览
| 方法 | 路径 | 说明 |
|---|---|---|
GET | /api/v1/billing/summary | 用量与账单汇总 |
GET | /api/v1/billing/trend | 用量趋势 |
GET | /api/v1/billing/invoices | 账单列表 |
GET | /api/v1/billing/transactions | 交易流水 |
GET | /api/v1/billing/transactions/summary | 交易汇总 |
POST | /api/v1/billing/transactions/sync | 触发交易同步 |
GET | /api/v1/billing/departments | 部门成本(企业) |
GET | /api/v1/billing/plans/current | 当前计费方案 |
PUT | /api/v1/billing/plans/current | 变更计费方案 |
GET /api/v1/billing/summary
用量与账单汇总。
响应:
json
{
"code": 0,
"data": {
"month_total": 38.5,
"today_total": 4.2,
"llm_tokens": 1520340,
"sandbox_minutes": 265
},
"message": "ok",
"request_id": "req_abc123"
}GET /api/v1/billing/plans/current
响应:
json
{
"code": 0,
"data": {
"id": "plan_pro",
"name": "Pro",
"price": 99.0,
"token_quota": 5000000,
"description": "含 Pro 模型档位"
},
"message": "ok",
"request_id": "req_abc123"
}PUT /api/v1/billing/plans/current
请求:
json
{ "plan_id": "plan_enterprise" }交易流水
GET /api/v1/billing/transactions 返回条目含 id、period、amount、status、created_at。POST /api/v1/billing/transactions/sync 触发一次与云端 Hub 的对账同步。
错误码
| 场景 | code | message |
|---|---|---|
| 计费方案不存在 | 40400 | 计费方案不存在 |
| 配额不足 | 40200 | 配额不足 |
| 同步失败 | 50000 | 对账同步失败 |