Loading component…
Loading component…
How much each AI company's models were used – one stacked bar per company with a segment per model, switch between tokens, cost and requests, and see what it all went into
To reuse this local React demo, copy all files from the Code tab into the same folder, then import ModelUsage from ./model-usage.
import { ModelUsage, type UsageCompany } from "@/components/ui/model-usage";
const companies: UsageCompany[] = [
{
id: "anthropic",
name: "Anthropic",
logo: <ClaudeLogo />,
models: [
{ id: "sonnet", name: "Claude Sonnet 5.5", usage: { tokens: 2_180_000, cost: 6.54, requests: 838 } },
{ id: "opus", name: "Claude Opus 5.5", usage: { tokens: 1_240_000, cost: 18.6, requests: 477 } },
],
},
{
id: "openai",
name: "OpenAI",
logo: <OpenAILogo />,
models: [{ id: "gpt", name: "GPT-5.5", usage: { tokens: 1_520_000, cost: 15.2, requests: 585 } }],
},
];
export function Usage() {
return <ModelUsage companies={companies} previous={{ tokens: 4_100_000, cost: 31.4, requests: 1620 }} />;
}| Name | Type | Default | Description |
|---|---|---|---|
| companies | UsageCompany[] | One bar each, in its color, with its logo and name under it | |
| UsageCompany.models | UsageModel[] | A segment each – the most used at the bottom, darkest, the rest in lighter shades of the company's color | |
| UsageModel.usage | { tokens?, cost?, requests? } | What it used in the period, per measure – cost in dollars | |
| UsageModel.tasks | Record<kind, { tokens?, cost?, requests? }> | What its usage went into – adds the task list below the bars | |
| UsageCompany.color / logo | string / ReactNode | Its color (the palette in order by default) and its logo under the bar and in the card | |
| metrics / defaultMetric | UsageMetric[] / UsageMetric | The measures to switch between, and the one shown first – tokens, cost, requests; one alone hides the switch | |
| title | string | The period's name above the total – "This week" by default | |
| previous / since | { tokens?, cost?, requests? } / string | Last period's totals – adds "+38% since last week", green up, red down | |
| kinds | Record<string, { label, color, icon? }> | Names, colors and icons for task kinds of your own, or to change the built-in ones | |
| className | string | Extra class on the root – set the color variables on it |
The classic style has a rounder card and bars, round task tiles and a pill switch – the same behavior as the clean one
Fills its container's width; up to four or five companies read best
Below 420px the switch moves under the total, company names give way to their logos, the tasks stack in one column and the card spans the chart
Numbers stay short at any size: 2.24T tokens, $12.4M, 1.2M requests; a model's sliver of a bar reads "<1%"
No usage at all shows "No usage this week" across the empty chart
The card sits beside its bar – right of it on the left half, left of it on the right half – so it never covers the header
Broken data holds: a value that isn't a number or below 0 counts as 0, a company without models stands empty with 0, a company without a logo shows its name only, an unknown task kind gets a grey square and its own name
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"