Skip to content
Back

Spend breakdown

A run's spend, step by step: model calls, tools and sub-agents stack across to the total, each with its model, tokens in and out, price and duration; the priciest step is flagged and one toggle swaps money for tokens.

oxyn add spend-breakdown
MCP

Run cost

Release notes for v2.4
Live
Total cost
$0.02
Total tokens
4.2k3.8k in · 440 out
Most expensive
  • Outline the notesOpus 5.5Top3.8k440$0.022.8s
Dioxus
rsx! {
    SpendBreakdown {
        steps: Some(run.cost_steps()),
        task: run.task.clone(),
        now: clock.now(),
        on_open_change: move |id| inspect(id),
    }
}

Rendered from Rust at build time · goes live when visible

When to use

  • A run's spend, step by step: model calls, tools and sub-agents stack across to the total, each with its model, tokens in and out, price and duration; the priciest step is flagged and one toggle swaps money for tokens.

When not to use

  • An agent asks before it acts: use Approval Card instead.
  • Several open requests in one card: use Approval pager instead.
  • An agent's question in its own card above the composer: use Decision Card instead.

Installation

Spend breakdown is free and MIT. The oxyn CLI copies its code, and the components it needs, into src/oxyn/ of your Dioxus or GPUI project, so it is yours to change.

Terminal
cargo install --git https://github.com/ismailqureshi72/Oxyn oxyn-cli
oxyn init
oxyn add spend-breakdown
Rust
use crate::oxyn::{SpendBreakdown, STATUS_INDICATOR_CSS};

Rather depend on the crate? cargo add oxyn-dioxus oxyn-core --git https://github.com/ismailqureshi72/Oxyn, then use oxyn_dioxus::{SpendBreakdown, STATUS_INDICATOR_CSS};

Usage

Dioxus · rust
rsx! {
    SpendBreakdown {
        steps: Some(run.cost_steps()),
        task: run.task.clone(),
        now: clock.now(),
        on_open_change: move |id| inspect(id),
    }
}

Examples

Live

The run plays out – rows slide in, the running bar shines, the totals climb, Live turns Done.

Run cost

Release notes for v2.4
Live
Total cost
$0.02
Total tokens
4.2k3.8k in · 440 out
Most expensive
  • Outline the notesOpus 5.5Top3.8k440$0.022.8s
Code
rsx! {
    SpendBreakdown {
        steps: Some(run.cost_steps()),
        task: run.task.clone(),
        now: clock.now(),
        on_open_change: move |id| inspect(id),
    }
}

Settled

The finished run in dollars: the most expensive step tagged Top and named in the stats.

Run cost

Release notes for v2.4
Done
Total cost
$0.42
Total tokens
116k106k in · 9.5k out
Most expensive
  • Outline the notesOpus 5.53.8k880$0.042.8s
  • CollectorGemini 3.8 Flash34.9k1.1k$0.037.9s
  • search_prssince v2.3––$0.011.2s
  • search_prslabels: breaking––$0.01900ms
  • read_diffs12 files–––2.3s
  • Group the changesGemini 3.8 Flash34.9k1.1k$0.013.5s
  • Write the notesOpus 5.5Top20.6k5.2k$0.237.1s
  • CheckerHaiku 5.524.2k640$0.033.1s
  • Check claimsHaiku 5.524.2k640$0.031.9s
  • check_links27 links–––1.0s
  • Apply fixesSonnet 5.522.9k1.7k$0.092.6s
  • Publish notesNotion–––820ms
Code
rsx! {
    SpendBreakdown {
        steps: Some(run.cost_steps()),
        task: run.task.clone(),
        now: clock.now(),
        on_open_change: move |id| inspect(id),
    }
}

Tokens

Open in the tokens view: the axis and every bar re-based on tokens in and out.

Run cost

Release notes for v2.4
Done
Total cost
$0.42
Total tokens
116k106k in · 9.5k out
Most expensive
  • Outline the notesOpus 5.53.8k880$0.042.8s
  • CollectorGemini 3.8 Flash34.9k1.1k$0.037.9s
  • search_prssince v2.3––$0.011.2s
  • search_prslabels: breaking––$0.01900ms
  • read_diffs12 files–––2.3s
  • Group the changesGemini 3.8 Flash34.9k1.1k$0.013.5s
  • Write the notesOpus 5.5Top20.6k5.2k$0.237.1s
  • CheckerHaiku 5.524.2k640$0.033.1s
  • Check claimsHaiku 5.524.2k640$0.031.9s
  • check_links27 links–––1.0s
  • Apply fixesSonnet 5.522.9k1.7k$0.092.6s
  • Publish notesNotion–––820ms
