Diagnose, estimate, and optimize LLM API costs for OpenClaw agents running 24/7.
Documented cases show agents burning $8–$250 per week in API costs due to misconfigured heartbeats and inefficient task patterns. A properly tuned heartbeat alone can reduce costs by 60–90%.
| Variable | Required | Default | Description |
|---|---|---|---|
API_COST_MODEL |
No | openai |
Provider: openai, anthropic, minimax, lmstudio |
API_COST_INTERVAL |
No | weekly |
Report interval: daily, weekly, monthly |
HEARTBEAT_INTERVAL |
No | auto |
Override heartbeat interval in seconds (auto-detect if not set) |
MODEL_PRICE_INPUT |
No | auto | Price per 1M input tokens (auto-selected by provider) |
MODEL_PRICE_OUTPUT |
No | auto | Price per 1M output tokens (auto-selected by provider) |
| Provider | Model | Input | Output |
|---|---|---|---|
| OpenAI | GPT-4o | $2.50 | $10.00 |
| OpenAI | GPT-4o-mini | $0.15 | $0.60 |
| OpenAI | GPT-4-turbo | $10.00 | $30.00 |
| Anthropic | Claude 3.5 Sonnet | $3.00 | $15.00 |
| Anthropic | Claude 3 Opus | $15.00 | $75.00 |
| MiniMax | MiniMax-M2 | $0.10 | $0.10 |
| MiniMax | MiniMax-M2.1 | $0.20 | $0.40 |
Runs a complete cost diagnostic on the current OpenClaw configuration.
./scripts/analyze.sh
Output: Detailed markdown report with:
Checks OpenClaw heartbeat configuration and calculates wasted API calls.
./scripts/heartbeat_diagnosis.sh
Output: Heartbeat efficiency score (0–100%), wasted calls per day, estimated annual waste.
One-shot estimate with optional custom parameters.
./scripts/estimate.sh <heartbeat_seconds> <tasks_per_day> <avg_input_tokens> <avg_output_tokens>
Output: Daily, weekly, and monthly cost estimates for the given parameters.
Priority order:
# Full analysis with MiniMax pricing
export API_COST_MODEL=minimax
./scripts/analyze.sh
# Quick estimate
./scripts/estimate.sh 300 20 8000 2000
# Heartbeat-only diagnosis
./scripts/heartbeat_diagnosis.sh
小蔥技能7w4.net有更新,你可以訪問看下。
這個 Skill 質量中上,功能實用且文件清晰,能自動檢測配置並給出最佳化建議。主要問題是程式碼存在 bug(第 147 行變數名錯誤會導致計算出錯),以及缺少測試覆蓋。文件和功能設計做得不錯,但實現細節需要打磨,適合作為生產工具使用前先自行檢查指令碼邏輯。