← 返回 Skills 市场
kryzl19

Api Cost Optimizer

作者 KRYZL19 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
99
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install api-cost-optimizer-kryzl19
功能描述
Analyze OpenClaw agent configuration and API usage patterns to identify cost-saving opportunities. Diagnose inefficient heartbeat configs, estimate daily/wee...
使用说明 (SKILL.md)

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

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 Default Pricing (per 1M tokens)

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

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 \x3Cheartbeat_seconds> \x3Ctasks_per_day> \x3Cavg_input_tokens> \x3Cavg_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
安全使用建议
This skill is overall coherent with its stated purpose — it inspects your OpenClaw config and estimates API costs — but before installing or running it, do the following: (1) Review the included shell scripts yourself (they run locally and read files under $HOME/.openclaw). (2) Note a small but important bug: analyze.sh references an undefined variable (TOOL_CALLS_DAY) which will break or produce incorrect tool-overhead calculations; expect some inaccurate outputs until fixed. (3) The package declares curl as required though scripts don't use it — likely a harmless mismatch but a sign of sloppy packaging. (4) Because the scripts read your OpenClaw config files, those files might include API keys or other secrets; run the scripts in a safe environment or inspect the files first if you are concerned about accidental logging or output. (5) There are no network calls in the code, so data should remain local — still verify by inspection. If you lack the expertise, ask the publisher to fix the code issues (undefined variable, remove unused required binaries) and confirm that no telemetry/exfiltration is intended before using on production hosts.
功能分析
Type: OpenClaw Skill Name: api-cost-optimizer-kryzl19 Version: 1.0.0 The skill bundle is a utility for analyzing and optimizing LLM API costs for the OpenClaw platform. The scripts (analyze.sh, estimate.sh, and heartbeat_diagnosis.sh) function as described, reading local configuration files from ~/.openclaw/ to calculate heartbeat frequency and estimated token usage. There is no evidence of data exfiltration, network activity, or malicious intent; the logic is transparent and strictly aligned with the stated purpose of cost management.
能力评估
Purpose & Capability
Name/description align with behavior: scripts parse ~/.openclaw configs, count skills, estimate costs and give recommendations — all consistent with cost analysis. Minor mismatch: 'curl' is declared as a required binary but none of the scripts actually call curl.
Instruction Scope
Runtime instructions and scripts stay within the stated scope: they read OpenClaw config files (~/.openclaw/openclaw.json and per-agent JSON), enumerate skill/workspace directories, compute cost estimates, and print recommendations. They do not make network calls or attempt to exfiltrate data.
Install Mechanism
No install spec or remote downloads are present. The skill is instruction-plus-scripts only, so nothing is fetched from external URLs during install.
Credentials
The skill requests no credentials and only uses optional env vars documented in SKILL.md (API_COST_MODEL, API_COST_INTERVAL, HEARTBEAT_INTERVAL, etc.). However, the scripts read arbitrary files under $HOME/.openclaw which could contain tokens or other sensitive config — this access is consistent with purpose but worth reviewing.
Persistence & Privilege
always:false and no modifications to other skills or global config. Scripts only read files and print reports; they do not persist new credentials or enable themselves.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install api-cost-optimizer-kryzl19
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /api-cost-optimizer-kryzl19 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial release of API Cost Optimizer for OpenClaw agents - Analyzes agent configs to estimate daily/weekly API spend and prioritize cost-saving recommendations - Diagnoses inefficient heartbeat intervals, quantifies wasted API calls, and suggests optimizations - Generates detailed markdown reports with model/tool risk factors and savings estimates - Includes analysis, heartbeat efficiency, and fast cost estimation scripts for real-time insights - Supports customizable pricing for OpenAI, Anthropic, and MiniMax providers
元数据
Slug api-cost-optimizer-kryzl19
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Api Cost Optimizer 是什么?

Analyze OpenClaw agent configuration and API usage patterns to identify cost-saving opportunities. Diagnose inefficient heartbeat configs, estimate daily/wee... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 99 次。

如何安装 Api Cost Optimizer?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install api-cost-optimizer-kryzl19」即可一键安装,无需额外配置。

Api Cost Optimizer 是免费的吗?

是的,Api Cost Optimizer 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Api Cost Optimizer 支持哪些平台?

Api Cost Optimizer 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Api Cost Optimizer?

由 KRYZL19(@kryzl19)开发并维护,当前版本 v1.0.0。

💬 留言讨论