> For the complete documentation index, see [llms.txt](https://docs.blockchainsecurity.asia/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.blockchainsecurity.asia/documentation/he-xin-gai-nian/credit-billing.md).

# Credit 計費

BCS API 採 credit 點數制計費。每把 API key 都有獨立的 credit 額度；系統會依 API endpoint、查詢成本與方案設定計算扣點。

Credit 用於控管 API 用量與成本，不代表實際法幣價格。實際方案、單價與加值方式依合約或報價單為準。

## 核心原則

{% hint style="success" %}
核心原則

只有成功且需計費的 HTTP 2xx 回應才會扣除 credit。任何錯誤回應，包括 4xx 與 5xx，皆不扣點。
{% endhint %}

• 不同 endpoint 依查詢成本設定不同扣點權重。例如基礎資料查詢成本較低，資金流追蹤、風險分析或市場行為分析成本較高。

• 管理後台、健康檢查與部分沙盒試用端點不扣點。

• 每次成功回應會在 response.meta 與部分 response header 中回傳本次扣點與剩餘額度。

## 如何得知本次花費

成功回應會回傳本次扣點與剩餘額度。建議以 response.meta 作為系統對帳依據，response header 可作為即時監控與除錯輔助。

| 來源     | 欄位                   | 意義                                       |
| ------ | -------------------- | ---------------------------------------- |
| `meta` | `credit_cost`        | 本次請求扣除的 credit                           |
| `meta` | `credit_remaining`   | 扣點後的剩餘 credit                            |
| Header | `X-Credit-Cost`      | 本次請求扣除的 credit，對應 `meta.credit_cost`     |
| Header | `X-Credit-Remaining` | 扣點後的剩餘 credit，對應 `meta.credit_remaining` |

```json
{
  "data": { "...": "..." },
  "meta": { "credit_cost": 5, "credit_remaining": 9995 }
}
```

## 餘額不足

當剩餘 credit 不足以支付本次請求時，系統會回傳 402 insufficient\_credit。該請求不會被處理，也不會扣點。

```json
{
  "error": {
    "code": "insufficient_credit",
    "message": "insufficient credit: required 5, remaining 2"
  }
}
```

請聯絡管理員增加 credit、調整方案或切換至具足夠額度的 API key 後，再重新送出請求。

## 對帳

每筆扣點紀錄都會寫入不可覆寫的用量帳本，並記錄 request\_id、API key、endpoint、扣點數、扣點後餘額與請求時間。客戶可依 request\_id 對應 API 回應、客服紀錄與內部交易流水，進行事後對帳與稽核。

{% hint style="info" %}
建議：客戶系統可在每次成功回應後讀取 meta.remaining\_credits 或 X-Credit-Remaining，並在額度低於內部門檻時觸發提醒，避免正式服務中斷。
{% endhint %}

## 下一步

{% content-ref url="/pages/JTozQ5Gb9ly2bavrljBP" %}
[分頁](/documentation/he-xin-gai-nian/pagination.md)
{% endcontent-ref %}
