cost-latency-estimator
Skill0 starsChanged 8 days agoMITView on GitHub
Estimate tokens per turn, cost per conversation, monthly LLM spend and response latency for an agent or LLM feature from traffic and token assumptions - system prompt, tool definitions, retrieved context, history growth, tool-call round trips, prompt caching, model routing mix, fixed infrastructure costs, budget check and traffic scenarios - with a script driven by a configurable price table (no prices built in; you enter your LLM provider's current prices). Use when quoting or budgeting an agent project, choosing between models or architectures, explaining why costs grew, setting rate limits, or checking if a design meets a latency target.
In this repository9 other files it gives its agents.
- AGENTS.mdAGENTS.md
- agent-deployment-checklistSkill
- agent-scopingSkill
- conversation-log-analysisSkill
- eval-harnessSkill
- guardrails-and-safetySkill
- rag-ingestionSkill
- system-prompt-reviewSkill
- tool-schema-designSkill
The file
Files
Cost and latency estimator
Agent costs are dominated by input tokens that repeat on every call: system prompt, tool definitions, retrieved context and conversation history. Model them explicitly before quoting a price or picking an architecture.
Paths below are relative to this skill's folder.
When to use
- "How much will this chatbot cost per month?", proposals and budgets
- Comparing designs: bigger context vs. retrieval, one large model vs. routing, caching on/off
- "Why did our bill triple?" (history growth, tool loops, retrieved context)
- Checking whether a multi-tool design can meet a response-time target
When not to use
- Exact billing reconciliation: use your LLM provider's usage reports
- Load testing real latency: measure with real traffic; use this for planning
- Infrastructure sizing for self-hosted models (GPU memory, throughput): different model
Workflow
- Get current prices from the user or their LLM provider's pricing page: input, output and
cached-input price per 1M tokens, plus typical time to first token and output speed. Never
rely on remembered prices; they change. Record the date and source in the config
_note. - Measure token sizes of the real prompt, tool definitions and a typical retrieved context:
(characters / 4 is a rough estimate; use the provider's tokenizer when precision matters).python3 scripts/estimate_cost.py --tokens-file prompt.txt --tokens-file tools.json - Write the config. Copy assets/example-config.json and set models, routing shares (sum to 1), traffic, tokens, caching, fixed monthly costs and budget. Field meanings are in references/assumptions.md.
- Run the estimate.
Exit 1 when the total exceedspython3 scripts/estimate_cost.py config.json python3 scripts/estimate_cost.py config.json --compare # 0.5x, 1x, 2x, 5x traffic python3 scripts/estimate_cost.py config.json --set traffic.conversations_per_day=5000 \ --set caching.cached_fraction_of_static=0 --jsonbudget_monthly. - Find the levers. Re-run with
--setto see the effect of: shorter system prompt, fewer tool definitions per call, smallerretrieved_context,history_carryover=false(summaries), caching, routing more traffic to a smaller model, fewer tool calls per turn. Report the top three by saving. - Check latency per turn against the target (e.g. first token in under 2 s for chat). Each tool call adds a model round trip plus tool latency; parallel tool calls or fewer steps are usually the fix.
- Report with ranges. State assumptions, the date of the prices, a low/expected/high range (traffic scenarios) and what will be measured in the pilot to replace guesses.
Output
Example with the placeholder prices in assets/example-config.json:
Assumptions: prices from <provider pricing page, date>, 1,000 conversations/day, 4 turns
small-model (80%): 0.0094 USD/conversation, 225.12 USD/month; latency per turn 3,008 ms
large-model (20%): 0.0593 USD/conversation, 355.68 USD/month; latency per turn 5,842 ms
LLM 580.80 + other 130.00 = 710.80 USD/month (budget 1,500: within)
Scenarios: x0.5 420, x2 1,292, x5 3,034 USD/month
Levers (LLM cost): 95% small-model routing -> 356 (-39%); retrieved context 1,500 -> 800 tokens
-> 455 (-22%); history summaries -> 505 (-13%). Without caching it would be 872 (+50%).
Latency: 0.5 tool calls/turn on large-model gives ~5.8 s per turn; target 4 s -> fewer tool steps.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
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.

