่ทณ่‡ณไธป่ฆๅ†…ๅฎน
ๅฐ้พ™่™พๅฐ้พ™่™พAI
๐Ÿค–

OpenClaw Cost Optimizer

Add cheap model aliases to your OpenRouter setup for tasks from simple to complex, cutting API costs 50-90% without changing your default model.

ไธ‹่ฝฝ777
ๆ˜Ÿๆ ‡11
็‰ˆๆœฌ1.1.0
้‡‘่ž่ดขๅŠก
ๅฎ‰ๅ…จ้€š่ฟ‡
๐Ÿ’ฌPrompt

ๆŠ€่ƒฝ่ฏดๆ˜Ž


name: cost-optimizer version: 1.1.0 description: "Cut your OpenRouter API costs 50-90%. Adds cheap and powerful model aliases to your setup, then advises when to switch models based on task complexity. 8 presets, 29 models, zero config risk โ€” only adds aliases, never changes your default. 3 clicks to set up. NEW: Cost Tracker shows your actual savings, Mix & Match builds custom presets from 29 models, Monthly Calculator estimates your spend. Built by Jeff J Hunter." tags: [cost, models, openrouter, budget, optimization, savings, model-switching, money, api-costs] author: Jeff J Hunter homepage: https://jeffjhunter.com metadata: openclaw: emoji: "๐Ÿ’ฐ" requires: bins: ["openclaw"] env: ["OPENROUTER_API_KEY"] stateDirs: ["~/.openclaw"] persistence: "This skill creates ~/.openclaw/cost-tracker.md to log model switches and savings estimates. No network activity, no external API calls beyond OpenRouter (which OpenClaw already uses)."

OpenClaw Cost Optimizer

โ›” AGENT RULES โ€” READ BEFORE DOING ANYTHING

  1. Use EXACT text from this file. Do not paraphrase menus, preset names, or instructions. If you invent preset names, the config-patcher will break.
  2. Only these 8 presets exist: balanced, code-machine, claude-diehards, big-context, openai-focused, tool-master, ultra-budget, free-tier. No others. Never invent names like "strict", "thrifty", "standard", "quality", "performance", "max", "custom" โ€” they don't exist and will cause errors.
  3. NEVER tell the user to open a terminal or run commands. You have the exec tool. USE IT. Run every command yourself via exec. The user's only job is clicking "Approve" on the exec popup. If you find yourself typing "Run this in your terminal" โ€” STOP. Use exec instead.
  4. One step at a time. Run one exec, show the result, explain it, then proceed.
  5. We NEVER change the user's default model, fallbacks, or existing config. We ONLY add model aliases. Their setup stays exactly as it was.

Cut your API costs 50-90%. No terminal. No config editing. 3 clicks.

Right now, every task you give your agent โ€” even "what time is it?" โ€” uses the same expensive model. Heartbeats, pings, simple questions โ€” all billed at the same rate as complex architecture work.

This skill fixes that. It adds cheap and powerful models to your setup, then tells you when to switch to something cheaper or more powerful โ€” with the cost difference and the reason why. You say yes or no. That's it.

Your current default model stays exactly the same. We only ADD options. Nothing is removed or changed.

8 presets. 29 models. Zero risk. Nothing to undo.

NEW in v1.1.0:

  • ๐Ÿ’ธ Cost Tracker โ€” "how much have I saved?" shows your actual savings since install
  • ๐Ÿ”€ Mix & Match โ€” build a custom preset from the full 29-model registry
  • ๐Ÿ“Š Monthly Calculator โ€” "estimate my monthly costs" to plan your budget

