Skip to content
Skill

Cost aware LLM pipeline

Patterns for routing LLM calls across model tiers while tracking spend and budgets

Cost aware LLM pipeline is an open-source agent skill for developer tools. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

Scripts
None
Platforms
Claude Code, Codex, Cursor
GitHub stars
66
Last commit
License
MIT
Listing updated

Similar skills

About Cost aware LLM pipeline

This skill gives an agent a set of Python patterns for keeping LLM API bills under control without dropping quality on hard tasks. It covers picking a cheaper model for simple inputs and a stronger one for complex inputs based on text length and item count, with an option to force a specific model. It also shows how to record per-call token usage and cost in an immutable tracker that checks a spending limit before each request.

The guidance adds retry logic that only repeats calls on transient network, rate limit and server errors, using exponential backoff and failing immediately on authentication or bad request errors. It also explains marking long, repeated system prompts for caching so they are not resent in full on every request. A reference table lists per-million-token input and output prices for several Claude models, and the skill combines these pieces into a single pipeline function.

The examples use the Anthropic Python SDK and expect Python with dataclasses. The skill ships only a SKILL.md with no scripts, so the agent writes the code into the user's project itself.

When your agent uses it

Cost optimization patterns for LLM API usage — model routing by task complexity, budget tracking, retry logic, and prompt caching. Use when LLM spend needs to come down, or when routing tasks across model tiers and budgets.

From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.

What it can access

From a static check of its 2 files (6 KB) on GitHub on 1 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.

Check another skill before you install it.

Install

This skill ships in the rea-skills plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

/plugin marketplace add smartworldarafath/REA_Skill
/plugin install rea-skills@smartworldarafath

Or copy only this skill to ~/.claude/skills/cost-aware-llm-pipeline:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/smartworldarafath/REA_Skill.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/cost-aware-llm-pipeline &&
cp -R "$tmp/.agents/skills/cost-aware-llm-pipeline" ~/.claude/skills/cost-aware-llm-pipeline &&
rm -rf "$tmp"

For one project only, put the folder in .claude/skills/cost-aware-llm-pipeline inside it instead.

Claude Code docs on skills

Copy the skill folder to ~/.agents/skills/cost-aware-llm-pipeline to use it in every repository:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/smartworldarafath/REA_Skill.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/cost-aware-llm-pipeline &&
cp -R "$tmp/.agents/skills/cost-aware-llm-pipeline" ~/.agents/skills/cost-aware-llm-pipeline &&
rm -rf "$tmp"

For one repository only, put the folder in .agents/skills/cost-aware-llm-pipeline inside it instead.

Codex docs on skills

Copy the skill folder to ~/.cursor/skills/cost-aware-llm-pipeline to use it in every project:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/smartworldarafath/REA_Skill.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/cost-aware-llm-pipeline &&
cp -R "$tmp/.agents/skills/cost-aware-llm-pipeline" ~/.cursor/skills/cost-aware-llm-pipeline &&
rm -rf "$tmp"

For one project only, put the folder in .cursor/skills/cost-aware-llm-pipeline inside it instead.

Cursor docs on skills

Run in a terminal (add --scope workspace to install it for the current workspace only):

gemini skills install https://github.com/smartworldarafath/REA_Skill.git --path .agents/skills/cost-aware-llm-pipeline

Or copy the folder to ~/.gemini/skills/cost-aware-llm-pipeline yourself.

Gemini CLI docs on skills

For GitHub Copilot in VS Code, copy the skill folder to ~/.copilot/skills/cost-aware-llm-pipeline:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/smartworldarafath/REA_Skill.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/cost-aware-llm-pipeline &&
cp -R "$tmp/.agents/skills/cost-aware-llm-pipeline" ~/.copilot/skills/cost-aware-llm-pipeline &&
rm -rf "$tmp"

For one project only, put the folder in .github/skills/cost-aware-llm-pipeline inside it instead.

VS Code docs on skills

Get the folder:

git clone --depth 1 https://github.com/smartworldarafath/REA_Skill.git

Then copy REA_Skill/.agents/skills/cost-aware-llm-pipeline into your agent's skills folder as cost-aware-llm-pipeline. Agents that support SKILL.md read one folder per skill.

The SKILL.md format

What it does

Complexity-based model routing
Chooses a cheaper or more capable model based on input size and item count, with an override option.
Immutable budget tracking
Records each call's tokens and cost in a frozen tracker that reports when spend exceeds a limit.
Narrow retry handling
Retries only transient API errors with exponential backoff and fails fast on other errors.
Prompt caching setup
Shows how to mark a long system prompt for caching so repeated requests reuse it.
Model pricing reference
Provides a table of input and output token prices for several Claude model tiers.
Composable pipeline pattern
Combines routing, budget checks, retries, caching and cost tracking into one processing function.

Good for

  • Reduce the monthly bill of an app that calls Claude on every request
  • Route short and simple items to a cheaper model and long ones to a stronger model
  • Add a spending cap that stops batch processing before it overspends
  • Make an LLM client retry only on rate limits and network errors
  • Add prompt caching to a repetitive system prompt in an existing integration

Cost aware LLM pipeline FAQ

What does the skill need to run?

It uses Python with dataclasses and the Anthropic SDK in its examples, and it bundles no scripts. The agent writes the pipeline code into your project.

When does Cost aware LLM pipeline trigger?

It loads when LLM spend needs to come down or when tasks are being routed across model tiers and budgets.

Which errors does the retry logic repeat?

It retries connection errors, rate limit errors and internal server errors, up to three attempts. Authentication and bad request errors are raised immediately.

How is the budget tracked?

Each call adds a cost record to an immutable tracker, which reports over budget when total cost exceeds a set limit, default one dollar.

How do I install Cost aware LLM pipeline in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/cost-aware-llm-pipeline to use it in all your projects, or to .claude/skills/cost-aware-llm-pipeline in one project. Or install the rea-skills plugin, which includes it: /plugin marketplace add smartworldarafath/REA_Skill, then /plugin install rea-skills@smartworldarafath.

Does Cost aware LLM pipeline run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

Which AI agents can use Cost aware LLM pipeline?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

What are the best alternatives to Cost aware LLM pipeline?

The closest alternatives to Cost aware LLM pipeline are Claude API, API rate limiting helper, Orchestration, Agentic eval and Patterns.

Where this comes from

  • Description: from the skill's own SKILL.md.

More from smartworldarafath/REA_Skill

  1. Guides building and auditing UI to WCAG 2.2 AA across web, iOS and Android

    • Open source
    • 66 GitHub stars
    • Developer tools
  2. Diagnoses agent and LLM stacks for hidden failures and ranks the fixes by severity

    • Open source
    • 66 GitHub stars
    • Developer tools
  3. Compare coding agents head-to-head on your own tasks by pass rate, cost and time

    • Open source
    • 66 GitHub stars
    • Developer tools
  4. Guides an agent to design tool sets, observations and error recovery for better completion

    • Open source
    • 66 GitHub stars
    • Developer tools
  5. Lets an AI agent make x402 payments within per-task budgets and spending policies

    • Open source
    • 66 GitHub stars
    • Finance and payments