agentleFS
MuvonMuvon/octomind-tap/skills/ai-cost-finops/SKILL.md

ai-cost-finops

Skill6 starsChanged 8 months agoApache-2.0View on GitHub

Cutting LLM cost: model price book, prompt caching, Batch tiers, routing, attribution. Use when projecting LLM cost or hunting pipeline waste.

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 4 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use it when projecting cost for a new feature, hunting waste in an existing pipeline, picking a model or effort level, or setting up …

    line 34
  2. Very specific:

    Every call costs uncached_input × $in + cache_writes × $write + cache_reads × $read + output × $out (thinking tokens bill as output), plus …

    line 38
  3. Very specific:

    Verify with usage.cache_read_input_tokens.

    line 73
  4. Distinctive:

    Use for evals, backfills, embeddings, dataset enrichment, and scheduled jobs.

    line 85
  5. Distinctive:

    Before building a multi-model cascade, measure the strongest model at lower effort on the same tasks.

    line 93
  6. Distinctive:

    No markdown when the consumer is a machine.

    line 107
  7. Very specific:

    Don't ask current reasoning models to write their reasoning into the answer: it costs output tokens, and on the newest Claude models it can …

    line 108
  8. Very specific:

    Check current plan pricing on each vendor's site.

    line 123

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Overview

LLM cost is an engineering surface, not a line on the card statement. The levers that move it most in 2026, in order: prompt caching (cache reads cost a tenth of input or less), Batch/Flex tiers (50% off), effort or reasoning-depth tuning, then model routing. This skill holds the dated price book, the discount mechanics, and the optimization order with primary-source citations.

Use it when projecting cost for a new feature, hunting waste in an existing pipeline, picking a model or effort level, or setting up per-feature attribution. Skip it for prototypes spending under ~$100/month.

Mental model

Every call costs uncached_input × $in + cache_writes × $write + cache_reads × $read + output × $out (thinking tokens bill as output), plus retrieval, rerank, and storage for RAG. Judge cost per completed task, not per request: a cheaper call that needs more turns or retries is not cheaper.

Work the levers in order. Free wins first, because they don't trade quality: caching, input hygiene, output hygiene, batch. Then quality trades, measured against an eval: effort level, then model choice. The cheapest call is the one not made; then the cached one; then the batched one; then the one at lower effort or on a smaller model.

Output tokens cost 5× input on most current models, so output-length discipline (no markdown for machine consumers, no preambles) is the next lever after caching.

Rules

1. Price book (2026: verified 2026-10-12, per 1M tokens, standard tier, input/output)

Prices change quarterly. Re-check the pricing pages before any budget.

ProviderModelInputOutputNotes
AnthropicClaude Fable 5.1$10$50Most capable widely released Claude; thinking always on
AnthropicClaude Opus 5.5$4$20Default effort medium
AnthropicClaude Sonnet 5.5$2$10
AnthropicClaude Haiku 5.5$0.10$0.50Prompts ≤100K tokens; $0.50 / $2.50 above
OpenAIgpt-6-astra$10$50Cached input $1; >272K input billed at a higher tier
OpenAIgpt-6.1-sol$2$10Cached input $0.10
OpenAIgpt-6-luna$0.10$0.50Cached input $0.01
GoogleGemini 3.1 Pro (preview)$2$12≤200K prompt; $4 / $18 above
GoogleGemini 3.8 Flash$0.75$3.75Promotional to 31 Dec 2026, then $1.50 / $7.50
GoogleGemini 3.5 Flash-Lite$0.30$2.50

Sources: Anthropic pricing, OpenAI pricing, Gemini pricing. Older generations stay listed at their own prices; Claude Opus 4.7 and later use a tokenizer that emits ~1–1.35× the tokens of older Claude models, so re-baseline with token counting when migrating. Regional data-residency endpoints carry uplifts on some providers (OpenAI: +10%).

2. Prompt caching

Anthropic (docs):

  • Writes cost 1.25× input (5-minute TTL, the default) or 2× (1-hour TTL, set "ttl": "1h"). Reads cost ~0.1× input; 0.05× on Opus 5.5 and 0.025× on Fable 5.1.
  • Break-even: two requests on the 5-minute TTL, three on the 1-hour. A cache read refreshes the TTL, so traffic that arrives less than 5 minutes apart never needs the 1-hour TTL.
  • Prefix match in render order tools → system → messages; any byte change invalidates everything after it. Max 4 breakpoints; minimum cacheable prefix is model-dependent (512–4096 tokens) and shorter prefixes silently don't cache.
  • Top-level automatic caching moves the breakpoint forward as a conversation grows; add an explicit breakpoint on the static system prefix for agent loops.
  • Caches are model-scoped, and changing top-level effort mid-conversation invalidates the message cache.
  • Verify with usage.cache_read_input_tokens; zero across repeated requests means a silent invalidator (timestamps in the system prompt, unsorted JSON, a varying tool list).

OpenAI: automatic prefix caching, no code change; cached input is billed at 5–10% of input on the GPT-6 family (pricing page). Gemini: implicit caching plus explicit context caches billed at ~10% of input plus hourly storage.

Cache system prompts, tool and skill definitions, few-shot examples, and long static documents — anything long, stable, and re-sent.

3. Batch and Flex (50% off anything nobody waits on)

  • Anthropic Message Batches — 50% off every token, including cache reads and writes; results within 24 hours, in any order (key by custom_id). No mid-batch tool loop. docs
  • OpenAI Batch and Flex — both 50% below standard on current models. pricing
  • Gemini Batch and Flex — 50% off; Priority costs ~1.8×. pricing