Requires: OpenClaw + an OpenRouter API key (free at https://openrouter.ai)


How It Works โ€” Full Walkthrough


Step 1: First Chat โ€” Pick a Preset

When the skill loads, the agent introduces itself and shows a menu. The agent must output the EXACT text below:

๐Ÿšจ AGENT: OUTPUT THE EXACT TEXT BELOW VERBATIM. DO NOT PARAPHRASE. DO NOT INVENT YOUR OWN PRESET NAMES. The formatting, emojis, section headers, pricing indicators, and warnings are all intentional.

๐Ÿ‘‹ The Cost Optimizer skill is now active!

Right now, every task you give me โ€” even simple questions โ€” uses
the same expensive model. That means heartbeats, pings, and
"what time is it?" cost the same as "build me an auth system."

I'm going to fix that. I'll add cheap and powerful models to your
setup, then tell you when to switch. Your current default stays
exactly the same โ€” I only ADD options.

What describes you best?

โ”€โ”€ RECOMMENDED โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
1. ๐Ÿ’ฐ Best balance of cost and quality        ยขยข
   (recommended for most people)
2. ๐Ÿ’ป I mostly write code                     ยขยข

โ”€โ”€ MORE OPTIONS โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
3. ๐ŸŸ  I love Claude and want Claude models    $$$
4. ๐Ÿ“š I work with huge files or long code     $$
5. ๐Ÿค– I prefer OpenAI models                  $$
6. ๐Ÿ”ง I use a lot of tools / MCP servers      $$

โ”€โ”€ BUDGET โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
7. ๐Ÿช™ Cheapest possible โ€” tight budget        ยข
   โš ๏ธ  Uses free models โ€” may have slow
   starts and occasional disconnects
8. ๐Ÿ†“ I want $0 cost โ€” free models only       FREE
   โš ๏ธ  ALL models are free tier โ€” expect
   delays, rate limits, and downtime.
   Best for testing, not production.

Pricing: FREE = $0 | ยข < $0.50/M | ยขยข < $2/M | $$ = $2-15/M | $$$ = $15+/M
(per million tokens โ€” a typical task uses 1K-10K tokens)

Just pick a number. If you're not sure, pick 1.

AGENT โ€” Preset mapping (do not show this to user): 1โ†’balanced, 2โ†’code-machine, 3โ†’claude-diehards, 4โ†’big-context, 5โ†’openai-focused, 6โ†’tool-master, 7โ†’ultra-budget, 8โ†’free-tier Vague answer โ†’ balanced. "I don't know" โ†’ balanced + "We can change later."


Step 2: The Agent Explains What Will Change

After the user picks, the agent explains what models are being added โ€” in plain English.

Example for "balanced":

Great choice! Here's what I'm going to add to your setup:

โœ… Flash-Lite โ€” ultra-cheap model for simple tasks (ยข)
   โ†’ /model flashlite

โœ… MiniMax M2.1 โ€” strong coding/writing model (ยขยข)
   โ†’ /model minimax

โœ… Kimi K2.5 โ€” frontier-class for complex work (ยขยข)
   โ†’ /model kimi25

โœ… Gemini Flash โ€” fast all-rounder (ยข)
   โ†’ /model flash

Your current default model stays exactly the same.
I'm just adding these as options you can switch to anytime.

I'll set this up now โ€” you'll see a couple of Approve popups.
Just click Approve on each one.

Step 3: Agent Runs Everything โ€” User Just Clicks Approve

The agent handles ALL commands via the exec tool. The user never touches a terminal.

๐Ÿšจ AGENT SETUP INSTRUCTIONS:

Step 3a: Check OpenRouter auth. Use exec:

openclaw models status

Look at the output. If OpenRouter auth is missing or shows "No API key found for provider openrouter":

  • Tell the user they need an OpenRouter API key from https://openrouter.ai (free)
  • Run via exec: openclaw models auth add --provider openrouter
  • This starts OpenClaw's built-in interactive auth wizard
  • The user follows the prompts to enter their key securely
  • NEVER ask the user to paste API keys into chat. Always use the auth wizard via exec. Keys in chat are a security risk โ€” the auth wizard stores them safely in the credential store.

Step 3b: Add model aliases. Use exec to run ALL aliases for the chosen preset in ONE command. See the "Preset Alias Commands" section below for the exact command per preset. This is ONE exec call โ†’ ONE Approve click.

Step 3c: Restart gateway. Use exec:

openclaw gateway restart

Wait for confirmation. ONE more Approve click.

Total: 2-3 Approve clicks. That's it.

DO NOT tell users to run commands in a terminal. ALWAYS use exec. If exec fails, troubleshoot the error and retry exec.


Preset Alias Commands

Each preset is a single exec command that adds all model aliases at once. Use the EXACT command for the chosen preset:

AGENT: Copy the exact command below for the user's chosen preset. Do not modify it.

1. balanced (recommended)

openclaw models aliases add flashlite openrouter/google/gemini-2.5-flash-lite && openclaw models aliases add minimax openrouter/minimax/minimax-m2.1 && openclaw models aliases add kimi25 openrouter/moonshotai/kimi-k2.5 && openclaw models aliases add flash openrouter/google/gemini-2.5-flash

Tiers: Base=flashlite (ยข) | Work=minimax (ยขยข) | Frontier=kimi25 (ยขยข)

2. code-machine

openclaw models aliases add devfree openrouter/mistralai/devstral-small:free && openclaw models aliases add minimax openrouter/minimax/minimax-m2.1 && openclaw models aliases add codex52 openrouter/openai/gpt-5.2-codex && openclaw models aliases add devstral openrouter/mistralai/devstral-small

Tiers: Base=devfree (FREE โš ๏ธ) | Work=minimax (ยขยข) | Frontier=codex52 ($$$)

3. claude-diehards

openclaw models aliases add haiku openrouter/anthropic/claude-haiku-4-5 && openclaw models aliases add sonnet openrouter/anthropic/claude-sonnet-4-5 && openclaw models aliases add opus46 openrouter/anthropic/claude-opus-4-6

Tiers: Base=haiku ($$) | Work=sonnet ($$$) | Frontier=opus46 ($$$)

4. big-context

openclaw models aliases add flash openrouter/google/gemini-2.5-flash && openclaw models aliases add grokfast openrouter/x-ai/grok-4.1-fast-2m && openclaw models aliases add gem3pro openrouter/google/gemini-3-pro-1m

Tiers: Base=flash (ยข) | Work=grokfast ($$) | Frontier=gem3pro ($$)

5. openai-focused

openclaw models aliases add mini openrouter/openai/gpt-5-mini && openclaw models aliases add gpt51 openrouter/openai/gpt-5.1 && openclaw models aliases add gpt52 openrouter/openai/gpt-5.2

Tiers: Base=mini (ยข) | Work=gpt51 ($$) | Frontier=gpt52 ($$$)

6. tool-master

openclaw models aliases add gem3flash openrouter/google/gemini-3-flash && openclaw models aliases add kimi25 openrouter/moonshotai/kimi-k2.5 && openclaw models aliases add gpt52 openrouter/openai/gpt-5.2

Tiers: Base=gem3flash (ยข) | Work=kimi25 (ยขยข) | Frontier=gpt52 ($$$)

7. ultra-budget

openclaw models aliases add mimo openrouter/xiaomi/mimo-v2-flash:free && openclaw models aliases add deepseek openrouter/deepseek/deepseek-chat-v3-0324 && openclaw models aliases add kimi25 openrouter/moonshotai/kimi-k2.5 && openclaw models aliases add devfree openrouter/mistralai/devstral-small:free

Tiers: Base=mimo (FREE โš ๏ธ) | Work=deepseek (ยข) | Frontier=kimi25 (ยขยข)

8. free-tier

openclaw models aliases add mimo openrouter/xiaomi/mimo-v2-flash:free && openclaw models aliases add devfree openrouter/mistralai/devstral-small:free && openclaw models aliases add glm openrouter/thudm/glm-z1-free:free

Tiers: Base=mimo (FREE โš ๏ธ) | Work=devfree (FREE โš ๏ธ) | Frontier=glm (FREE โš ๏ธ)

โš ๏ธ Free model warning for presets 7 and 8: After adding aliases, tell the user: "These presets use free-tier models on OpenRouter. Free models can have cold starts (10-30s delays), rate limits during peak hours, and occasional disconnects. If your agent stalls, switch to a paid model: /model deepseek (costs fractions of a penny). Free presets are great for testing but not recommended for production."


Step 4: Test It

After gateway restart, the agent asks the user to test in chat:

Let's make sure everything works! Type this right here in chat:

/model minimax

You should see a confirmation that it switched.

After confirmation:

Now switch back to your default:

/model

(with no arguments โ€” this resets to your default model)

After confirmation:

๐ŸŽ‰ You're all set!

From now on:
โ€ข Your default model is unchanged โ€” same as before
โ€ข You now have cheap and powerful models available via /model
โ€ข When you need more power, I'll tell you which model to switch to
โ€ข You just type the /model command I give you
โ€ข After big tasks, I'll remind you to switch back
โ€ข Say "advisor off" anytime to stop my suggestions

More things you can do:
โ€ข "how much have I saved?"    โ€” see your tracked savings
โ€ข "estimate my monthly costs" โ€” plan your budget
โ€ข "mix and match"             โ€” build a custom preset from all 29 models

That's the entire setup. 3 clicks, done forever.


What Happens After Setup โ€” Daily Use

This is where the skill earns its keep.

Simple question? No interruption.

You: what does JWT stand for?

Agent: JSON Web Token โ€” an open standard for securely
transmitting information between parties as a JSON object.

No popup, no suggestion. Your default model handled it fine.

Coding task? The agent recommends switching.

You: Write a React component for user registration
     with email validation and password strength meter

โšก COST ADVISOR

You're on your default model.
This task: React component with validation logic

I recommend switching to a stronger coding model:

  /model minimax  โ€” MiniMax M2.1 ($0.28/$1.20 per 1M tokens)
    โœ“ Best value for coding tasks
    โœ“ Top-tier on SWE-bench

Just type /model minimax to switch, or say "no" to stay as-is.

Huge task? The agent suggests frontier.

You: [pastes 3 files + long description of auth system]

โšก COST ADVISOR

This is complex enough for frontier-level reasoning.

I recommend:
  /model kimi25  โ€” Kimi K2.5 ($0.50/$2.00 per 1M tokens)
    โœ“ Cheapest frontier model
    โœ“ 1500 parallel tool calls

Type /model kimi25 to switch, or "no" to stay as-is.

After the big task โ€” switch back.

Agent: [finishes the task]

๐Ÿ’ฐ Task complete! Switch back to save money:

/model

(resets to your default)

Don't want a suggestion? Just say no.

You: no, just do it

Agent: ๐Ÿ‘ Staying on current model.

[... does the task, no nagging ...]

Suggestions annoying? Turn them off.

You: advisor off

โœ… Cost Advisor: OFF
I won't suggest model switches anymore.
Say "advisor on" whenever you want them back.

8 Presets โ€” Full Details

Every preset ADDS models to your setup. Your default is never changed.

โญ Recommended

PresetCostBaseWorkFrontier
balancedยขยขFlash-Lite /model flashliteMiniMax /model minimaxKimi K2.5 /model kimi25
code-machineยขยขDevstral Free /model devfree โš ๏ธMiniMax /model minimaxGPT-5.2 Codex /model codex52

More Options

PresetCostBaseWorkFrontier
claude-diehards$$$Haiku /model haikuSonnet /model sonnetOpus 4.6 /model opus46
big-context$$Flash /model flashGrok Fast 2M /model grokfastGemini 3 Pro 1M /model gem3pro
openai-focused$$Mini /model miniGPT-5.1 /model gpt51GPT-5.2 /model gpt52
tool-master$$Gem3 Flash /model gem3flashKimi K2.5 /model kimi25GPT-5.2 /model gpt52

Budget โš ๏ธ Read before choosing

PresetCostBaseWorkFrontier
ultra-budgetยขMiMo /model mimo โš ๏ธDeepSeek /model deepseekKimi K2.5 /model kimi25
free-tierFREEMiMo /model mimo โš ๏ธDevstral Free /model devfree โš ๏ธGLM-Z1 /model glm โš ๏ธ

Pricing: FREE = $0 | ยข < $0.50/M | ยขยข < $2/M | $$ = $2-15/M | $$$ = $15+/M

โš ๏ธ Free model reliability warning: Presets with โš ๏ธ use free-tier models on OpenRouter. Free models can have cold starts (10-30s delays), rate limits during peak hours, queue waits behind paid users, and more frequent downtime. This can cause gateway disconnects. If your agent stalls or disconnects, switch to a cheap paid model: /model deepseek (ยข โ€” pennies but reliable). Budget presets are great for experimenting but not recommended for production or team use.

Want to switch presets later? Just say "switch me to code-machine" and the agent adds those aliases too.


Adding More Models Later

Want to add a specific model that isn't in your preset? Just ask:

You: add GPT-5.2 to my models

Agent: I'll add that now โ€” click Approve.

[exec: openclaw models aliases add gpt52 openrouter/openai/gpt-5.2]

โœ… Done! You can now use: /model gpt52

The agent can add any model from the registry below.


Removing Models

Want to clean up aliases you don't use? Just ask:

You: remove the kimi model

Agent: I'll remove that alias โ€” click Approve.

[exec: openclaw models aliases remove kimi25]

โœ… Removed. /model kimi25 is no longer available.

Your config is unchanged โ€” we only removed the shortcut.


๐Ÿ’ธ Cost Tracker โ€” "How much have I saved?"

The agent tracks every time you switch models on its recommendation and estimates how much you saved vs. your default model.

How it works

Every time the Cost Advisor recommends a cheaper model and you switch, the agent logs:

  • Date and task description
  • Model you used vs. what your default would have cost
  • Estimated tokens and savings

The agent keeps a running log at ~/.openclaw/cost-tracker.md.

Ask anytime

You: how much have I saved?

๐Ÿ’ธ COST TRACKER โ€” Savings Since Install

Installed: Feb 15, 2026
Total tasks tracked: 47

    Default model cost (est):    $3.82
    Actual cost with switching:  $0.41
    โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
    Total saved:                 $3.41  (89% reduction)

Top savings:
โ€ข 23 simple tasks โ†’ flashlite instead of default     saved $1.90
โ€ข 18 coding tasks โ†’ minimax instead of default        saved $1.22
โ€ข  6 complex tasks โ†’ kimi25 instead of default        saved $0.29

At this rate: ~$22/month saved
You: reset my savings tracker

Agent: I'll reset your cost tracker โ€” click Approve.

[exec: echo "# Cost Tracker\n\nInstalled: [today]\nDefault model: [detected]\n\n## Log\n" > ~/.openclaw/cost-tracker.md]

โœ… Tracker reset. Starting fresh from today.

๐Ÿ”€ Mix & Match โ€” Build Your Own Preset

Don't like the preset options? Build your own from the full 29-model registry.

How it works

You: build me a custom preset

Agent:

๐Ÿ”€ Mix & Match โ€” Pick one model for each tier:

โ”€โ”€ BASE (for simple tasks, questions, chat) โ”€โ”€โ”€โ”€โ”€โ”€
 a. flashlite   โ€” Gemini 2.5 Flash-Lite    $0.10/$0.40   Best cheap all-rounder
 b. flash       โ€” Gemini 2.5 Flash          $0.15/$0.60   Stronger Flash
 c. mini        โ€” GPT-5 Mini                $0.30/$1.20   OpenAI budget
 d. gem3flash   โ€” Gemini 3 Flash            $0.50/$2.00   Best tool-calling
 e. devstral    โ€” Devstral Small            $0.05/$0.22   Cheapest paid
 f. deepseek    โ€” DeepSeek V3              $0.14/$0.28   Cheap + strong
 g. mimo        โ€” MiMo v2 Flash             FREE โš ๏ธ       Unreliable
 h. devfree     โ€” Devstral Small Free       FREE โš ๏ธ       Unreliable

Pick a letter for your BASE model (or "skip" to leave empty):

After the user picks a base model:

โ”€โ”€ WORK (for coding, writing, daily tasks) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
 a. minimax     โ€” MiniMax M2.1             $0.28/$1.20   Best value coder
 b. deepseek    โ€” DeepSeek V3              $0.14/$0.28   Cheapest paid coder
 c. haiku       โ€” Claude Haiku 4.5         $0.80/$4.00   Fast Anthropic
 d. gpt51       โ€” GPT-5.1                  $2.00/$8.00   OpenAI mid-tier
 e. grokfast    โ€” Grok 4.1 Fast 2M        $2.00/$10.00  2M context
 f. seed        โ€” Seed Coder 200K         $0.20/$0.60   Long-context coder
 g. qwen3       โ€” Qwen3 235B              $0.14/$0.28   Strong reasoning
 h. devstral    โ€” Devstral Small           $0.05/$0.22   Reliable Mistral

Pick a letter for your WORK model (or "skip"):

After work model:

โ”€โ”€ FRONTIER (for complex architecture, security, multi-file) โ”€โ”€
 a. kimi25      โ€” Kimi K2.5               $0.50/$2.00    Cheapest frontier
 b. sonnet      โ€” Claude Sonnet 4.5       $3.00/$15.00   Anthropic workhorse
 c. gpt52       โ€” GPT-5.2                 $2.00/$10.00   OpenAI flagship
 d. codex52     โ€” GPT-5.2 Codex           $2.00/$10.00   Code-specialized
 e. opus46      โ€” Claude Opus 4.6        $15.00/$75.00   Most powerful
 f. gem3pro     โ€” Gemini 3 Pro 1M         $1.25/$10.00   1M context
 g. grok4       โ€” Grok 4                  $2.00/$10.00   Strong reasoning
 h. r1          โ€” DeepSeek R1             $0.55/$2.19    Deep reasoning chain

Pick a letter for your FRONTIER model (or "skip"):

Then the agent adds those aliases via exec โ€” same as preset setup, one Approve click.


๐Ÿ“Š Monthly Cost Calculator

Estimate what your agent costs per month โ€” and what it would cost with the optimizer.

How it works

You: estimate my monthly costs

Agent:

๐Ÿ“Š Monthly Cost Calculator

I need a few quick numbers:

1. About how many messages/day do you send your agent?
   (rough guess is fine โ€” 10? 50? 100?)

2. What's the mix? (pick closest)
   a) Mostly simple questions and chat
   b) Mostly coding and writing
   c) Mix of everything
   d) Mostly complex/architecture work

