openclaw - 💡(How to fix) Fix [Feature]: Feature Request: Pre-request budget/cost check to prevent runaway spending on free tier accounts

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

When using providers with limited free tier quotas (e.g., Alibaba Cloud Qwen 1M free tokens), OpenClaw has no mechanism to check remaining budget before sending a request. If a provider's free quota is exhausted or the account has insufficient balance, each request still hits the API and consumes real money before failing with a 403/400 error. 3. If exceeded, skip the primary model entirely and go directly to fallback or surface an error

Root Cause

This is especially painful because:

  1. Gateway retries and failover happen after the failed request — meaning the cost is already incurred
  2. Even with model fallbacks configured, the primary model is attempted first on every message, burning balance on every failed attempt
  3. The auto fallback primary-probe (every 5 minutes) also sends real requests that consume quota

Code Example

{
  "agents": {
    "defaults": {
      "model": {
        "primary": "qwen/qwen3.7-plus",
        "fallbacks": ["deepseek/deepseek-v4-flash"]
      },
      "spendLimit": {
        "enabled": true,
        "qwen": {
          "maxTokensPerDay": 500000,
          "maxCostPerDay": 0.50
        }
      }
    }
  }
}

### Proposed solution

Something like:
RAW_BUFFERClick to expand / collapse

Summary

Problem

When using providers with limited free tier quotas (e.g., Alibaba Cloud Qwen 1M free tokens), OpenClaw has no mechanism to check remaining budget before sending a request. If a provider's free quota is exhausted or the account has insufficient balance, each request still hits the API and consumes real money before failing with a 403/400 error.

This is especially painful because:

  1. Gateway retries and failover happen after the failed request — meaning the cost is already incurred
  2. Even with model fallbacks configured, the primary model is attempted first on every message, burning balance on every failed attempt
  3. The auto fallback primary-probe (every 5 minutes) also sends real requests that consume quota

Scenario

  • User has 1M free tokens on Alibaba Cloud Qwen
  • Tokens exhausted → every subsequent probe costs real money before failing to 403
  • User may not notice until balance is drained

Proposed Solution

Add a budget/spend tracking configuration that allows OpenClaw to:

  1. Track per-provider daily/monthly token/spend usage
  2. Before sending a request, check if the configured threshold has been exceeded
  3. If exceeded, skip the primary model entirely and go directly to fallback or surface an error

Problem to solve

Something like:

{
  "agents": {
    "defaults": {
      "model": {
        "primary": "qwen/qwen3.7-plus",
        "fallbacks": ["deepseek/deepseek-v4-flash"]
      },
      "spendLimit": {
        "enabled": true,
        "qwen": {
          "maxTokensPerDay": 500000,
          "maxCostPerDay": 0.50
        }
      }
    }
  }
}

### Proposed solution

Something like:

```json
{
  "agents": {
    "defaults": {
      "model": {
        "primary": "qwen/qwen3.7-plus",
        "fallbacks": ["deepseek/deepseek-v4-flash"]
      },
      "spendLimit": {
        "enabled": true,
        "qwen": {
          "maxTokensPerDay": 500000,
          "maxCostPerDay": 0.50
        }
      }
    }
  }
}

### Alternatives considered

_No response_

### Impact

Impact

Affected users/systems/channels: All OpenClaw users with limited/free tier API quotas on any provider (e.g., Alibaba Cloud Qwen free tokens, Google Gemini free tier, etc.)
Severity: Blocks workflow — once quota is exhausted, every message silently drains real money before failing, and the user may not notice until balance is gone
Frequency: Always — happens on every request once the free tier or configured budget is exceeded; 100% reproducible
Consequence: Unexpected real-money charges, drained prepaid balances, user distrust — the current failover mechanism only reacts after cost is incurred, making it unsafe for anyone on free tier or prepaid plans

### Evidence/examples

_No response_

### Additional information

_No response_

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING