Cost Aware Llm Pipeline
Composable LLM cost controls combining model routing, budget tracking, narrow retries, and prompt caching.
- CCM score
- 71 of 100
- skills.sh installs
- 12.7K
- GitHub stars
- 312.6K
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers four patterns: complexity-based model routing, immutable cost tracking, narrow retry logic, and prompt caching
- Routes simple work to
claude-haiku-4-5and complex work to Sonnet by text length and item count, with a force-model override - Enforces a budget ceiling that raises
BudgetExceededErrorbefore each call and retries only on transient errors - Designed for batch pipelines and production systems where API spend needs guardrails and auditable cost records
Install
$ npx -y skills add affaan-m/ecc --skill cost-aware-llm-pipeline -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
Cost-Aware LLM Pipeline
Patterns for controlling LLM API costs while maintaining quality. Combines model routing, budget tracking, retry logic, and prompt caching into a composable pipeline.
When to Activate
- Building applications that call LLM APIs (Claude, GPT, etc.)
- Processing batches of items with varying complexity
- Need to stay within a budget for API spend
- Optimizing cost without sacrificing quality on complex tasks
Core Concepts
1. Model Routing by Task Complexity
Automatically select cheaper models for simple tasks, reserving expensive models for complex ones.
MODEL_SONNET = "claude-sonnet-5"
MODEL_HAIKU = "claude-haiku-4-5-20251001"
_SONNET_TEXT_THRESHOLD = 10_000 # chars
_SONNET_ITEM_THRESHOLD = 30 # items
def select_model(
text_length: int,
item_count: int,
force_model: str | None = None,
) -> str:
"""Select model based on task complexity."""
if force_model is not None:
return force_model
if text_length >= _SONNET_TEXT_THRESHOLD or item_count >= _SONNET_ITEM_THRESHOLD:
return MODEL_SONNET # Complex task
return MODEL_HAIKU # Simple task (3-4x cheaper)
Details
- Repository
- github.com/affaan-m/ecc
- Categories
- AI Agents & LLM Apps, Backend & APIs
- First seen
- Jul 14, 2026
Questions
What does the cost-aware-llm-pipeline skill do?
It applies cost optimization patterns to LLM API usage, including model routing by task complexity, budget tracking, retry logic, and prompt caching. These four techniques combine into one composable pipeline that keeps spend down without sacrificing quality on complex tasks.
How do I install the cost-aware-llm-pipeline skill?
Run npx -y skills add affaan-m/ecc --skill cost-aware-llm-pipeline -y in a project. Once installed, the agent can route simple requests to cheaper Haiku models and reserve Sonnet for complex work.
When should I use cost-aware-llm-pipeline?
Use it when LLM spend needs to come down or when you route tasks across model tiers under a budget. It suits batch pipelines where API costs add up quickly and production systems that need budget guardrails.
Where does cost-aware-llm-pipeline rank in its category?
It sits in the top 50 of the AI Agents & LLM Apps category on Claude Marketplaces. It focuses on controlling API spend through routing, budgets, retries and caching rather than building the agent itself.
More from affaan-m/ecc
All 257- Kotlin Patterns12.7K
- Iterative Retrieval12.6K
- Django Verification12.6K
- Nextjs Turbopack12.6K
- Content Engine12.5K
- Springboot Verification12.5K
- Context Budget12.5K
- Nutrient Document Processing12.5K
- Autonomous Loops12.4K
- Architecture Decision Records12.4K
- Investor Materials12.4K
- Swiftui Patterns12.4K
- Pytorch Patterns12.3K
- Bun Runtime12.3K
- Ai First Engineering12.3K
- Flutter Dart Code Review12.2K
- Perl Security12.2K
- Regex Vs Llm Structured Text12.2K
- Compose Multiplatform Patterns12.2K
- Continuous Agent Loop12.2K
- Content Hash Cache Pattern12.1K
- Kotlin Testing12.1K
- Ai Regression Testing12.1K
- Browser Qa12.1K
Similar to Cost Aware Llm Pipeline
More AI Agents & LLM Appscost-latency-optimizerSkillpatricio0312rev/skills337 installsPractical code patterns for cutting LLM spend and response times through caching, model routing, batching, and streaming.
llm-cost-optimizerPluginalirezarezvani/claude-skills30.7K starsCut LLM API spend via model routing, prompt caching, prompt compression, and per-feature cost observability. Use when AI costs are too high, choosing between mo
Token Optimizer McpMCP serverooples595 starsToken-cost savings and cache controls for MCP clients, backed by a prompt-compression proxy and usage billing.
regex-vs-llm-structured-textSkillaffaan-m/ecc12.2K installsDecision framework and hybrid regex-first pipeline for parsing structured text at lower LLM cost.
ai-wrapper-productSkilldavila7/claude-code-templates379 installsFocused AI API wrapper patterns for products that solve specific problems, covering architecture, prompts, and cost control.