Use for evals, backfills, embeddings, dataset enrichment, and scheduled jobs.

4. Effort before routing

Current frontier models expose a reasoning-depth control: Claude output_config.effort (low → max, with adaptive thinking), OpenAI reasoning effort, Gemini thinking level. Effort is the first quality-trading lever: it trades thoroughness for tokens inside one model and keeps one cache namespace.

  • Effort names don't mean the same thinking budget across models; re-run the sweep per model. Anthropic reports Opus 5.5 at medium matching or beating Opus 5 at high on coding and knowledge work (prompting guide).
  • Chat, classification, and high-volume routes often hold quality at low; coding and long-horizon agents repay high/xhigh. Tune per route, not globally.
  • Before building a multi-model cascade, measure the strongest model at lower effort on the same tasks.

5. Model routing

ApproachProsCons
Manual rules (classify by complexity, escalate on validation failure)Predictable, auditableNeeds upfront classification logic
Commercial routers (Martian, NotDiamond, OpenRouter Auto)Zero setupVendor-claimed savings; often pick expensive models (RouterArena, arXiv:2510.00202)

Pattern: small model by default (Haiku, Flash-Lite, Luna), escalate to mid-tier on low confidence or failed validation, reserve the top tier for hard-reasoning paths — with an eval gate per tier. Every model switch forfeits cache reuse.

6. Output and input hygiene

  • Structured outputs (Anthropic output_config.format and strict tools, OpenAI Structured Outputs) kill preambles and parse-retry loops.
  • No markdown when the consumer is a machine; ban preambles in the system prompt.
  • Don't ask current reasoning models to write their reasoning into the answer: it costs output tokens, and on the newest Claude models it can be declined (reasoning_extraction). Lower effort instead.
  • Trim tool results to high-signal fields; cap or compact long histories.
  • Set max_tokens with room for thinking — a truncated answer you retry costs twice.

7. FinOps observability and attribution

ToolModeStrength
Provider usage/cost APIs (Anthropic Usage & Cost Admin API, OpenAI usage)Org-levelGround truth for spend by model, key, workspace
HeliconeGateway (URL swap)Always-on cost/latency logging; OSS
LangfuseSDK or OTLPPer-generation cost tracking; OSS
Phoenix (Arize)OSS, OTLP-nativeLocal-first trace analysis
LangSmithSDKDeepest LangChain integration
VantageFinOps platformCross-provider and cloud roll-up, per-team allocation

Check current plan pricing on each vendor's site. Tag every call with feature, team, customer_tier, experiment_arm; use per-project API keys or workspaces so usage reports are attributable. Without attribution you can't optimize.

8. Waste patterns

PatternImpactFix
Uncached system prompt and tools re-sent every turnFull input price per turnStable prefix + breakpoints; verify hit rate
Timestamp or request ID in the system promptCache never hitsMove volatile content after the last breakpoint
Over-retrieved RAG contextInput bloatRerank + tighter top-k
JSON parse-retry loops2–3× cost on flaky callsStructured outputs / strict tools
Top tier at top effort for routine trafficSeveral-fold over-spendEffort sweep, then routing, gated by evals
No streaming abortPay for bad outputStream and stop on quality signals

9. RAG cost stack

  • Embeddings are usually a rounding error next to generation; upgrade the embedding model only when retrieval evals show lift.
  • Rerankers bill per search (Cohere: one query + up to 100 documents; Rerank 4 shipped Apr 2026) — cost scales with candidates, so rerank the top 50, not the top 500.
  • Managed vector DBs (Pinecone, Weaviate, Qdrant, Turbopuffer) price on storage, reads, and writes; self-hosting wins at very large scale. Price your own volume on the vendor pages.
  • A stable corpus under ~200K tokens can skip RAG entirely: put it in the prompt and cache it (Anthropic Contextual Retrieval).

Examples

Bad: "Use Opus for everything; it's the best." No per-task cost, no eval, no effort setting.

Good: "Support triage runs 40K requests/day with a 6K-token static prefix. Caching the prefix cuts that input to ~0.1× after the first write; the nightly re-classification moves to Batch at 50% off; an effort sweep shows low holds the 94% routing accuracy of high. Projected per-ticket cost drops from $X to $Y (prices from the pricing page, 2026-10-12)."

Case studies (Klarna, Intercom Fin) are useful for direction only; budget from your own attribution data, not vendor blog numbers.

Checklist

  • Prices quoted with the date checked and the source URL
  • Cache hit rate measured from usage fields; static prefix byte-stable; TTL chosen from request gaps
  • Every non-real-time path on Batch or Flex
  • Effort swept per route against an eval before any model routing
  • Routing tiers each gated by an eval; cache-scope loss accounted for
  • Structured outputs on machine-consumed paths; no preambles; max_tokens leaves room for thinking
  • RAG: rerank depth bounded; long-context-with-cache considered for small corpora
  • Every call tagged for per-feature attribution; per-project keys or workspaces
  • Cost reported per completed task, not per request

Composition / References

Within-domain pairings:

  • Pairs with the sibling AI skill on RAG patterns (embeddings, rerank, vector DB costs).
  • Pairs with the sibling AI skill on agent design (multi-agent and tool-loop cost).
  • Pairs with the sibling AI skill on evals (every effort or routing change needs an eval gate; eval runs belong on Batch).

Primary sources:

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.