← 返回
未分类 中文

Api Cost Optimizer

Analyze OpenClaw agent configuration and API usage patterns to identify cost-saving opportunities. Diagnose inefficient heartbeat configs, estimate daily/wee...
分析 OpenClaw 代理配置和 API 使用模式,识别费用节省机会。诊断低效的心跳配置,估计每日/每周...
kryzl19 kryzl19 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 323
下载
💾 0
安装
1
版本
#latest

概述

API Cost Optimizer

Diagnose, estimate, and optimize LLM API costs for OpenClaw agents running 24/7.

What This Skill Does

  • Estimates API spend from agent configuration (model, heartbeat interval, task complexity)
  • Diagnoses heartbeat waste — the #1 cause of runaway API bills
  • Counts and categorizes tools the agent has access to
  • Produces a cost report with prioritized recommendations
  • Estimates time-to-payback for any recommended changes

The Problem This Solves

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%.

Environment Variables

VariableRequiredDefaultDescription
------------------------------------------
API_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)

Provider Default Pricing (per 1M tokens)

ProviderModelInputOutput
--------------------------------
OpenAIGPT-4o$2.50$10.00
OpenAIGPT-4o-mini$0.15$0.60
OpenAIGPT-4-turbo$10.00$30.00
AnthropicClaude 3.5 Sonnet$3.00$15.00
AnthropicClaude 3 Opus$15.00$75.00
MiniMaxMiniMax-M2$0.10$0.10
MiniMaxMiniMax-M2.1$0.20$0.40

Scripts

analyze.sh — Full Cost Analysis

Runs a complete cost diagnostic on the current OpenClaw configuration.

./scripts/analyze.sh

Output: Detailed markdown report with:

  • Estimated API spend (daily / weekly / monthly)
  • Heartbeat cost analysis
  • Tool count risk factor
  • Top 3 cost reduction recommendations
  • Estimated savings after optimization

heartbeat_diagnosis.sh — Find Heartbeat Waste

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.

estimate.sh — Quick Cost Estimate

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.

Cost Reduction Recommendations

Priority order:

  1. Increase heartbeat interval — If heartbeat is under 5 minutes, increase to 10–30 min for idle agents
  2. Switch to cheaper model — MiniMax M2 at $0.10/1M is 25x cheaper than GPT-4o for most tasks
  3. Batch tasks — Run 5–10 tasks per session instead of 1 task per heartbeat cycle
  4. Cache responses — Use memory skills to avoid repeated context
  5. Disable verbose logging — Reduces token churn in long conversations

Usage Example

# 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

Notes

  • Estimates are based on configuration analysis, not live API metering
  • For actual spend tracking, enable provider cost logs and compare
  • MiniMax models offer best price/performance for volume workloads
  • Heartbeat waste is typically the single largest cost lever

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-07 05:25 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

data-analysis

Data Analysis

ivangdavila
{"answer":"数据分析与可视化。查询数据库、生成报告、自动化电子表格,将原始数据转化为清晰可行的见解。适用于:(1) 您……"}
★ 216 📥 71,370
data-analysis

AdMapix

fly0pants
AdMapix 原始数据层,提供广告创意、应用、排名、下载/收入及市场元数据。返回 AdMapix API 的结构化 JSON;调用方...
★ 298 📥 142,848
knowledge-management

Content Summarizer

kryzl19
获取任意URL并生成结构化内容摘要,采用提取式摘要技术,包含AI增强提示和结构化输出模板,提取清洁内容。
★ 1 📥 1,773