Usage
Token, time and cost usage of an agent task: UsageStat for a card and UsageTable on Table, with compact counts, the exact value in the title, honest unknown and estimated values, and summaries side by side as columns.
Example
Input tokens60K
Output tokens10.5K
Cost$0.43 (estimated)
| Metric | Value |
|---|---|
| Input tokens | 60K |
| Output tokens | 10.5K |
| Cache read | 36K |
| Cache write | unknown |
| Reasoning tokens | 4.2K |
| Duration | 20s |
| Active time | unknown |
| Cost | $0.43 (estimated) |
usage-demo.tsxCopy code
Installation
Copy code
Usage
ImportCopy code
API reference
UsageQuantity
Takes Omit<PartProps<"span">, "children"> &.
UsageStat
Takes PartProps<"div"> &.
UsageTable
Takes Omit<PartProps<"table">, "children"> &.
UsageGrid
| Prop | Type | Default |
|---|---|---|
usage | UsageSummary | – |
labels | Partial<UsageLabels> | – |
locale | string | – |
formatCurrency | (usd: number) => string | – |
variant`"compact"` lists the figures as term and value rows, for a narrow side column. | "tiles" | "compact" | "tiles" |
Also takes <div> attributes and render except children.
Other exports
usageFormatterusageLabelsusageLabelsEsusageMetricsusageGridMetricstype UsageColumntype UsageKindtype UsageLabelstype UsageMetrictype UsageQuantityPropstype UsageStatPropstype UsageTablePropstype UsageGridPropsAccessibility
- UsageTable is a real table; unknown values show a dash, estimates a tilde.
Agent actions
Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.