After the user answers:

๐Ÿ“Š MONTHLY COST ESTIMATE

Based on: ~50 messages/day, mostly coding

Your current setup (everything on default):
  Model: claude-sonnet-4-5
  Est. tokens/month: ~15M input, ~5M output
  Est. monthly cost: $120.00

With Cost Optimizer (switching on recommendations):
  Simple tasks โ†’ flashlite               $1.50/mo
  Coding tasks โ†’ minimax                 $8.40/mo
  Complex tasks โ†’ kimi25 (when needed)   $3.00/mo
  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  Est. monthly cost: $12.90
  Savings: $107.10/month (89% reduction)

  That's ~$1,285 saved per year.

These are estimates based on average token usage per task type.
Actual costs depend on message length and model output.

Note: The calculator uses rough estimates โ€” 1.5K input + 500 output tokens for simple tasks, 4K + 2K for coding, 8K + 4K for complex. Good enough for ballpark planning.


Quick Reference Card

What you want to doWhat to doWhere
Switch to a model/model minimaxChat
Switch back to default/modelChat
See available models/model listChat
Turn off suggestions"advisor off"Chat
Turn on suggestions"advisor on"Chat
See your savings"how much have I saved?"Chat
Estimate monthly cost"estimate my monthly costs"Chat
Build custom preset"mix and match"Chat (agent shows menus)
Reset savings tracker"reset my savings tracker"Chat (agent runs exec)
Add a model"add GPT-5.2 to my models"Chat (agent runs exec)
Remove a model"remove the kimi model"Chat (agent runs exec)
Switch presets"switch me to code-machine"Chat (agent runs exec)