Code
rsx! {
    SpendBreakdown {
        steps: Some(run.cost_steps()),
        task: run.task.clone(),
        now: clock.now(),
        on_open_change: move |id| inspect(id),
    }
}

Details

A step opened: its prompt and response under the row.

Run cost

Release notes for v2.4
Done
Total cost
$0.42
Total tokens
116k106k in · 9.5k out
Most expensive
  • Outline the notesOpus 5.53.8k880$0.042.8s
  • CollectorGemini 3.8 Flash34.9k1.1k$0.037.9s
  • search_prssince v2.3––$0.011.2s
  • search_prslabels: breaking––$0.01900ms
  • read_diffs12 files–––2.3s
  • Group the changesGemini 3.8 Flash34.9k1.1k$0.013.5s
  • Write the notesOpus 5.5Top20.6k5.2k$0.237.1s
    Prompt

    Write the v2.4 notes from the six groups; lead with the breaking changes.

    Response

    1,240 words · 6 sections

  • CheckerHaiku 5.524.2k640$0.033.1s
  • Check claimsHaiku 5.524.2k640$0.031.9s
  • check_links27 links–––1.0s
  • Apply fixesSonnet 5.522.9k1.7k$0.092.6s
  • Publish notesNotion–––820ms
Code
rsx! {
    SpendBreakdown {
        steps: Some(run.cost_steps()),
        task: run.task.clone(),
        now: clock.now(),
        on_open_change: move |id| inspect(id),
    }
}

Failed step

A failed tool call: a red sliver, a red time, the error in its details.

Run cost

Release notes for v2.4
Done
Total cost
$0.42
Total tokens
116k106k in · 9.5k out
Most expensive
  • Outline the notesOpus 5.53.8k880$0.042.8s
  • CollectorGemini 3.8 Flash34.9k1.1k$0.037.9s
  • search_prssince v2.3––$0.011.2s
  • search_prslabels: breaking––$0.01900ms
  • read_diffs12 files–––2.3s
  • Group the changesGemini 3.8 Flash34.9k1.1k$0.013.5s
  • Write the notesOpus 5.5Top20.6k5.2k$0.237.1s
  • CheckerHaiku 5.524.2k640$0.033.1s
  • Check claimsHaiku 5.524.2k640$0.031.9s
  • check_links27 links–––1.0s
    Input

    –

    Error

    2 links time out (docs preview is down)

  • Apply fixesSonnet 5.522.9k1.7k$0.092.6s
  • Publish notesNotion–––820ms
Code
rsx! {
    SpendBreakdown {
        steps: Some(run.cost_steps()),
        task: run.task.clone(),
        now: clock.now(),
        on_open_change: move |id| inspect(id),
    }
}

Folded

Fold finished sub-agents: the collector folded with a +4 chip.

Run cost

Release notes for v2.4
Done
Total cost
$0.42
Total tokens
116k106k in · 9.5k out
Most expensive
  • Outline the notesOpus 5.53.8k880$0.042.8s
  • Write the notesOpus 5.5Top20.6k5.2k$0.237.1s
  • CheckerHaiku 5.524.2k640$0.033.1s
  • Check claimsHaiku 5.524.2k640$0.031.9s
  • check_links27 links–––1.0s
  • Apply fixesSonnet 5.522.9k1.7k$0.092.6s
  • Publish notesNotion–––820ms
Code
rsx! {
    SpendBreakdown {
        steps: Some(run.cost_steps()),
        task: run.task.clone(),
        now: clock.now(),
        on_open_change: move |id| inspect(id),
    }
}

Medium

Under 720 px the In and Out columns step aside.

Run cost

Release notes for v2.4
Done
Total cost
$0.42
Total tokens
116k106k in · 9.5k out
Most expensive
  • Outline the notesOpus 5.53.8k880$0.042.8s
  • CollectorGemini 3.8 Flash34.9k1.1k$0.037.9s
  • search_prssince v2.3––$0.011.2s
  • search_prslabels: breaking––$0.01900ms
  • read_diffs12 files–––2.3s
  • Group the changesGemini 3.8 Flash34.9k1.1k$0.013.5s
  • Write the notesOpus 5.5Top20.6k5.2k$0.237.1s
  • CheckerHaiku 5.524.2k640$0.033.1s
  • Check claimsHaiku 5.524.2k640$0.031.9s
  • check_links27 links–––1.0s
  • Apply fixesSonnet 5.522.9k1.7k$0.092.6s
  • Publish notesNotion–––820ms
Code
rsx! {
    SpendBreakdown {
        steps: Some(run.cost_steps()),
        task: run.task.clone(),
        now: clock.now(),
        on_open_change: move |id| inspect(id),
    }
}

Narrow

