Skip to content
SlashClone

Agent cost dashboard

@agentcosts/agent-cost-dashboard

Turn LLM usage logs into one self-contained HTML cost dashboard for an agentic product: cost per customer, per task, per successful outcome, model mix, cache hit rate, and gross margin when you add revenue by customer. Prices blank costs from an editable price table.

SkillDatav1.0.0 (latest)Tested
Activity
New: be the first to try it
  1. 1---
  2. 2name: agent-cost-dashboard
  3. 3description: Build a single-file HTML cost dashboard for an AI or agentic product from LLM usage logs. Shows cost per customer, per task or workflow, per successful outcome, model mix, cache hit rate, daily cost, and gross margin after model costs when revenue by customer is provided. Use when the user asks "what do our agents cost", "cost per customer", "cost per task", "LLM spend dashboard", "which customers are unprofitable", "is caching working", or has token usage logs or a provider usage export.
  4. 4license: MIT
  5. 5---
  6. 6
  7. 7# Agent cost dashboard
  8. 8
  9. 9Token bills arrive as one big number. This kit splits it by customer, by task, and by model, and divides by successful outcomes, because a failed agent run still costs money. One script, one HTML file with no external scripts, ready to attach to a pricing or board discussion.
  10. 11## Inputs
  11. 131. **Usage CSV** in `data/` in the shared schema (one row per model call):
  12. 15 ```csv
  13. 16 timestamp,customer,task,run_id,provider,model,input_tokens,output_tokens,cache_read_tokens,cache_write_tokens,cost_usd,outcome
  14. 17 2026-10-01T09:12:00Z,northwind-co,research_agent,run-00042,anthropic,claude-opus-5-5,9000,2500,90000,0,,success
  15. 18 ```
  16. 20 - `input_tokens` is **uncached** input only. Cache reads and writes go in their own columns.
  17. 21 - `run_id` groups the calls of one task run (optional; without it each row is a run).
  18. 22 - `outcome`: `success` or `failure` on any row of the run (optional, but cost per success needs it).
  19. 23 - `cost_usd`: leave blank to price from the price table.
  20. 25 App logs usually have all of this. Provider exports do not know your customers or tasks; convert them with the `llm-usage-normalizer` kit first.
  21. 262. **Price table** (`data/llm-prices.csv`, or `examples/prices.csv` to start): per-million-token prices per model. **Prices change. Check them against each provider's current pricing page and update `checked_on`;** the script warns when prices were never checked or are over 60 days old.
  22. 273. **Revenue by customer** (optional): `customer,month,revenue`. Adds gross margin after LLM cost per customer.
  23. 29## Steps
  24. 311. Check the usage file: date range, row count, customers, tasks, models. Confirm what one row is (one call) and whether `input_tokens` includes cached tokens. If it does (common in exports from OpenAI-style APIs), stop and convert with `llm-usage-normalizer`, or cache savings will be double counted.
  25. 322. Run:
  26. 34 ```bash
  27. 35 node scripts/cost-dashboard.mjs data/usage.csv --prices data/llm-prices.csv --revenue data/revenue.csv --title "Agent costs, October" --out out/agent-costs.html
  28. 36 ```
  29. 38 Limit the range with `--from 2026-10-01 --to 2026-10-31` so it matches the revenue month.
  30. 393. If the script warns about unpriced models, add them to the price table and rerun. Do not guess a price; ask the user or point them to the provider's pricing page.
  31. 404. Give a read-out from `out/agent-costs.json`: total cost, cost per successful outcome, the most expensive task per success, the model that dominates spend, cache hit rate, and any customer with gross margin under 60% or negative.
  32. 415. Suggest the next move that fits: `gross-margin-by-customer` for full margins with hosting and support costs, `usage-pricing-simulator` if a customer is unprofitable, `consumption-guardrails` if one day or one customer spiked.
  33. 43## Reading the numbers
  34. 45- **Cost per successful outcome** = all cost for a task (including failed runs) / successful runs. Low success rates make this number climb fast; fixing reliability is often the cheapest cost cut.
  35. 46- **Cache hit rate** = cache reads / (uncached input + cache reads + cache writes). Agents that resend long context should be well above 50%.
  36. 47- **Model mix:** if one top-tier model is most of the spend, check which steps really need it.
  37. 49## Output template
  38. 51```markdown
  39. 52**October agent costs: $147 across 573 runs (86% succeeded).**
  40. 53- Cost per successful outcome $0.30; research_agent is $1.58 per success (65% success rate).
  41. 54- claude-opus-5-5 is 90% of spend. Cache hit rate 77%.
  42. 55- Margin after LLM cost 80% overall; cobalt-labs is negative (-10%), northwind-co 69%.
  43. 56Dashboard: out/agent-costs.html
  44. 57```
  45. 59## Guardrails
  46. 61- Prices in the kit are examples, not quotes. Always say so when sharing cost numbers built from them.
  47. 62- Never call provider APIs or billing pages from this kit; it works on files.
  48. 63- Customer names are business data; keep raw rows out of chat.