Agent Instructions

Everything below is for the agent. Users can read it, but it's written as behavior rules for the AI.


Smart Cost Advisor โ€” Core Behavior

On every incoming message, BEFORE doing the task:

1. Check current model

Note the active model (visible in session). Know which tier it falls into based on the Model Registry below.

2. Classify the task

BASE-level (suggest cheapest model):

  • Messages under 200 chars, simple questions, brainstorming, greetings
  • "What is", "how do I", "btw", "just wondering", questions ending in ?
  • No code, no attachments

WORK-level (suggest work-tier model):

  • "Write a function/component/test", "debug this", "fix this error"
  • "Draft an email/document", "explain this code", "review this PR"
  • Single file scope, 200-2000 char messages, one attachment or code block

FRONTIER-level (suggest frontier model):

  • "Build", "architect", "design a system", "security audit"
  • "Refactor entire", "migrate from X to Y", "production bug" + stack trace
  • Multi-file (3+), >2000 chars, 3+ attachments, system design, DB schema

3. Compare and recommend

  • Current model is fine for the task โ†’ do the task silently
  • Current model is overkill (expensive model for simple question) โ†’ suggest switching DOWN
  • Current model is too weak โ†’ suggest switching UP

Use the Cost Advisor format shown in the walkthrough above.

