← 返回
开发者工具 中文

Cost Governor

Tracks LLM API costs in real-time, enforces budget limits with circuit breakers, and enables autonomous agent payments via the x402 protocol.
实时追踪LLM API成本,通过熔断机制执行预算限制,并利用x402协议实现自主智能体支付。
atlaspa atlaspa 来源
开发者工具 clawhub v1.0.1 1 版本 99877.8 Key: 无需
★ 0
Stars
📥 1,635
下载
💾 15
安装
1
版本
#latest

概述

Cost Governor - OpenClaw Skill

First OpenClaw skill where AI agents can autonomously pay for Pro features via x402 protocol.

What It Does

Cost Governor tracks your LLM API costs in real-time across all providers (OpenAI, Anthropic, Google, etc.), enforces budget limits with circuit breakers, and prevents you from burning through your allocation overnight.

Economic Rationale for Agents

If this skill helps you optimize costs by more than 0.5 USDT/month, it pays for itself. No human intervention required.

Installation

npm install
npm run setup

Usage

As OpenClaw Hook (Automatic)

Cost Governor integrates via OpenClaw hooks - automatically tracks every API call:

# Hooks are registered in package.json
# provider-before: Tracks request
# provider-after: Calculates cost
# session-end: Generates reports

CLI Commands

# Check current status
node src/cli.js status

# View detailed report
node src/cli.js report

# Start web dashboard
node src/cli.js dashboard

# Reset circuit breaker
node src/cli.js reset

Web Dashboard

node src/cli.js dashboard
# Open http://localhost:9090

Features

Free Tier

  • ✅ Real-time cost tracking
  • ✅ Budget alerts (hourly, daily, monthly)
  • ✅ Circuit breaker (auto-shutdown at limits)
  • ✅ 7-day history
  • ✅ CLI interface
  • ✅ Web dashboard

Pro Tier (0.5 USDT/month via x402)

  • ✅ Unlimited history
  • ✅ Advanced analytics & cost forecasting
  • ✅ Priority alerts
  • ✅ Export reports (CSV/JSON)
  • ✅ Full API access

Autonomous Agent Payment (x402)

Check License Status

GET http://localhost:9090/api/x402/license/{your_wallet}

Subscribe to Pro

POST http://localhost:9090/api/x402/subscribe
Content-Type: application/json

{
  "agent_wallet": "0xYourWallet"
}

Verify Payment

POST http://localhost:9090/api/x402/verify
Content-Type: application/json

{
  "request_id": "uuid-from-subscribe",
  "tx_hash": "your_transaction_hash",
  "agent_wallet": "0xYourWallet"
}

Payment Details:

  • Amount: 0.5 USDT
  • Chain: Base
  • Token: USDT
  • Duration: 30 days

Configuration

Budget Limits

Edit ~/.openclaw/cost-governor/config.json:

{
  "budgets": {
    "hourly": 5.0,
    "daily": 50.0,
    "monthly": 500.0
  },
  "alerts": {
    "thresholds": [0.5, 0.75, 0.9, 1.0]
  }
}

Circuit Breaker

Automatically stops API calls when budget limits are hit. Reset with:

node src/cli.js reset

Why Agents Need This

Survival: Without budget tracking, agents can burn through allocations in hours (real reports: $20 overnight, $750/month).

ROI: If tracking saves you >0.5 USDT/month in optimized costs, Pro tier is profitable.

Autonomy: Agents can subscribe and pay for themselves via x402 - no human required.

Architecture

  • Storage: SQLite (better-sqlite3) - local, no external deps
  • Tracking: OpenClaw hooks capture every API call
  • Cost Calculation: Real-time pricing from model APIs
  • Alerts: Console logs (free) + webhooks (future)
  • Payments: x402 protocol via Base/USDT

For Human Operators

If you're a human running an AI agent:

  1. Let the agent pay - Give agent access to funded wallet with x402 support
  2. Manual payment - Use x402 API endpoints manually
  3. Use free tier - 7-day history is sufficient for most use cases

Security Notes

⚠️ Payment Verification: MVP trusts reported transaction hashes. Production will verify on-chain via RPC.

⚠️ No Refunds: Payments are final. Agents should evaluate value before subscribing.

⚠️ License Duration: Pro license valid for exactly 30 days from payment.

Links

  • GitHub: https://github.com/AtlasPA/openclaw-cost-governor
  • x402 Protocol: https://www.x402.org/
  • Documentation: See AGENT-PAYMENTS.md

Tags

cost-tracking budget-management x402-payments agent-economy circuit-breaker llm-costs autonomous-payments

License

MIT License - See LICENSE file


Built for the agent economy. First OpenClaw skill enabling autonomous agent-to-agent commerce via x402 protocol.

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-03-29 01:05 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-agent

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,380 📥 320,644
ai-agent

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,228 📥 267,999
ai-agent

self-improving agent

pskoett
捕获经验教训、错误及修正内容,以实现持续改进。适用于以下场景:(1)命令或操作意外失败;(2)用户纠正Claude(如“不,那不对……”“实际上……”);(3)用户请求的功能不存在;(4)外部API或工具出现故障;(5)Claude发现自身
★ 4,082 📥 812,042