ai-cost-token-optimizer

Solid

Expert guide for LLM API cost optimization, Prompt Caching, model routing (Flash/Pro/Opus), semantic caching, and token budgeting / Panduan ahli optimasi biaya API LLM, Prompt Caching, model routing, dan semantic caching.

AI & Automation 46 stars 9 forks Updated 3 days ago MIT

Install

View on GitHub

Quality Score: 87/100

Stars 20%
56
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# AI Cost & Token Optimizer [English](#english) | [Bahasa Indonesia](#bahasa-indonesia) --- <a name="english"></a> ## English ### Purpose & Overview Production-grade guidelines for FinOps in AI engineering — prompt caching (Anthropic Prompt Caching, Gemini Context Caching), dynamic model routing (routing lightweight queries to Flash/Haiku and complex reasoning to Pro/Opus), semantic caching with Redis/GPTCache, and real-time token expenditure tracking. ### Key Capabilities - **Prompt & Context Caching**: Storing static system prompts, long-context documents, and schemas in cache to reduce token costs by up to 90%. - **Model Router**: Heuristic and classifier-based routing between ultra-fast Flash models and high-reasoning Pro models. - **Semantic Caching**: Hashing query vector embeddings to serve cached responses for semantically identical user queries. ```typescript // Model Routing Strategy Example export function selectOptimalModel(promptLength: number, taskType: 'classification' | 'reasoning' | 'summary') { if (taskType === 'classification' || promptLength < 500) { return 'gemini-3.5-flash'; // High speed, ultra low cost } return 'gemini-3.1-pro'; // Complex reasoning } ``` ### Implementation Checklist - [ ] Enable Context Caching for static system prompts or documents larger than 32k tokens. - [ ] Implement a router heuristic: use `gemini-3.5-flash` for simple parsing and `gemini-3.1-pro` for deep reasoning. - [ ] Set up semantic caching (e.g., Redis + ...

Details

Author
roedyrustam
Repository
roedyrustam/vibes-plug
Created
3 months ago
Last Updated
3 days ago
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category