# 自动充值

余额低于阈值时自动从默认付款方式扣款，避免请求因 `insufficient_balance` 失败。本页讲控制台设置。计费侧概念与退款影响见 [账户 → 自动充值](/helodata-zh/zhang-hu-yu-ji-fei/auto-topup.md)。

## 启用

1. **账单 → 自动充值 → 启用**。
2. 填写：
   * **阈值** — 余额低于此美元数即触发
   * **充值金额** — 每次触发扣款金额
   * **付款方式** — 选已保存的卡
   * **日上限** — 单日最大扣款（安全防线）
3. **保存**。

\[screenshot: 自动充值设置]

### 推荐取值

| 工作量          | 阈值   | 充值金额   | 日上限    |
| ------------ | ---- | ------ | ------ |
| 业余（<10 GB/月） | $5   | $20    | $20    |
| 小团队          | $50  | $200   | $500   |
| 生产           | $500 | $2,000 | $5,000 |

日上限是安全网——没有它，异常循环（如反复触发限流的爬虫）可能引发失控扣款。

## 触发时机

每次计费事件**前**检查：

* 网关：每次会消耗流量的请求
* API：每次 `POST /orders`
* 续费：订阅续费时

余额 < 阈值时，**仅该请求**短暂等待卡扣完后继续。代价是触发请求多出约 2 秒的卡扣延迟——这就是阈值要高于 0 的原因。

## 卡扣失败怎么办

原请求以 `insufficient_balance` 失败。我们会：

1. 立即邮件告知。
2. 把付款方式标记为 **失败中**；下次流量请求会用同卡再试。
3. 连续 3 次失败后自动充值暂停，需你介入。

有第二张卡时把它设为**默认**先撑过去。

## 关闭 / 暂停

* **暂停** — 临时关闭但保留配置。测试时常用。
* **禁用** — 彻底删除配置，通过同一表单可重启。

## 一次性手动充值

不想自动扣的可手动充：

**账单 → 付款方式 → 充值** → 选金额 → 确认。余额立即到账。

## 自动充值 + 订阅

自动充值针对**预付余额**。订阅（月度套餐）在续费日**直接扣卡**，不动用余额（除非余额够覆盖整笔续费）。

所以同时开 $500/月 订阅 **和** $50 阈值自动充值时：

1. 续费日卡上扣 $500（订阅）
2. 当余额按请求扣到 $50 时，另外扣 $200（自动充值）

## API

```bash
curl -X POST -H "Authorization: Bearer API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
       "threshold_usd":   50,
       "topup_amount_usd": 200,
       "payment_method_id": "pm_01HX...",
       "daily_cap_usd":    500
     }' \
     https://api.helodata.com/v1/billing/auto-topup
```

## 常见陷阱

* **阈值太低（如 $1）** — 触发时可能已到 0。阈值要高于最坏情况下 1 秒的支出。
* **日上限太紧** — 生产负载在压测时容易突破。按你能接受的**最大**日支出设定。
* **没有备用卡** — 唯一卡在续费日附近失败时订阅也会失败。请在 **付款方式** 添加备用卡。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.helodata.com/helodata-zh/kong-zhi-tai/auto-topup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
