← Back to Skills Marketplace
kryzl19

Api Cost Optimizer

by KRYZL19 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
125
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install api-cost-optimizer
Description
Analyze OpenClaw agent configuration and API usage patterns to identify cost-saving opportunities. Diagnose inefficient heartbeat configs, estimate daily/wee...
README (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
Usage Guidance
This skill appears to implement a useful local cost analysis tool, but review and test before trusting it on production agents. Specifically: (1) inspect the three scripts yourself (they are plain bash/python and only read files under $HOME/.openclaw), (2) note the oddities — SKILL.md lists curl as required though curl is unused, and analyze.sh defaults to 'minimax' while SKILL.md claims 'openai' as the default — clarify which provider you expect, (3) the scripts contain a bug/typo (an undefined variable TOOL_CALLS_DAY is referenced) that may cause the analyzer to fail due to set -e; fix or test in a safe environment first, (4) run the scripts as a non-privileged user and on a copy of your OpenClaw config or in a sandbox to confirm outputs, and (5) do not expect any network exfiltration from these scripts, but always review and run them offline if you have sensitive configuration data.
Capability Analysis
Type: OpenClaw Skill Name: api-cost-optimizer Version: 1.0.0 The skill bundle is a utility for analyzing and optimizing LLM API costs by inspecting local OpenClaw configuration files (~/.openclaw/openclaw.json). The scripts (analyze.sh, estimate.sh, and heartbeat_diagnosis.sh) perform cost calculations and provide optimization recommendations based on detected heartbeat intervals and model providers, with no evidence of data exfiltration, unauthorized network access, or malicious intent.
Capability Assessment
Purpose & Capability
The skill's name/description align with its actions: the scripts read OpenClaw config files under ${HOME}/.openclaw, count skills, estimate heartbeat and task costs, and emit recommendations. However, SKILL.md and scripts disagree on the default provider (SKILL.md defaults API_COST_MODEL to 'openai' while analyze.sh defaults to 'minimax'), and the metadata declares 'curl' as a required binary even though none of the scripts invoke curl. These are incoherences (likely sloppy engineering) but not necessarily malicious.
Instruction Scope
The SKILL.md instructs running the included scripts; the scripts' runtime behavior matches those instructions. The scripts only read user-home OpenClaw configuration paths (~/.openclaw/openclaw.json, ~/.openclaw/agents/*/agent.json and workspace/skills) and do not transmit data externally. They parse JSON with python3 and perform local arithmetic and reporting.
Install Mechanism
No install spec is present (instruction-only with bundled scripts). Nothing is downloaded or installed by the skill itself, which minimizes supply-chain risk. Scripts are executed locally by the agent when invoked.
Credentials
No credentials or secret environment variables are required. Several optional env vars are documented (e.g., API_COST_MODEL, HEARTBEAT_INTERVAL), which is reasonable. Still, the scripts' defaults conflict with SKILL.md (openai vs minimax), so intended default behavior may be unclear and should be confirmed before use.
Persistence & Privilege
The skill does not request permanent inclusion (always:false) and does not modify other skills or system-wide agent settings. Scripts only read files; they don't write to system or agent configs.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install api-cost-optimizer
  3. After installation, invoke the skill by name or use /api-cost-optimizer
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
API Cost Optimizer 1.0.0 – Initial Release - Analyze OpenClaw agent configs and API usage to estimate daily, weekly, or monthly spend. - Diagnose inefficient heartbeat intervals and provide a detailed waste analysis. - Generate actionable, prioritized cost-saving recommendations (e.g., tuning heartbeat, model selection, batching). - Offer quick and full-cost estimate scripts with provider-specific default pricing. - Include tool count risk factor and time-to-payback for recommended changes. - Essential diagnostics for 24/7 agent operators seeking to minimize unexpected API bills.
Metadata
Slug api-cost-optimizer
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is Api Cost Optimizer?

Analyze OpenClaw agent configuration and API usage patterns to identify cost-saving opportunities. Diagnose inefficient heartbeat configs, estimate daily/wee... It is an AI Agent Skill for Claude Code / OpenClaw, with 125 downloads so far.

How do I install Api Cost Optimizer?

Run "/install api-cost-optimizer" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Api Cost Optimizer free?

Yes, Api Cost Optimizer is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Api Cost Optimizer support?

Api Cost Optimizer is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Api Cost Optimizer?

It is built and maintained by KRYZL19 (@kryzl19); the current version is v1.0.0.

💬 Comments