{"id":"1e9a9dd5-6a9b-4f33-8ca9-0b754f87f8d5","entityType":"agent","slug":"clawhub-openlark-token-cost-optimization","name":"Token Cost Optimization","canonicalUrl":"https://www.xpersona.co/agent/clawhub-openlark-token-cost-optimization","canonicalPath":"/agent/clawhub-openlark-token-cost-optimization","generatedAt":"2026-10-12T16:55:10.228Z","source":"CLAWHUB","claimStatus":"UNCLAIMED","verificationTier":"NONE","summary":{"evidence":{"source":"editorial-content","verified":true,"confidence":"high","updatedAt":"2026-10-12T02:25:26.790Z","emptyReason":null},"description":"Token savings and API cost optimization. Provides token calculator, three-tier optimization strategies (prompt compression / cache reuse / model downgrade),... Skill: Token Cost Optimization Owner: openlark Summary: Token savings and API cost optimization. Provides token calculator, three-tier optimization strategies (prompt compression / cache reuse / model downgrade),... Tags: latest:1.0.0 Version history: v1.0.0 | 2026-04-22T02:41:26.011Z | user - Initial release of token-cost-optimization skill. - Provides a token calculator script for quick estimation of API usage and","descriptionLabel":"Technical summary","evidenceSummary":"Capability contract not published. No trust telemetry is available yet. 955 downloads reported by the source. Last updated 10/12/2026.","installCommand":"clawhub skill install s1727wv2g20pc729snzcm4nf8183hy72:token-cost-optimization","sourceUrl":"https://clawhub.ai/openlark/token-cost-optimization","homepage":"https://clawhub.ai/openlark/skills/token-cost-optimization","primaryLinks":[{"label":"View on ClawHub","url":"https://clawhub.ai/openlark/token-cost-optimization","kind":"source"},{"label":"Homepage","url":"https://clawhub.ai/openlark/skills/token-cost-optimization","kind":"homepage"}],"safetyScore":84,"overallRank":62,"popularityScore":60,"trustScore":null,"claimedByName":null,"isOwner":false,"seoDescription":"Token savings and API cost optimization. Provides token calculator, three-tier optimization strategies (prompt compression / cache reuse / model downgrade),... "},"coverage":{"evidence":{"source":"public-profile","verified":false,"confidence":"medium","updatedAt":"2026-10-12T02:25:26.790Z","emptyReason":null},"protocols":[{"protocol":"OPENCLEW","label":"OpenClaw","status":"self-declared","notes":"Declared in the public agent profile."}],"capabilities":[],"verifiedCount":0,"selfDeclaredCount":1,"capabilityMatrix":{"rows":[{"key":"OPENCLEW","type":"protocol","support":"unknown","confidenceSource":"profile","notes":"Listed on profile"}],"flattenedTokens":"protocol:OPENCLEW|unknown|profile"}},"adoption":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-12T02:25:26.790Z","emptyReason":null},"stars":null,"forks":null,"downloads":955,"likes":null,"task":null,"library":null,"packageName":null,"latestVersion":"1.0.0","tractionLabel":"955 downloads"},"release":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-12T02:25:26.779Z","emptyReason":null},"lastUpdatedAt":"2026-10-12T02:25:26.790Z","lastCrawledAt":"2026-10-12T02:25:26.779Z","lastIndexedAt":null,"nextCrawlAt":"2026-10-13T02:25:26.779Z","lastVerifiedAt":null,"highlights":[{"version":"1.0.0","createdAt":"2026-04-22T02:41:26.011Z","changelog":"- Initial release of token-cost-optimization skill. - Provides a token calculator script for quick estimation of API usage and potential savings. - Outlines a three-tiered token optimization strategy: prompt compression, conversation summary caching, and model downgrade/task routing. - Includes step-by-step phased implementation guides and best practices for each optimization tier. - Offers quantified cost analysis examples and detailed configuration references for each strategy.","fileCount":5,"zipByteSize":6081}]},"execution":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No published capability contract is available yet."},"installCommand":"clawhub skill install s1727wv2g20pc729snzcm4nf8183hy72:token-cost-optimization","setupComplexity":"low","setupSteps":["Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.","Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data."],"contract":{"contractStatus":"missing","authModes":[],"requires":[],"forbidden":[],"supportsMcp":false,"supportsA2a":false,"supportsStreaming":false,"inputSchemaRef":null,"outputSchemaRef":null,"dataRegion":null,"contractUpdatedAt":null,"sourceUpdatedAt":null,"freshnessSeconds":null},"invocationGuide":{"preferredApi":{"snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-openlark-token-cost-optimization/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-openlark-token-cost-optimization/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-openlark-token-cost-optimization/trust"},"curlExamples":["curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-openlark-token-cost-optimization/snapshot\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-openlark-token-cost-optimization/contract\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-openlark-token-cost-optimization/trust\""],"jsonRequestTemplate":{"query":"summarize this repo","constraints":{"maxLatencyMs":2000,"protocolPreference":["OPENCLEW"]}},"jsonResponseTemplate":{"ok":true,"result":{"summary":"...","confidence":0.9},"meta":{"source":"CLAWHUB","generatedAt":"2026-10-12T16:55:10.228Z"}},"retryPolicy":{"maxAttempts":3,"backoffMs":[500,1500,3500],"retryableConditions":["HTTP_429","HTTP_503","NETWORK_TIMEOUT"]}},"endpoints":{"dossierUrl":"https://www.xpersona.co/api/v1/agents/clawhub-openlark-token-cost-optimization/dossier","snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-openlark-token-cost-optimization/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-openlark-token-cost-optimization/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-openlark-token-cost-optimization/trust"}},"reliability":{"evidence":{"source":"runtime-metrics","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No trust, reliability, or runtime telemetry is available."},"trust":{"status":"unavailable","handshakeStatus":"UNKNOWN","verificationFreshnessHours":null,"reputationScore":null,"p95LatencyMs":null,"successRate30d":null,"fallbackRate":null,"attempts30d":null,"trustUpdatedAt":null,"trustConfidence":"unknown","sourceUpdatedAt":null,"freshnessSeconds":null},"decisionGuardrails":{"doNotUseIf":["Contract metadata is missing or unavailable for deterministic execution."],"safeUseWhen":[],"riskFlags":["missing_or_unavailable_contract","trust_data_unavailable","schema_references_missing"],"operationalConfidence":"low"},"executionMetrics":{"observedLatencyMsP50":null,"observedLatencyMsP95":null,"estimatedCostUsd":null,"uptime30d":null,"rateLimitRpm":null,"rateLimitBurst":null,"lastVerifiedAt":null,"verificationSource":null},"runtimeMetrics":{"successRate":null,"avgLatencyMs":null,"avgCostUsd":null,"hallucinationRate":null,"retryRate":null,"disputeRate":null,"p50Latency":null,"p95Latency":null,"lastUpdated":null}},"benchmarks":{"evidence":{"source":"no-benchmark-data","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No benchmark suites or observed failure patterns are available."},"suites":[],"failurePatterns":[]},"artifacts":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"high","updatedAt":"2026-10-12T02:25:26.790Z","emptyReason":null},"readme":"Skill: Token Cost Optimization\n\nOwner: openlark\n\nSummary: Token savings and API cost optimization. Provides token calculator, three-tier optimization strategies (prompt compression / cache reuse / model downgrade),...\n\nTags: latest:1.0.0\n\nVersion history:\n\nv1.0.0 | 2026-04-22T02:41:26.011Z | user\n\n- Initial release of token-cost-optimization skill.\n- Provides a token calculator script for quick estimation of API usage and potential savings.\n- Outlines a three-tiered token optimization strategy: prompt compression, conversation summary caching, and model downgrade/task routing.\n- Includes step-by-step phased implementation guides and best practices for each optimization tier.\n- Offers quantified cost analysis examples and detailed configuration references for each strategy.\n\nArchive index:\n\nArchive v1.0.0: 5 files, 6081 bytes\n\nFiles: references/tier-strategies.md (4041b), scripts/token_calculator.py (3398b), skill-card.md (2115b), SKILL.md (2138b), _meta.json (142b)\n\nFile v1.0.0:SKILL.md\n\n---\nname: token-cost-optimization\ndescription: 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.\n---\n\n# Token Cost Optimization\n\n## Use Cases\n\nUser mentions token savings, API cost optimization, prompt compression, cache strategy, model downgrade, cost analysis.\n\n## Quick Start\n\n### Token Calculator\nRun the calculation script, input conversation scale, and quickly estimate current token consumption and optimization potential:\n\n```bash\npython scripts/token_calculator.py\n```\n\nThe script will prompt for:\n- Number of conversation history items / average length\n- Model and pricing used\n- Current optimization status\n\nOutput: Current cost, optimized cost, savings percentage.\n\n### Three-Tier Optimization Strategy\nRanked by effect / implementation cost:\n\n| Tier | Strategy | Effect | Implementation Cost |\n|------|----------|--------|---------------------|\n| L1   | Prompt compression & output truncation | 10-30% | Low |\n| L2   | Conversation summary caching | 30-50% | Medium |\n| L3   | Model downgrade + task routing | 50-70% | High |\n\n**Priority Recommendation**: Implement in order L1 → L2 → L3, verifying results at each stage before proceeding.\n\nDetailed strategies, configuration guides, and pitfalls → See `references/tier-strategies.md`\n\n## Phased Implementation Guide\n\n### Phase 1: L1 Compression (Immediate Effect)\n- Clean up redundant descriptions in system prompt\n- Set max_tokens limits for long responses\n- Remove outdated/unused messages from conversation history\n\n### Phase 2: L2 Caching (1-3 Days)\n- Establish FAQ shortcuts for high-frequency repeat questions\n- Add summary compression at the beginning of conversations (execute every N rounds)\n\n### Phase 3: L3 Routing (1-2 Weeks)\n- Route simple tasks to cheaper models (e.g., 4o-mini / Haiku)\n- Retain strong models for complex tasks\n- Configure model routing rules\n\n## Quantifiable Comparison Example\n\nSee the \"Quantified Comparison\" section in `references/tier-strategies.md` for details.\n\nFile v1.0.0:_meta.json\n\n{\n  \"ownerId\": \"kn75qrtb885pznwsjwsh18dvf1813bv0\",\n  \"slug\": \"token-cost-optimization\",\n  \"version\": \"1.0.0\",\n  \"publishedAt\": 1776825686011\n}\n\nFile v1.0.0:references/tier-strategies.md\n\n# Three-Tier Optimization Strategies Explained\n\n## L1: Prompt Compression & Output Truncation (Effect 10-30%)\n\n### Specific Actions\n\n**1. System Prompt Streamlining**\n```diff\n- \"You are a professional, patient, and meticulous AI assistant, skilled at analyzing problems and providing comprehensive, organized, and in-depth answers...\"\n+ \"Professional AI assistant. Provide concise answers.\"\n```\n\n**2. max_tokens Limiting**\nSet output limits based on task type:\n- Simple Q&A: max_tokens=200\n- Routine tasks: max_tokens=500\n- Long-form generation: max_tokens=1500\n\n**3. History Message Pruning**\nWhen conversations exceed 20 rounds, delete the earliest 1/3 of history messages (preserving recent context).\n\n### Quantified Effect\n\n| Scenario | Tokens Before | Tokens After | Savings |\n|----------|---------------|--------------|---------|\n| Simple Q&A | 800/session | 500/session | 37% |\n| Code Review | 2000/session | 1400/session | 30% |\n| Long-form Text | 5000/session | 3500/session | 30% |\n\n---\n\n## L2: Conversation Summary Caching (Effect 30-50%)\n\n### Specific Actions\n\n**1. High-Frequency Question FAQ Shortcuts**\n```python\n# Pseudocode example\nfaq_cache = {\n    \"What's the weather today?\": \"Beijing, sunny, 25°C\",\n    \"What's my name?\": \"Determined based on context\",\n}\n# Cache hit → Return directly, no API call\n```\n\n**2. Dynamic Summary Compression**\nAfter every N conversation rounds, compress history into a single summary:\n```\n[Summary] User is working on project X, discussed issues Y and Z, currently at stage Z.\n```\n\n**3. Reference Document Caching**\nStore user-provided documents, code, contracts, etc., in a vector database; subsequent questions are answered via retrieval.\n\n### Quantified Effect\n\n| Scenario | Cost/Month Before | Cost/Month After | Savings |\n|----------|-------------------|------------------|---------|\n| 10 rounds/day × 30d | $90 | $45 | 50% |\n| 30 rounds/day × 30d | $270 | $162 | 40% |\n| 100 rounds/day × 30d | $900 | $450 | 50% |\n\n---\n\n## L3: Model Downgrade + Task Routing (Effect 50-70%)\n\n### Model Routing Strategy\n\n| Task Type | Route To | Cost Reduction |\n|-----------|----------|----------------|\n| Simple Q&A, Translation | gpt-4o-mini / claude-haiku | 90% |\n| Normal Tasks, Summarization | gpt-4o / claude-sonnet | 50% |\n| Complex Reasoning, Long Context | gpt-4-turbo / claude-opus | Baseline |\n\n### Configuration Example (OpenAI API)\n\n```python\ndef route_model(task_type, complexity):\n    if complexity == \"low\":\n        return \"gpt-4o-mini\"\n    elif complexity == \"medium\":\n        return \"gpt-4o\"\n    else:\n        return \"gpt-4-turbo\"\n```\n\n### Quantified Effect\n\n| Monthly Calls | All 4o | Smart Routing | Savings |\n|---------------|--------|---------------|---------|\n| 5,000 | $75 | $23 | 69% |\n| 20,000 | $300 | $95 | 68% |\n| 50,000 | $750 | $240 | 68% |\n\n---\n\n## Pitfalls to Avoid\n\n### ❌ Common Mistakes\n\n1. **Over-compressing system prompt**\n   - Consequence: Unstable model behavior, degraded output quality\n   - Suggestion: Retain core directives; remove \"polite fluff,\" not \"constraints\"\n\n2. **Setting max_tokens too low**\n   - Consequence: Truncated output, incomplete answers\n   - Suggestion: Estimate + 20% buffer, gradually reduce to find the optimal value\n\n3. **Caching without expiration**\n   - Consequence: Outdated information leading to incorrect answers\n   - Suggestion: Set TTL for FAQ; periodically refresh summary caches\n\n4. **One-size-fits-all model downgrade**\n   - Consequence: Simple tasks using cheaper models may waste more due to retries\n   - Suggestion: Use a classifier to assess task complexity first, then route\n\n5. **Premature L3 optimization**\n   - Consequence: Incomplete routing rules degrade user experience\n   - Suggestion: Validate L1+L2 effects first, then introduce L3\n\n### ✅ Best Practices\n\n- Record a baseline after each optimization phase and compare effects\n- Keep detailed cost logs for analysis\n- L3 routing should include a \"downgrade failure auto-upgrade\" fallback strategy\n- Periodically (monthly) review token consumption trends\n\nFile v1.0.0:skill-card.md\n\n## Description:\n\nHelps estimate and reduce API token costs with a calculator, prompt compression, cache reuse, model routing, configuration guidance, and quantified savings examples.\n\nThis skill is ready for commercial/non-commercial use.\n\n## Publisher:\n\n[openlark](https://clawhub.ai/user/openlark)\n\n### License/Terms of Use:\n\nMIT-0\n\n## Use Case:\n\nDevelopers and engineers use this skill to estimate model API costs and plan phased token-reduction work across prompt compression, caching, and model routing.\n\n### Deployment Geography for Use:\n\nGlobal\n\n## Known Risks and Mitigations:\n\nRisk: Caching user documents, source code, contracts, or customer data can expose private or regulated information if implemented without safeguards.\n\nMitigation: Require explicit consent, minimize or redact stored content, apply access controls, define retention limits, and provide a deletion path before enabling document or vector-database caching.\n\nRisk: Over-compression, overly low token limits, or one-size-fits-all model downgrades can reduce answer quality or cause incomplete outputs.\n\nMitigation: Measure a baseline, validate each optimization phase, keep task-appropriate token buffers, and use fallback routing when cheaper models do not meet quality requirements.\n\n## Reference(s):\n\n- [Three-Tier Optimization Strategies Explained](references/tier-strategies.md)\n\n## Skill Output:\n\n**Output Type(s):** [text, markdown, code, shell commands, configuration, guidance]\n\n**Output Format:** [Markdown guidance with inline shell commands and Python snippets; the calculator prints terminal cost estimates.]\n\n**Output Parameters:** [1D]\n\n**Other Properties Related to Output:** [Includes estimated monthly before/after costs and savings percentages based on user-entered usage assumptions.]\n\n## Skill Version(s):\n\n1.0.0 (source: server release metadata)\n\n## Ethical Considerations:\n\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.","readmeExcerpt":"Skill: Token Cost Optimization Owner: openlark Summary: Token savings and API cost optimization. Provides token calculator, three-tier optimization strategies (prompt compression / cache reuse / model downgrade),... Tags: latest:1.0.0 Version history: v1.0.0 | 2026-04-22T02:41:26.011Z | user - Initial release of token-cost-optimization skill. - Provides a token calculator script for quick estimation of API usage and ","codeSnippets":[],"executableExamples":[{"language":"bash","snippet":"python scripts/token_calculator.py"},{"language":"diff","snippet":"- \"You are a professional, patient, and meticulous AI assistant, skilled at analyzing problems and providing comprehensive, organized, and in-depth answers...\"\n+ \"Professional AI assistant. Provide concise answers.\""},{"language":"python","snippet":"# Pseudocode example\nfaq_cache = {\n    \"What's the weather today?\": \"Beijing, sunny, 25°C\",\n    \"What's my name?\": \"Determined based on context\",\n}\n# Cache hit → Return directly, no API call"},{"language":"text","snippet":"[Summary] User is working on project X, discussed issues Y and Z, currently at stage Z."},{"language":"python","snippet":"def route_model(task_type, complexity):\n    if complexity == \"low\":\n        return \"gpt-4o-mini\"\n    elif complexity == \"medium\":\n        return \"gpt-4o\"\n    else:\n        return \"gpt-4-turbo\""}],"parameters":null,"dependencies":[],"permissions":[],"extractedFiles":[{"path":"SKILL.md","content":"---\nname: token-cost-optimization\ndescription: 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.\n---\n\n# Token Cost Optimization\n\n## Use Cases\n\nUser mentions token savings, API cost optimization, prompt compression, cache strategy, model downgrade, cost analysis.\n\n## Quick Start\n\n### Token Calculator\nRun the calculation script, input conversation scale, and quickly estimate current token consumption and optimization potential:\n\n```bash\npython scripts/token_calculator.py\n```\n\nThe script will prompt for:\n- Number of conversation history items / average length\n- Model and pricing used\n- Current optimization status\n\nOutput: Current cost, optimized cost, savings percentage.\n\n### Three-Tier Optimization Strategy\nRanked by effect / implementation cost:\n\n| Tier | Strategy | Effect | Implementation Cost |\n|------|----------|--------|---------------------|\n| L1   | Prompt compression & output truncation | 10-30% | Low |\n| L2   | Conversation summary caching | 30-50% | Medium |\n| L3   | Model downgrade + task routing | 50-70% | High |\n\n**Priority Recommendation**: Implement in order L1 → L2 → L3, verifying results at each stage before proceeding.\n\nDetailed strategies, configuration guides, and pitfalls → See `references/tier-strategies.md`\n\n## Phased Implementation Guide\n\n### Phase 1: L1 Compression (Immediate Effect)\n- Clean up redundant descriptions in system prompt\n- Set max_tokens limits for long responses\n- Remove outdated/unused messages from conversation history\n\n### Phase 2: L2 Caching (1-3 Days)\n- Establish FAQ shortcuts for high-frequency repeat questions\n- Add summary compression at the beginning of conversations (execute every N rounds)\n\n### Phase 3: L3 Routing (1-2 Weeks)\n- Route simple tasks to cheaper models (e.g., 4o-mini / Haiku)\n- Retain strong models for complex tasks\n- Configure model routing rules\n\n## Quantifiable Comparison Example\n\nSee the \"Quantified Comparison\" section in `references/tier-strategies.md` for details."},{"path":"_meta.json","content":"{\n  \"ownerId\": \"kn75qrtb885pznwsjwsh18dvf1813bv0\",\n  \"slug\": \"token-cost-optimization\",\n  \"version\": \"1.0.0\",\n  \"publishedAt\": 1776825686011\n}"},{"path":"references/tier-strategies.md","content":"# Three-Tier Optimization Strategies Explained\n\n## L1: Prompt Compression & Output Truncation (Effect 10-30%)\n\n### Specific Actions\n\n**1. System Prompt Streamlining**\n```diff\n- \"You are a professional, patient, and meticulous AI assistant, skilled at analyzing problems and providing comprehensive, organized, and in-depth answers...\"\n+ \"Professional AI assistant. Provide concise answers.\"\n```\n\n**2. max_tokens Limiting**\nSet output limits based on task type:\n- Simple Q&A: max_tokens=200\n- Routine tasks: max_tokens=500\n- Long-form generation: max_tokens=1500\n\n**3. History Message Pruning**\nWhen conversations exceed 20 rounds, delete the earliest 1/3 of history messages (preserving recent context).\n\n### Quantified Effect\n\n| Scenario | Tokens Before | Tokens After | Savings |\n|----------|---------------|--------------|---------|\n| Simple Q&A | 800/session | 500/session | 37% |\n| Code Review | 2000/session | 1400/session | 30% |\n| Long-form Text | 5000/session | 3500/session | 30% |\n\n---\n\n## L2: Conversation Summary Caching (Effect 30-50%)\n\n### Specific Actions\n\n**1. High-Frequency Question FAQ Shortcuts**\n```python\n# Pseudocode example\nfaq_cache = {\n    \"What's the weather today?\": \"Beijing, sunny, 25°C\",\n    \"What's my name?\": \"Determined based on context\",\n}\n# Cache hit → Return directly, no API call\n```\n\n**2. Dynamic Summary Compression**\nAfter every N conversation rounds, compress history into a single summary:\n```\n[Summary] User is working on project X, discussed issues Y and Z, currently at stage Z.\n```\n\n**3. Reference Document Caching**\nStore user-provided documents, code, contracts, etc., in a vector database; subsequent questions are answered via retrieval.\n\n### Quantified Effect\n\n| Scenario | Cost/Month Before | Cost/Month After | Savings |\n|----------|-------------------|------------------|---------|\n| 10 rounds/day × 30d | $90 | $45 | 50% |\n| 30 rounds/day × 30d | $270 | $162 | 40% |\n| 100 rounds/day × 30d | $900 | $450 | 50% |\n\n---\n\n## L3: Model Downgrade + Task Routing (Effect 50-70%)\n\n### Model Routing Strategy\n\n| Task Type | Route To | Cost Reduction |\n|-----------|----------|----------------|\n| Simple Q&A, Translation | gpt-4o-mini / claude-haiku | 90% |\n| Normal Tasks, Summarization | gpt-4o / claude-sonnet | 50% |\n| Complex Reasoning, Long Context | gpt-4-turbo / claude-opus | Baseline |\n\n### Configuration Example (OpenAI API)\n\n```python\ndef route_model(task_type, complexity):\n    if complexity == \"low\":\n        return \"gpt-4o-mini\"\n    elif complexity == \"medium\":\n        return \"gpt-4o\"\n    else:\n        return \"gpt-4-turbo\"\n```\n\n### Quantified Effect\n\n| Monthly Calls | All 4o | Smart Routing | Savings |\n|---------------|--------|---------------|---------|\n| 5,000 | $75 | $23 | 69% |\n| 20,000 | $300 | $95 | 68% |\n| 50,000 | $750 | $240 | 68% |\n\n---\n\n## Pitfalls to Avoid\n\n### ❌ Common Mistakes\n\n1. **Over-compressing system prompt**\n   - Consequence: Unstable model behavior, degraded output quality\n   - Suggestion: Retain core direc"},{"path":"skill-card.md","content":"## Description:\n\nHelps estimate and reduce API token costs with a calculator, prompt compression, cache reuse, model routing, configuration guidance, and quantified savings examples.\n\nThis skill is ready for commercial/non-commercial use.\n\n## Publisher:\n\n[openlark](https://clawhub.ai/user/openlark)\n\n### License/Terms of Use:\n\nMIT-0\n\n## Use Case:\n\nDevelopers and engineers use this skill to estimate model API costs and plan phased token-reduction work across prompt compression, caching, and model routing.\n\n### Deployment Geography for Use:\n\nGlobal\n\n## Known Risks and Mitigations:\n\nRisk: Caching user documents, source code, contracts, or customer data can expose private or regulated information if implemented without safeguards.\n\nMitigation: Require explicit consent, minimize or redact stored content, apply access controls, define retention limits, and provide a deletion path before enabling document or vector-database caching.\n\nRisk: Over-compression, overly low token limits, or one-size-fits-all model downgrades can reduce answer quality or cause incomplete outputs.\n\nMitigation: Measure a baseline, validate each optimization phase, keep task-appropriate token buffers, and use fallback routing when cheaper models do not meet quality requirements.\n\n## Reference(s):\n\n- [Three-Tier Optimization Strategies Explained](references/tier-strategies.md)\n\n## Skill Output:\n\n**Output Type(s):** [text, markdown, code, shell commands, configuration, guidance]\n\n**Output Format:** [Markdown guidance with inline shell commands and Python snippets; the calculator prints terminal cost estimates.]\n\n**Output Parameters:** [1D]\n\n**Other Properties Related to Output:** [Includes estimated monthly before/after costs and savings percentages based on user-entered usage assumptions.]\n\n## Skill Version(s):\n\n1.0.0 (source: server release metadata)\n\n## Ethical Considerations:\n\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment."}],"languages":[],"docsSourceLabel":"CLAWHUB","editorialOverview":"Token savings and API cost optimization. Provides token calculator, three-tier optimization strategies (prompt compression / cache reuse / model downgrade),... Skill: Token Cost Optimization Owner: openlark Summary: Token savings and API cost optimization. Provides token calculator, three-tier optimization strategies (prompt compression / cache reuse / model downgrade),... Tags: latest:1.0.0 Version history: v1.0.0 | 2026-04-22T02:41:26.011Z | user - Initial release of token-cost-optimization skill. - Provides a token calculator script for quick estimation of API usage and","editorialQuality":{"score":100,"threshold":65,"status":"ready","wordCount":1227,"uniquenessScore":50,"reasons":[]}},"media":{"evidence":{"source":"no-media","verified":false,"confidence":"low","updatedAt":"2026-10-12T02:25:26.790Z","emptyReason":"No screenshots, media assets, or demo links are available."},"primaryImageUrl":null,"mediaAssetCount":0,"assets":[],"demoUrl":null},"ownerResources":{"evidence":{"source":"unclaimed","verified":false,"confidence":"low","updatedAt":"2026-10-12T02:25:26.790Z","emptyReason":"This page has not been claimed by the agent owner."},"hasCustomPage":false,"customPageUpdatedAt":null,"customLinks":[],"structuredLinks":{"docsUrl":null,"demoUrl":null,"supportUrl":null,"pricingUrl":null,"statusUrl":null},"customPage":null},"relatedAgents":{"evidence":{"source":"protocol-neighbors","verified":false,"confidence":"medium","updatedAt":"2026-10-12T16:55:10.228Z","emptyReason":null},"items":[{"id":"8ebccd8e-3863-4187-8355-c3f14e1f9edf","entityType":"agent","canonicalPath":"/agent/iofficeai-aionui","slug":"iofficeai-aionui","name":"AionUi","description":"Free, local, open-source 24/7 Cowork app and OpenClaw for Gemini CLI, Claude Code, Codex, OpenCode, Qwen Code, Goose CLI, Auggie, and more | 🌟 Star if you like it!","url":"https://github.com/iOfficeAI/AionUi","homepage":"https://www.aionui.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-10-09T19:11:12.944Z","createdAt":"2026-02-25T03:38:16.584Z","downloads":null},{"id":"b917f68a-ebff-438e-84f8-3f4b2494c0bc","entityType":"agent","canonicalPath":"/agent/activepieces-activepieces","slug":"activepieces-activepieces","name":"activepieces","description":"AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents","url":"https://github.com/activepieces/activepieces","homepage":"https://www.activepieces.com","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-15T02:22:12.426Z","createdAt":"2026-02-25T03:38:12.412Z","downloads":null},{"id":"5cb26759-3a39-483f-94cf-276a98c13bb8","entityType":"agent","canonicalPath":"/agent/cherryhq-cherry-studio","slug":"cherryhq-cherry-studio","name":"cherry-studio","description":"AI productivity studio with smart chat, autonomous agents, and 300+ assistants. Unified access to frontier LLMs","url":"https://github.com/CherryHQ/cherry-studio","homepage":"https://cherry-ai.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-11T14:38:40.986Z","createdAt":"2026-02-25T03:38:19.379Z","downloads":null},{"id":"6f6582d0-5d76-4f0f-b81d-86520247950b","entityType":"agent","canonicalPath":"/agent/copilotkit-copilotkit","slug":"copilotkit-copilotkit","name":"CopilotKit","description":"The Frontend for Agents & Generative UI. React + Angular","url":"https://github.com/CopilotKit/CopilotKit","homepage":"https://docs.copilotkit.ai","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-03-25T09:50:57.846Z","createdAt":"2026-02-25T03:39:14.617Z","downloads":null}],"links":{"hub":"/agent","source":"/agent/source/clawhub","protocols":[{"label":"OpenClaw","href":"/agent/protocol/openclew"}]}}}