> ## Documentation Index
> Fetch the complete documentation index at: https://docs.clawflow.daboluo.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# 计费与额度

> 了解 ClawFlow 的计费模型：订阅 Plan + 按需充值，本地 Worker 免费。

## 计费模型

ClawFlow 采用 **订阅 + 按需（Plan + On-demand）** 混合计费：

* **Plan 订阅**：月付固定费用，获得包含额度（付得多折扣越大）
* **On-demand 充值**：额外预充值余额，Plan 额度用完后自动扣除
* **按结果付费**：只有成功提交 PR 才消耗额度，失败和跳过不扣费

## 定价方案

| Plan       | 月费       | 包含额度          | 倍率   | 单次成本        | 超出处理        |
| ---------- | -------- | ------------- | ---- | ----------- | ----------- |
| Free       | \$0      | \$10（一次性注册赠送） | —    | 2.0x markup | 用完暂停        |
| Starter    | \$20/mo  | \$30/mo       | 1.5x | 1.5x markup | 扣 on-demand |
| Pro        | \$100/mo | \$200/mo      | 2x   | 1.3x markup | 扣 on-demand |
| Enterprise | \$200/mo | \$500/mo      | 2.5x | 1.2x markup | 扣 on-demand |

### Markup 说明

Markup 是平台对实际 LLM API 成本的加价倍率。例如一次 pipeline 实际调用 Claude API 花费 \$0.10：

* Free 用户扣费：$0.10 × 2.0 = **$0.20\*\*
* Starter 用户扣费：$0.10 × 1.5 = **$0.15\*\*
* Pro 用户扣费：$0.10 × 1.3 = **$0.13\*\*
* Enterprise 用户扣费：$0.10 × 1.2 = **$0.12\*\*

高档位用户每次 pipeline 运行成本更低。

## 扣费优先级

1. 先扣 **Plan 月度额度**（每月重置）
2. 月度额度用完 → 扣 **On-demand 余额**（永不过期）
3. 都用完 → 暂停执行，通知用户升级或充值

## 两种执行模式

|      | Cloud（SaaS 算子）         | Local（本地 Worker） |
| ---- | ---------------------- | ---------------- |
| 执行环境 | ClawFlow 平台托管          | 你自己的机器           |
| 额度消耗 | 按实际 API 用量 × markup 扣费 | **不扣费**          |
| 用量统计 | Dashboard 可见           | Dashboard 可见     |
| 适用场景 | 零运维、开箱即用               | 自带 API Key、完全控制  |

### Cloud 模式

Issue 触发后由 ClawFlow 平台调度执行，使用平台提供的算力资源。费用按实际 LLM API 调用量 × markup 计算。

### Local 模式

通过 `clawflow worker start` 在本地启动 Worker，任务在你自己的机器上执行，使用你自己的 API Key。平台只记录用量明细（方便你追踪成本），**不从账户额度中扣除**。

```bash theme={null}
# 登录并启动本地 Worker
clawflow login --saas-url https://clawflow.daboluo.cc
clawflow worker start
```

## 用量看板

Dashboard 提供 Cloud / Local 分离的用量统计：

* **Cloud 用量**：input/output tokens、缓存命中、总费用、运行次数
* **Local 用量**：同样的统计维度，帮你管理本地 Worker 的 API 开销
* **Plan 额度**：本月已用 / 包含额度，剩余可用

## API

* `GET /api/v1/billing/balance` — 查询当前余额（plan 额度 + on-demand）
* `GET /api/v1/billing/plan` — 查询当前 plan 详情
* `GET /api/v1/billing/history` — 查询充值/扣费记录
* `GET /api/v1/billing/usage` — 查询 Cloud vs Local 用量明细
* `POST /api/v1/billing/topup` — On-demand 充值
* `POST /api/v1/billing/subscribe` — 订阅/升级 Plan

## 安全隔离

* Cloud 和 Local 执行路径完全隔离，互不影响
* 本地 Worker 无法被误认为平台算子，不会产生意外扣费
* 所有 VCS Token 使用 AES-256-GCM 加密存储，仅在执行时注入内存
