Skip to content
affaan-m avatar

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
View on GitHub

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-5 and complex work to Sonnet by text length and item count, with a force-model override
  • Enforces a budget ceiling that raises BudgetExceededError before 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 -y

Installs 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

Similar to Cost Aware Llm Pipeline

More AI Agents & LLM Apps