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- Total cost
- $0.02
- Total tokens
- 4.2k3.8k in · 440 out
- Most expensive
- Outline the notesOpus 5.5Top3.8k440$0.022.8s
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.
cargo install --git https://github.com/ismailqureshi72/Oxyn oxyn-cli
oxyn init
oxyn add spend-breakdownuse 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
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.
- 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.
- 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.
- 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.
- 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.1sPrompt
Write the v2.4 notes from the six groups; lead with the breaking changes.
Response1,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.
- 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.0sInput
–
Error2 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.
- 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 Flash+434.9k1.1k$0.037.9s
- 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.
- 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.
- 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.
- 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
| Prop | Type | Default | Description |
|---|---|---|---|
steps | Option<Vec<CostStep>> | Default::default() | The run's steps (the demo's when `None`). |
task | String | "Release notes for v2.4" | What the run is about, muted next to the title. |
tokens | bool | Default::default() | Starts in the tokens view. |
collapsed | Vec<String> | Default::default() | Sub-agents folded from the start (ids). |
open_id | String | Default::default() | A step whose details are open from the start. |
live | bool | Default::default() | Demo: the run plays out step by step (`step_ms` apart). |
step_ms | u64 | 900 | Gap between steps while live, ms. |
title | String | "Run cost" | Heading. |
nowrequired | ClockMs | — | The clock. |
style | String | Default::default() | `clean`, `classic`, or empty to follow `data-cstyle`. |
on_mode_change | EventHandler<String> | — | The switch was used (`cost` / `tokens`). |
on_open_change | EventHandler<String> | — | Details opened (id) or closed (empty). |
on_collapsed_change | EventHandler<Vec<String>> | — | The folded sub-agents changed. |
Read from the Rust signature and doc comments.
Keyboard interactions
| Key | Action |
|---|---|
| Tab | The switch, the most expensive step, then the rows – one stop |
| ↑ ↓orHome End | Between the rows |
| →or← | Opens or folds a sub-agent |
| EnterorSpace | Opens or closes the focused step's details |
| Escape | Closes 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
SpendBreakdownfromoxyn_dioxusand includeSTATUS_INDICATOR_CSSplus the token stylesheet once. - A GPUI version exists:
SpendBreakdownElinoxyn_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.