Token Cost Optimization
by @openlark
Token savings and API cost optimization. Provides token calculator, three-tier optimization strategies (prompt compression / cache reuse / model downgrade),...
clawhub install token-cost-optimizationπ About This Skill
name: token-cost-optimization description: Token savings and API cost optimization. Provides token calculator, three-tier optimization strategies (prompt compression / cache reuse / model downgrade), specific configuration guides, and quantified effect analysis.
Token Cost Optimization
Use Cases
User mentions token savings, API cost optimization, prompt compression, cache strategy, model downgrade, cost analysis.
Quick Start
Token Calculator
Run the calculation script, input conversation scale, and quickly estimate current token consumption and optimization potential:python scripts/token_calculator.py
The script will prompt for:
Output: Current cost, optimized cost, savings percentage.
Three-Tier Optimization Strategy
Ranked by effect / implementation cost:| Tier | Strategy | Effect | Implementation Cost | |------|----------|--------|---------------------| | L1 | Prompt compression & output truncation | 10-30% | Low | | L2 | Conversation summary caching | 30-50% | Medium | | L3 | Model downgrade + task routing | 50-70% | High |
Priority Recommendation: Implement in order L1 β L2 β L3, verifying results at each stage before proceeding.
Detailed strategies, configuration guides, and pitfalls β See references/tier-strategies.md
Phased Implementation Guide
Phase 1: L1 Compression (Immediate Effect)
Phase 2: L2 Caching (1-3 Days)
Phase 3: L3 Routing (1-2 Weeks)
Quantifiable Comparison Example
See the "Quantified Comparison" section in references/tier-strategies.md for details.
β‘ When to Use
User mentions token savings, API cost optimization, prompt compression, cache strategy, model downgrade, cost analysis.
π‘ Examples
Token Calculator
Run the calculation script, input conversation scale, and quickly estimate current token consumption and optimization potential:python scripts/token_calculator.py
The script will prompt for:
Output: Current cost, optimized cost, savings percentage.
Three-Tier Optimization Strategy
Ranked by effect / implementation cost:| Tier | Strategy | Effect | Implementation Cost | |------|----------|--------|---------------------| | L1 | Prompt compression & output truncation | 10-30% | Low | | L2 | Conversation summary caching | 30-50% | Medium | | L3 | Model downgrade + task routing | 50-70% | High |
Priority Recommendation: Implement in order L1 β L2 β L3, verifying results at each stage before proceeding.
Detailed strategies, configuration guides, and pitfalls β See references/tier-strategies.md