Cost Waterfall

Where the money and tokens of an agent run go, step by step, without double counting.

Every model call, tool call and sub-agent of a run as a waterfall: each step's cost stacks on the ones before it until the bar reaches the total, with the budget line across. Switch between cost and tokens, or sort by the most expensive step; open a step for its tokens, cached tokens and price.

PROGet Cost Waterfall and 176 other Pro components with pro lifetime — Get Pro

Category
AI Agent
Access
Pro
Source
407 lines · one file
States
6 drawn
Added
13 Nov 2026

The decision inside it

Totals never count a sub-agent twice

A sub-agent's calls roll up into its parent, so each parent row shows its own cost and its total separately, and the run total is the sum of own costs. Cached input is priced at the cache rate, which is where most hand-rolled cost views overstate the bill.

When to use it

Use Cost Waterfall to show where one agent run's money and tokens went, step by step, with sub-agents rolled up and a budget line. For spend over time use Usage Meter; for timing use Trace Waterfall.

Installation

How you get it

Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.

Use Liro's Cost Waterfall for this.
Install it: npx shadcn@latest add @liro/cost-waterfall
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/cost-waterfall.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.

For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @liro registry with your CLI token: see the Namespaced tab.

Usage

components/run-cost.tsx
import { CostWaterfall, type CostStep, type ModelPrice } from "@/components/ui/cost-waterfall";

const PRICES: Record<string, ModelPrice> = {
  "claude-sonnet": { input: 3, cached: 0.3, output: 15 },
};

export function RunCost({ steps }: { steps: CostStep[] }) {
  return <CostWaterfall title="Run cost" steps={steps} prices={PRICES} budget={150} />;
}

API reference

“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

TypeNotes
stepsCostStep[] Yes–
pricesRecord<string, ModelPrice> Yes–
budgetnumber NoThe run's budget in cents. Draws a line and turns the part above it amber.
titlestring No–
defaultMeasure"cost" | "tokens" NoStart on cost (default) or tokens.
defaultSort"time" | "cost" NoStart in run order (default) or ranked by the most expensive step.
lookLook No–

Dependencies

npm packages

clsxframer-motionlucide-reacttailwind-merge

Liro foundations, installed alongside it

liro-theme

States

All of them are drawn by the component. None is left for you to design.

  • One run
  • Over budget
  • Tokens
  • Most expensive
  • Running
  • Empty

Accessibility

  • Keyboard reachable throughout, in visual order
  • Focus trapped in overlays, Escape closes them
  • Focus returns to whatever opened it
  • Live regions announce what changed, not that something did
  • Honours prefers-reduced-motion

Responsive behavior

  • Sizes to its container, not the viewport
  • Usable from 320px up
  • Pointer-based interaction, so trackpad and touch both work
  • No hover-only affordances