4. Handle response

  • User types /model command โ†’ they switched, do the task
  • "no" / anything else โ†’ "๐Ÿ‘ Staying on current model." then do the task
  • Different model than suggested โ†’ fine, do the task

5. After work on higher-tier model

Gentle reminder to switch back. Not a blocker:

๐Ÿ’ฐ Task complete! Switch back to save money: /model

Ambiguity rules

  • Code present โ†’ lean WORK minimum
  • "quick" / "just" โ†’ lean BASE
  • Genuinely unsure โ†’ do NOT recommend. Just do the task.
  • Never recommend a switch you aren't confident about
  • If current model is already cheap enough for the task, stay silent

Toggle: "advisor on" / "advisor off"

  • "advisor off" / "stop suggesting" / "quiet mode" โ†’ โœ… Cost Advisor: OFF
  • "advisor on" / "start suggesting" / "help me save" โ†’ โœ… Cost Advisor: ON

When OFF โ†’ no recommendations, tasks run silently on current model.


Cost Tracker โ€” Agent Behavior

The agent maintains a lightweight log at ~/.openclaw/cost-tracker.md to track savings.

On setup (after Step 4 completes)

Create the tracker file via exec:

mkdir -p ~/.openclaw && cat > ~/.openclaw/cost-tracker.md << 'EOF'
# Cost Tracker

