cost-aware-llm-pipeline SKILL.md skillA
cost-aware-llm-pipeline from affaan-m/ecc is an agent skill: a SKILL.md folder an AI agent loads when a task calls for it.
mdr add affaan-m/ecc/cost-aware-llm-pipeline@git:20260829.1c42fe7Pins git:20260829.1c42fe7 in mdr.lock. Pin the fingerprint instead.
- Audit grade
- A, 17 of 17 checks passed
- Kind
- SKILL.md skill
- Repository
- affaan-m/ecc
- Path
docs/ja-JP/skills/cost-aware-llm-pipeline/SKILL.md- Versions recorded
- 5
- Latest version
- git:20260829.1c42fe7, committed Aug 29, 2026
- First version recorded
- Aug 8, 2026
- Size
- 7,147 bytes
- Repository stars
- 299,696
- License
- MIT
LLM APIの使用量のコスト最適化パターン — タスクの複雑さによるモデルルーティング、予算追跡、リトライロジック、プロンプトキャッシング。.
Collected from public GitHub. Every version is saved exactly as it was and never changes. Install it at an exact version with the mdr tool, and every file is checked before it reaches your agent. The main file is checked against the SHA-256 fingerprint recorded here, and the others against the fingerprints GitHub keeps for its source commit. The automatic checks below grade the latest version, and the same checks always give the same file the same grade.
What the file says
# コスト認識LLMパイプライン
品質を維持しながらLLM APIのコストをコントロールするためのパターン。モデルルーティング、予算追跡、リトライロジック、プロンプトキャッシングを組み合わせた合成可能なパイプライン。
## 起動条件
- LLM APIを呼び出すアプリケーションの構築(Claude、GPTなど)
- 複雑さが異なるアイテムのバッチ処理
- API支出の予算内に収める必要がある場合
- 複雑なタスクの品質を犠牲にせずにコストを最適化する場合
## コアコンセプト
### 1. タスクの複雑さによるモデルルーティング
シンプルなタスクには自動的に安価なモデルを選択し、複雑なタスクのために高価なモデルを予約します。
```python
MODEL_SONNET = "claude-sonnet-5"
MODEL_HAIKU = "claude-haiku-4-5-20251001"
_SONNET_TEXT_THRESHOLD = 10_000 # 文字数
_SONNET_ITEM_THRESHOLD = 30 # アイテム数
def select_model(
text_length: int,
item_count: int,
force_model: str | None = None,
) -> str:
"""タスクの複雑さに基づいてモデルを選択。"""
if force_model is not None:
return force_model
if text_length >= _SONNET_TEXT_THRESHOLD or item_count >= _SONNET_ITEM_THRESHOLD:
return MODEL_SONNET # 複雑なタスク
return MODEL_HAIKU # シンプルなタスク(3〜4倍安価)
```
### 2. 不変のコスト追跡
凍結データクラスで累積支出を追跡します。各API呼び出しは新しいトラッカーを返します — 状態を変更しません。
```python
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
…Read the whole file at its exact version.
How to install
mdr add affaan-m/ecc/cost-aware-llm-pipeline@sha256:dff5c6f753c1a069The line at the top of this page pins the label git:20260829.1c42fe7, which is what most people want. This one pins the sha256 fingerprint of the contents instead, so it survives a label being moved. Either way the exact version is written to mdr.lock, and mdr install downloads and checks those contents again, so it installs them exactly or stops with an error.
[](https://markdownregistry.com/a/art_42zr6maapbm2w4ry)
8 badge image fetches in 30 days. What the badge shows.
Versions
The registry has recorded 5 versions of this file, between Aug 8, 2026 and Aug 29, 2026, about one every 5 days.
| version | committed | commit | size | audit | |
|---|---|---|---|---|---|
| git:20260829.1c42fe7 latest | 2026-08-29 | 1c42fe7 | 7,147 B | A | view · diff |
| git:20260829.08024bb | 2026-08-29 | 08024bb | 7,012 B | A | view · diff |
| git:20260829.558aecb | 2026-08-29 | 558aecb | 7,021 B | A | view · diff |
| git:20260811.fd1b11c | 2026-08-11 | fd1b11c | 6,982 B | A | view · diff |
| git:20260808.5e6c8f9 | 2026-08-08 | 5e6c8f9 | 7,023 B | A | view |
Audit of the latest version
- pass: Frontmatter block present
- pass: Frontmatter declares a name
- pass: Frontmatter declares a description
- pass: Size between 200 bytes and 200 KB (7147 bytes)
- pass: No zero-width or bidi control characters
- pass: No instruction hidden inside an HTML comment
- pass: No link to an exfiltration or paste host
- pass: No credential-shaped string
- pass: No instruction to send local credentials anywhere
- pass: No text hidden with inline styles
- pass: No prompt-injection phrasing
- pass: No curl or wget piped into a shell
- pass: No recursive delete of root, home or parent
- pass: No instruction to read or print local credentials
- pass: No base64 blob over 200 characters
- pass: No link to a raw IP address
- pass: No script tag
Source
affaan-m/ecc · 299,696 stars · license MIT · pushed 2026-11-06 · branch main
API
GET https://markdownregistry.com/api/v1/artifacts/art_42zr6maapbm2w4ry GET https://markdownregistry.com/api/v1/resolve?ref=affaan-m/ecc/cost-aware-llm-pipeline GET https://markdownregistry.com/api/v1/blob/dff5c6f753c1a0691d1671af24013d1c22b0f21e1b1c473ae69fd1f6430ddcd0
Your AI assistant does the legwork. You hear about the deals worth your word. Hand yours the standing instructions at modelranch.com and it joins the network that reads files like this one.
Guides: the SKILL.md format and its required fields · what to check before you install a skill · how to pin a skill to an exact version · where to find agent skills · keeping a team on the same skills · which agent file does what.