Under 520 px each row stacks: name, cost and time, the bar under it.

Run cost

Release notes for v2.4
Done
Total cost
$0.42
Total tokens
116k106k in · 9.5k out
Most expensive
  • Outline the notesOpus 5.53.8k880$0.042.8s
  • CollectorGemini 3.8 Flash34.9k1.1k$0.037.9s
  • search_prssince v2.3––$0.011.2s
  • search_prslabels: breaking––$0.01900ms
  • read_diffs12 files–––2.3s
  • Group the changesGemini 3.8 Flash34.9k1.1k$0.013.5s
  • Write the notesOpus 5.5Top20.6k5.2k$0.237.1s
  • CheckerHaiku 5.524.2k640$0.033.1s
  • Check claimsHaiku 5.524.2k640$0.031.9s
  • check_links27 links–––1.0s
  • Apply fixesSonnet 5.522.9k1.7k$0.092.6s
  • Publish notesNotion–––820ms
Code
rsx! {
    SpendBreakdown {
        steps: Some(run.cost_steps()),
        task: run.task.clone(),
        now: clock.now(),
        on_open_change: move |id| inspect(id),
    }
}

Classic

Classic style: the header on a grey band, sentence-case stats, saturated bars.

Run cost

Release notes for v2.4
Done
Total cost
$0.42
Total tokens
116k106k in · 9.5k out
Most expensive
  • Outline the notesOpus 5.53.8k880$0.042.8s
  • CollectorGemini 3.8 Flash34.9k1.1k$0.037.9s
  • search_prssince v2.3––$0.011.2s
  • search_prslabels: breaking––$0.01900ms
  • read_diffs12 files–––2.3s
  • Group the changesGemini 3.8 Flash34.9k1.1k$0.013.5s
  • Write the notesOpus 5.5Top20.6k5.2k$0.237.1s
  • CheckerHaiku 5.524.2k640$0.033.1s
  • Check claimsHaiku 5.524.2k640$0.031.9s
  • check_links27 links–––1.0s
  • Apply fixesSonnet 5.522.9k1.7k$0.092.6s
  • Publish notesNotion–––820ms
Code
rsx! {
    SpendBreakdown {
        steps: Some(run.cost_steps()),
        task: run.task.clone(),
        now: clock.now(),
        on_open_change: move |id| inspect(id),
    }
}

API reference

SpendBreakdown

PropTypeDefaultDescription
stepsOption<Vec<CostStep>>Default::default()The run's steps (the demo's when `None`).
taskString"Release notes for v2.4"What the run is about, muted next to the title.
tokensboolDefault::default()Starts in the tokens view.
collapsedVec<String>Default::default()Sub-agents folded from the start (ids).
open_idStringDefault::default()A step whose details are open from the start.
liveboolDefault::default()Demo: the run plays out step by step (`step_ms` apart).
step_msu64900Gap between steps while live, ms.
titleString"Run cost"Heading.
nowrequiredClockMs—The clock.
styleStringDefault::default()`clean`, `classic`, or empty to follow `data-cstyle`.
on_mode_changeEventHandler<String>—The switch was used (`cost` / `tokens`).
on_open_changeEventHandler<String>—Details opened (id) or closed (empty).
on_collapsed_changeEventHandler<Vec<String>>—The folded sub-agents changed.

Read from the Rust signature and doc comments.

Keyboard interactions

KeyAction
TabThe switch, the most expensive step, then the rows – one stop
↑ ↓orHome EndBetween the rows
→or←Opens or folds a sub-agent
EnterorSpaceOpens or closes the focused step's details
EscapeCloses the details

Accessibility

  • The rows are a tree: every step a treeitem with its level, labelled with name, kind, status, cost, tokens and time; aria-expanded on sub-agents.
  • Roving focus: only one row is in the tab order.
  • Cost and Tokens are pressed-state buttons in a named group; Live or Done is a status region.

Responsive behaviour

  • 756 px up to its container: steps left, the waterfall in the middle, the numbers right.
  • Under 720 px In and Out step aside; under 520 px each row stacks with the bar across the width.
Edge cases (spec)

Wide: steps, waterfall, numbers. Under 720 px In and Out step aside; under 520 px each row stacks – name, cost, time, then the bar across the width.

Notes for AI

  • Import SpendBreakdown from oxyn_dioxus and include STATUS_INDICATOR_CSS plus the token stylesheet once.
  • A GPUI version exists: SpendBreakdownEl in oxyn_gpui.
  • Props to set first: now.
  • It reads a clock (now) for live timers; pass one clock for the whole page rather than one per component.
  • Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.

Guides

Oxyn · 74 free components · 264 Pro components · 96 screens · 20 blocks · Dioxus and GPUI