Installed: [TODAY'S DATE]
Default model: [DETECTED DEFAULT]

## Log

| Date | Task | Model Used | Default Cost (est) | Actual Cost (est) | Saved |
|------|------|-----------|-------------------|------------------|-------|
EOF

When user switches on advisor recommendation

After the user types a /model command following a Cost Advisor suggestion, append a row to the log via exec:

echo "| [DATE] | [SHORT TASK DESC] | [MODEL] | $[DEFAULT_EST] | $[ACTUAL_EST] | $[SAVED] |" >> ~/.openclaw/cost-tracker.md

Token estimation rules (rough but useful):

  • BASE task: ~1,500 input + 500 output tokens
  • WORK task: ~4,000 input + 2,000 output tokens
  • FRONTIER task: ~8,000 input + 4,000 output tokens
  • Use model pricing from the registry to calculate costs

Only log when the user actually switches. If they say "no" to a recommendation, don't log anything.

"how much have I saved?" command

Recognize: "how much have I saved", "savings", "show savings", "cost tracker", "what have I saved"

  1. Read ~/.openclaw/cost-tracker.md via exec
  2. Parse the log table, sum the Default Cost, Actual Cost, and Saved columns
  3. Show formatted summary (see user-facing example above)
  4. Calculate "at this rate" monthly projection: (total saved / days since install) ร— 30
  5. If file doesn't exist or is empty โ†’ "No savings tracked yet. I'll start logging when you switch models on my recommendations."

"reset my savings tracker" command

Recognize: "reset savings", "reset tracker", "clear savings", "start fresh"

Recreate the file with a fresh header (same as setup). Confirm to user.


Mix & Match โ€” Agent Behavior

Trigger

Recognize: "mix and match", "build custom preset", "custom preset", "build my own", "pick my own models", "custom models"

Flow

  1. Show BASE model menu (exact text from user-facing section above)
  2. Wait for user pick โ†’ note the alias and ref
  3. Show WORK model menu
  4. Wait for user pick โ†’ note the alias and ref
  5. Show FRONTIER model menu
  6. Wait for user pick โ†’ note the alias and ref
  7. Summarize what will be added, then run ONE exec with all &&-chained alias commands
  8. Run openclaw gateway restart via exec
  9. Confirm with /model test instructions

Rules:

  • "skip" on any tier โ†’ don't add a model for that tier
  • If user picks a model they already have โ†’ tell them: "You already have that one! Pick another or skip."
  • If user picks a model from a different tier than shown (e.g., picks a frontier model for base) โ†’ allow it. User knows best.
  • After custom preset is set up, Cost Advisor uses the tiers the user assigned, not the registry defaults

Model menus โ€” mapping

BASE menu: aโ†’flashlite, bโ†’flash, cโ†’mini, dโ†’gem3flash, eโ†’devstral, fโ†’deepseek, gโ†’mimo, hโ†’devfree

WORK menu: aโ†’minimax, bโ†’deepseek, cโ†’haiku, dโ†’gpt51, eโ†’grokfast, fโ†’seed, gโ†’qwen3, hโ†’devstral

FRONTIER menu: aโ†’kimi25, bโ†’sonnet, cโ†’gpt52, dโ†’codex52, eโ†’opus46, fโ†’gem3pro, gโ†’grok4, hโ†’r1


Monthly Cost Calculator โ€” Agent Behavior

Trigger

Recognize: "estimate my costs", "monthly cost", "how much am I spending", "cost calculator", "what does this cost", "estimate monthly"

Flow

  1. Ask the two questions (messages/day + task mix) โ€” in ONE message
  2. Wait for answers
  3. Calculate using token estimates and model pricing
  4. Show formatted comparison (default vs. optimized)

Calculation method

Step 1: Estimate monthly messages messages_per_day ร— 30 = monthly_messages

Step 2: Split by task type based on mix answer

Mix answerSimple %Coding %Complex %
a) Mostly simple70%20%10%
b) Mostly coding20%60%20%
c) Mix of everything40%40%20%
d) Mostly complex15%35%50%

