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%.
VariableRequiredDefaultDescriptionAPI_COST_MODELNoopenaiProvider: openai, anthropic, minimax, lmstudio``API_COST_INTERVALNoweeklyReport interval: daily, weekly, monthly``HEARTBEAT_INTERVALNoautoOverride heartbeat interval in seconds (auto-detect if not set)MODEL_PRICE_INPUTNoautoPrice per 1M input tokens (auto-selected by provider)MODEL_PRICE_OUTPUTNoautoPrice per 1M output tokens (auto-selected by provider)
ProviderModelInputOutputOpenAIGPT-4o$2.50$10.00OpenAIGPT-4o-mini$0.15$0.60OpenAIGPT-4-turbo$10.00$30.00AnthropicClaude 3.5 Sonnet$3.00$15.00AnthropicClaude 3 Opus$15.00$75.00MiniMaxMiniMax-M2$0.10$0.10MiniMaxMiniMax-M2.1$0.20$0.40
Runs a complete cost diagnostic on the current OpenClaw configuration.
bash
./scripts/analyze.sh
Output: Detailed markdown report with:
Checks OpenClaw heartbeat configuration and calculates wasted API calls.
bash
./scripts/heartbeat_diagnosis.sh
Output: Heartbeat efficiency score (0–100%), wasted calls per day, estimated annual waste.
One-shot estimate with optional custom parameters.
bash
./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:
bash
# 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