/polymath-ai:llm-cost-latencyfrom polymath-ai
Cut LLM cost and latency — model routing/cascade, prompt caching, batching, streaming, context trimming, output-token control, and a per-request cost/latency budget.
Ships in polymath-ai. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
LLM spend is dominated by tokens × model tier × call count. Most savings come from sending fewer tokens to a smaller model less often — measure the request first, then cut the biggest line.
Mode: analytical — judgment inside a fixed frame. Keep the output shape; every verdict cites its evidence; unknowns are marked [TBD] or [VERIFY], never filled in.
polymath-ai:llm-cost-latency.Not this when: this is a non-LLM service's latency/cost — that is polymath-performance:backend-tail-latency / perf-budget. For prompt wording quality, polymath-ai:prompt-engineer.
polymath-ai:eval-plan that the cheaper model still passes.rag-design), drop stale transcript, and reuse a stable system prompt to exploit prompt caching (order prefix-stable content first; check the provider's minimum cacheable length, cache TTL, and the write premium vs read discount, then measure the cache-hit rate). In agent loops, input cost grows with every turn because the history is re-sent — caching and summarization matter most there.LLM cost/latency plan: support-reply drafting
Per request (measured, 1,000-request sample):
input 6,200 tok (system 1,800 · retrieved 3,900 · history 500) × $3.00/M = $0.0186
output 450 tok × $15.00/M = $0.0068
total $0.0254/request · p95 latency 7.8 s (TTFT 1.1 s, generation 6.7 s)
largest line: retrieved context (61% of input cost)
Cuts (expected)
1. retrieve top-4 not top-10 chunks (eval: answer quality 91% → 90%, within noise) −$0.0070
2. prompt caching on the 1,800-token system prefix (hit rate 85% measured in staging) −$0.0041
3. cap output at 300 tokens + "3 short paragraphs" format −$0.0023, −2.2 s p95
4. route "FAQ-match" requests (38%) to the small tier after eval-plan passes on that slice
Streaming: on — first paint at TTFT
Budget + tripwire: ≤ $0.015/request and p95 ≤ 5 s; alert at 120% of either for 1 h
Prices are the provider's current list prices, cited with the date checked; an unknown price is [TBD: price], never remembered.
What SKILL.md sets; muted values are Claude Code's defaults
6 skills in this plugin
/agent-designDesign an LLM agent — architecture (ReAct, plan-execute, reflexion), tool/function-calling contract, memory, multi-agent orchestration, and the stop/budget conditions./eval-planDesign an evaluation for an LLM feature — task type, dataset shape, automated vs human rubric, regression set, decision threshold./llm-guardrailsDesign guardrails for an LLM feature — input validation, prompt-injection defenses, output filtering/schema validation, allow-deny policy, and human-in-the-loop gates.Other plugins' skills for the same job
npx claudepluginhub mohammadbafkar/polymath --plugin polymath-ai