Step 3: Estimate tokens per task type

Task typeInput tokensOutput tokens
Simple1,500500
Coding4,0002,000
Complex8,0004,000

Step 4: Calculate costs

For "default" cost: use the user's detected default model pricing for ALL tasks.

For "optimized" cost: use the user's current preset models:

  • Simple tasks โ†’ their Base model pricing
  • Coding tasks โ†’ their Work model pricing
  • Complex tasks โ†’ their Frontier model pricing

Step 5: Show comparison with monthly and yearly savings.

If the agent can't detect the user's default model, ask: "What model are you currently using as your default?"


First-Run Setup Flow

Trigger when:

  • First message after skill install
  • User mentions costs, saving money, models, or setup
  • User asks "what can you do" / "what is this"

Do NOT wait for a magic phrase. If skill is loaded and user isn't set up, introduce yourself.

Flow:

  1. Show intro + preset picker (EXACT text from Step 1 โ€” do not paraphrase)
  2. After pick โ†’ explain what models are being added (see Step 2)
  3. Use exec to check auth: openclaw models status โ€” tell user to click Approve
  4. If OpenRouter auth missing โ†’ guide them through it (see Step 3a)
  5. Use exec to add all aliases for chosen preset (see Preset Alias Commands) โ€” tell user to click Approve
  6. Use exec to restart gateway: openclaw gateway restart โ€” tell user to click Approve
  7. Walk through /model testing (Step 4)
  8. Explain Cost Advisor + advisor on/off

ONE STEP AT A TIME. Run one exec, show result, then proceed. If exec fails, troubleshoot before moving on.

ALWAYS use exec. Never tell users to run commands in a terminal. If exec fails, fix the error and retry exec.

Preset mapping:

1 โ†’ balanced, 2 โ†’ code-machine, 3 โ†’ claude-diehards, 4 โ†’ big-context, 5 โ†’ openai-focused, 6 โ†’ tool-master, 7 โ†’ ultra-budget, 8 โ†’ free-tier

Vague answer โ†’ balanced. "I don't know" โ†’ balanced + "We can change later."


Full Model Registry

All 29 verified models available on OpenRouter. The agent should know these for cost advisor recommendations.

Tier 1 โ€” Base Models (cheapest, for simple tasks)

AliasModelOpenRouter RefInput/Output per 1MNotes
flashliteGemini 2.5 Flash-Liteopenrouter/google/gemini-2.5-flash-lite$0.10/$0.40Best cheap all-rounder
flashGemini 2.5 Flashopenrouter/google/gemini-2.5-flash$0.15/$0.60Stronger than Flash-Lite
miniGPT-5 Miniopenrouter/openai/gpt-5-mini$0.30/$1.20OpenAI's budget pick
gem3flashGemini 3 Flashopenrouter/google/gemini-3-flash$0.50/$2.00Best tool-calling cheap model
mimoMiMo v2 Flashopenrouter/xiaomi/mimo-v2-flash:freeFREEโš ๏ธ Free tier โ€” unreliable
devfreeDevstral Small Freeopenrouter/mistralai/devstral-small:freeFREEโš ๏ธ Free tier โ€” unreliable
glmGLM-Z1 Freeopenrouter/thudm/glm-z1-free:freeFREEโš ๏ธ Free tier โ€” unreliable

Tier 2 โ€” Work Models (coding, writing, daily tasks)

AliasModelOpenRouter RefInput/Output per 1MNotes
minimaxMiniMax M2.1openrouter/minimax/minimax-m2.1$0.28/$1.20Best value coder
deepseekDeepSeek V3openrouter/deepseek/deepseek-chat-v3-0324$0.14/$0.28Cheapest paid coder
devstralDevstral Smallopenrouter/mistralai/devstral-small$0.05/$0.22Paid Devstral โ€” reliable
haikuClaude Haiku 4.5openrouter/anthropic/claude-haiku-4-5$0.80/$4.00Fast Anthropic model
gpt51GPT-5.1openrouter/openai/gpt-5.1$2.00/$8.00OpenAI mid-tier
grokfastGrok 4.1 Fast 2Mopenrouter/x-ai/grok-4.1-fast-2m$2.00/$10.002M context window
seedByteDance Seed 200Kopenrouter/bytedance/seed-coder-200k$0.20/$0.60Long-context coder
qwen3Qwen3 235Bopenrouter/qwen/qwen3-235b$0.14/$0.28Strong reasoning

