cost-aware-llm-pipeline

cost-aware-llm-pipeline is a skill for Claude Code, Codex from sjarmak/coding-agent-workflows. It costs 33 tokens per session (1,309 once invoked), scanned A, a copy of cost-aware-llm-pipeline, MIT.

A set of patterns for reducing the cost of applications that call large language model APIs. It chooses models based on task difficulty, tracks spending, retries failed calls, and reuses cached prompts.

In plain words
What is it for?
Use it when building multi-provider LLM applications or processing batches with tasks of different complexity. It helps set up model selection, budget tracking, retry handling, and prompt caching.
Why use it?
It helps avoid using an expensive model for every request and makes API spending easier to keep within a budget. It also provides ways to handle temporary failures without uncontrolled retries.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: positional $N argument.

Good fit Use it when building multi-provider LLM applications or processing batches with tasks of different complexity. It helps set up model selection, budget tracking, retry handling, and prompt caching.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/sjarmak/coding-agent-workflows/cost-aware-llm-pipeline
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add sjarmak/coding-agent-workflows --skill cost-aware-llm-pipeline
Clone the repo
git clone --depth 1 https://github.com/sjarmak/coding-agent-workflows

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cost-aware-llm-pipeline

README.md
[![agentmods](https://agentmods.dev/badge/skills/sjarmak/coding-agent-workflows/cost-aware-llm-pipeline/github.svg)](https://agentmods.dev/skills/sjarmak/coding-agent-workflows/cost-aware-llm-pipeline)
Your own site
<a href="https://agentmods.dev/skills/sjarmak/coding-agent-workflows/cost-aware-llm-pipeline"><img src="https://agentmods.dev/badge/skills/sjarmak/coding-agent-workflows/cost-aware-llm-pipeline/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for cost-aware-llm-pipeline

Your own site · 80×15
<a href="https://agentmods.dev/skills/sjarmak/coding-agent-workflows/cost-aware-llm-pipeline"><img src="https://agentmods.dev/badge/skills/sjarmak/coding-agent-workflows/cost-aware-llm-pipeline.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 33 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,309 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 92% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00033 $0.01309
Opus 5.5 $0.00013 $0.00524
Sonnet 5.5 $0.00007 $0.00262
Haiku 4.5 $0.00003 $0.00131

Measured 25d ago against content hash c96da9e53fd4, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

cost-aware-llm-pipeline scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 25d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

92% identical to cost-aware-llm-pipeline — 33 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

optional/skills/cost-aware-llm-pipeline/SKILL.md · 183 lines

How it starts

The opening of the file, as written. The whole thing — 183 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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 from multiple providers
  • 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_STRONG = "configured-strong-model"
MODEL_FAST = "configured-fast-model"

_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)

2. Immutable Cost Tracking

Track cumulative spend with frozen dataclasses. Each API call returns a new tracker — never mutates state.

from dataclasses import dataclass

@dataclass(frozen=True, slots=True)
class CostRecord:
    model: str
    input_tokens: int
    output_tokens: int
    cost_usd: float

@dataclass(frozen=True, slots=True)
class CostTracker:
    budget_limit: float = 1.00
    records: tuple[CostRecord, ...] = ()

    def add(self, record: CostRecord) -> "CostTracker":
        """Return new tracker with added record (never mutates self)."""
        return CostTracker(
            budget_limit=self.budget_limit,
            records=(*self.records, record),
        )

    @property
    def total_cost(self) -> float:
        return sum(r.cost_usd for r in self.records)

    @property
    def over_budget(self) -> bool:
        return self.total_cost > self.budget_limit

Read the full file on GitHub · 183 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 25d ago First seen · 183 lines · 33 tokens per session scan A c96da9e53fd4

Subscribe to this mod's changes

cost-aware-llm-pipeline is a skill published in the GitHub repository sjarmak/coding-agent-workflows (7 stars, last pushed 2d ago), licensed MIT. It adds 33 tokens to every session and 1,309 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. It is 92% identical to cost-aware-llm-pipeline, differing in 33 lines, and is treated as a copy.

Related

Other skills, from other repositories

developing-genkit-js

Develop AI-powered applications using Genkit in Node.js/TypeScript. Use when the user asks about Genkit, AI agents, flows, or tools in JavaScript/TypeScript, or when encountering Genkit errors, validation issues, type errors, or API problems.

google/skills · 60 tokens

agent-platform-prompt-management

Manages and orchestrates prompts in Agent Platform. Use when you need to create, list, retrieve, version, or delete managed prompts in Agent Platform. Don't use for model training, model deployment to endpoints, or managing non-Agent Platform prompts.

google/skills · 55 tokens

ml-kit-genai-prompt-api

Analyzes Android codebases to implement ML Kit GenAI Prompt API. Use this skill to send natural language requests on-device to Gemini Nano, use structured output with Prompt API, implement prefix caching, optimize the current prompt, or apply best practices.".

android/skills · 57 tokens

gemini-api-dev

Use this skill when writing code that calls the Gemini API for text generation, multi-turn chat, multimodal understanding, image generation, video generation, speech generation (TTS), voice design, voice replication, streaming responses, background research tasks, function calling, structured output, or migrating from…

google-gemini/gemini-skills · 85 tokens

nowait-reasoning-optimizer

Implements the NOWAIT technique for efficient reasoning in R1-style LLMs. Use when optimizing inference of reasoning models (QwQ, DeepSeek-R1, Phi4-Reasoning, Qwen3, Kimi-VL, QvQ), reducing chain-of-thought token usage by 27-51% while preserving accuracy. Triggers on "optimize reasoning", "reduce thinking tokens"…

foryourhealth111-pixel/Vibe-Skills · 110 tokens

huashu-prompt-save

A filing tool that identifies the type of a prompt and saves it under categories such as technical, content, teaching, product, or general.

alchaincyf/huashu-skills · 48 tokens