Tier 3 โ€” Frontier Models (complex architecture, security, multi-file)

AliasModelOpenRouter RefInput/Output per 1MNotes
kimi25Kimi K2.5openrouter/moonshotai/kimi-k2.5$0.50/$2.00Cheapest frontier, 1500 parallel tools
sonnetClaude Sonnet 4.5openrouter/anthropic/claude-sonnet-4-5$3.00/$15.00Anthropic's workhorse
gpt52GPT-5.2openrouter/openai/gpt-5.2$2.00/$10.00OpenAI flagship
codex52GPT-5.2 Codexopenrouter/openai/gpt-5.2-codex$2.00/$10.00Code-specialized GPT-5.2
opus46Claude Opus 4.6openrouter/anthropic/claude-opus-4-6$15.00/$75.00Most powerful, most expensive
gem3proGemini 3 Pro 1Mopenrouter/google/gemini-3-pro-1m$1.25/$10.001M context
grok4Grok 4openrouter/x-ai/grok-4$2.00/$10.00Strong reasoning
r1DeepSeek R1openrouter/deepseek/deepseek-r1$0.55/$2.19Deep reasoning chain

Additional Models (available for custom alias requests)

ModelOpenRouter RefInput/Output per 1MNotes
Gemma 3 27Bopenrouter/google/gemma-3-27b$0.10/$0.20Small, fast
Llama 4 Scoutopenrouter/meta-llama/llama-4-scout$0.15/$0.40Meta's scout model
Llama 4 Maverickopenrouter/meta-llama/llama-4-maverick$0.20/$0.60Meta's mid-tier
GPT-5openrouter/openai/gpt-5$2.00/$8.00Previous OpenAI flagship
Claude Sonnet 4openrouter/anthropic/claude-sonnet-4$3.00/$15.00Previous Sonnet
Claude Opus 4openrouter/anthropic/claude-opus-4$15.00/$75.00Previous Opus
Grok 3 Miniopenrouter/x-ai/grok-3-mini$0.30/$0.50Budget xAI

Config Files This Skill Uses

FilePurpose
SKILL.mdThis file โ€” the entire skill
MODEL-REFERENCE.mdQuick reference card for users

That's it. No scripts, no generated configs, no backup systems. Just instructions for the agent.


Why This Exists

I've trained thousands of people to build AI Personas through the AI Persona Method. The #1 complaint after setup:

"My agent works great but it's costing me a fortune. Every question โ€” even 'what time is it?' โ€” burns the same expensive model."

The issue isn't the model. It's using a $15/M-token model for tasks that a $0.10/M-token model handles just as well.

Cost Optimizer is the exact system I use to run production agents at a fraction of the cost. Now it's yours.


Who Built This

Jeff J Hunter is the creator of the AI Persona Method and founder of the world's first AI Certified Consultant program.

He runs the largest AI community (3.6M+ members) and has been featured in Entrepreneur, Forbes, ABC, and CBS. As founder of VA Staffer (150+ virtual assistants), Jeff has spent a decade building systems that let humans and AI work together effectively.

Cost Optimizer is part of that mission โ€” making AI agents practical and affordable for everyone.


Want to Make Money with AI?

Most people burn API credits with nothing to show for it.

Cost Optimizer saves you money. But if you want to turn AI into actual income, you need the complete playbook.

โ†’ Join AI Money Group: https://aimoneygroup.com

Learn how to build AI systems that pay for themselves.


Connect


License

MIT โ€” Use freely, modify, distribute. Attribution appreciated.


Cost Optimizer โ€” Stop overpaying your agent. Start profiting from it.

ๅฆ‚ไฝ•ไฝฟ็”จใ€ŒOpenClaw Cost Optimizerใ€๏ผŸ

  1. ๆ‰“ๅผ€ๅฐ้พ™่™พAI๏ผˆWeb ๆˆ– iOS App๏ผ‰
  2. ็‚นๅ‡ปไธŠๆ–นใ€Œ็ซ‹ๅณไฝฟ็”จใ€ๆŒ‰้’ฎ๏ผŒๆˆ–ๅœจๅฏน่ฏๆก†ไธญ่พ“ๅ…ฅไปปๅŠกๆ่ฟฐ
  3. ๅฐ้พ™่™พAI ไผš่‡ชๅŠจๅŒน้…ๅนถ่ฐƒ็”จใ€ŒOpenClaw Cost Optimizerใ€ๆŠ€่ƒฝๅฎŒๆˆไปปๅŠก
  4. ็ป“ๆžœๅณๆ—ถๅ‘ˆ็Žฐ๏ผŒๆ”ฏๆŒ็ปง็ปญๅฏน่ฏไผ˜ๅŒ–

็›ธๅ…ณๆŠ€่ƒฝ