Billing SDK/Billing SDK
Subscription ManagementUsage Table

Usage Table

Per-model LLM usage with token counts, cache reads, and API cost.

Usage Summary
Per-model LLM usage with token counts, cache reads, and API cost.
Model usage summary with token counts and costs
MODELINPUT (W/ CACHE WRITE)INPUT (W/O CACHE WRITE)CACHE READOUTPUTTOTAL TOKENSAPI COSTCOST TO YOU
gpt-50518,1311,646,080103,2712,267,482$0.00$0.00
claude-3.5-sonnet176,17728,413434,6128,326647,528$0.00$1.00
gemini-2.0-flash-exp176,10028,432434,6128,326647,528$1.00$0.00
gemini-2.5-pro176,17728,413434,6127,000647,528$1.00$0.00
claude-4-sonnet68,415902864,45012,769946,536$0.71$0.71
claude-3.7-sonnet68,415902864,45012,769946,536$0.71$0.00
auto84,5510284,8769,458378,885$0.23$0.00
sonic0149,4844,354,85523,5694,527,908$0.00$2.00
Total749,835754,6779,318,547185,48811,009,931$3.65$3.71
src/components/usage-table-demo.tsx
import { UsageTable, type UsageItem } from '@/registry/billingsdk/usage-table';

export default function UsageTableDemo() {
  const usageHistory: UsageItem[] = [
    {
      model: 'gpt-5',
      inputWithCache: 0,
      inputWithoutCache: 518131,
      cacheRead: 1646080,
      output: 103271,
      totalTokens: 2267482,
    },
    {
      model: 'claude-3.5-sonnet',
      inputWithCache: 176177,
      inputWithoutCache: 28413,
      cacheRead: 434612,
      output: 8326,
      totalTokens: 647528,
      costToYou: 1.00
    },
    {
      model: 'gemini-2.0-flash-exp',
      inputWithCache: 176100,
      inputWithoutCache: 28432,
      cacheRead: 434612,
      output: 8326,
      totalTokens: 647528,
      apiCost: 1,
      costToYou: 0
    },
    {
      model: 'gemini-2.5-pro',
      inputWithCache: 176177,
      inputWithoutCache: 28413,
      cacheRead: 434612,
      output: 7000,
      totalTokens: 647528,
      apiCost: 1,
      costToYou: 0
    },
    {
      model: 'claude-4-sonnet',
      inputWithCache: 68415,
      inputWithoutCache: 902,
      cacheRead: 864450,
      output: 12769,
      totalTokens: 946536,
      apiCost: 0.71,
      costToYou: 0.71
    },
    {
      model: 'claude-3.7-sonnet',
      inputWithCache: 68415,
      inputWithoutCache: 902,
      cacheRead: 864450,
      output: 12769,
      totalTokens: 946536,
      apiCost: 0.71,
    },
    {
      model: 'auto',
      inputWithCache: 84551,
      inputWithoutCache: 0,
      cacheRead: 284876,
      output: 9458,
      totalTokens: 378885,
      apiCost: 0.23,
      costToYou: 0
    },
    {
      model: 'sonic',
      inputWithCache: 0,
      inputWithoutCache: 149484,
      cacheRead: 4354855,
      output: 23569,
      totalTokens: 4527908,
      costToYou: 2
    }
  ];


  return (
      <UsageTable 
        title="Usage Summary"
        usageHistory={usageHistory}
        showTotal={true}
        description="Per-model LLM usage with token counts, cache reads, and API cost."
      />
  );
}

Installation

npx shadcn@latest add @billingsdk/usage-table
pnpm dlx shadcn@latest add @billingsdk/usage-table
npx shadcn@latest add @billingsdk/usage-table
npx @billingsdk/cli add usage-table
pnpm dlx @billingsdk/cli add usage-table
npx @billingsdk/cli add usage-table

Usage

import { UsageTable, type UsageItem } from "@/components/billingsdk/usage-table";
const usageHistory: UsageItem[] = [
    {
      model: 'gpt-5',
      inputWithCache: 0,
      inputWithoutCache: 518131,
      cacheRead: 1646080,
      output: 103271,
      totalTokens: 2267482,
    },
    {
      model: 'claude-3.5-sonnet',
      inputWithCache: 176177,
      inputWithoutCache: 28413,
      cacheRead: 434612,
      output: 8326,
      totalTokens: 647528,
      costToYou: 1.00
    },
    {
      model: 'gemini-2.0-flash-exp',
      inputWithCache: 176100,
      inputWithoutCache: 28432,
      cacheRead: 434612,
      output: 8326,
      totalTokens: 647528,
      apiCost: 1,
      costToYou: 0
    },
    {
      model: 'gemini-2.5-pro',
      inputWithCache: 176177,
      inputWithoutCache: 28413,
      cacheRead: 434612,
      output: 7000,
      totalTokens: 647528,
      apiCost: 1,
      costToYou: 0
    },
    {
      model: 'claude-4-sonnet',
      inputWithCache: 68415,
      inputWithoutCache: 902,
      cacheRead: 864450,
      output: 12769,
      totalTokens: 946536,
      apiCost: 0.71,
      costToYou: 0.71
    },
    {
      model: 'claude-3.7-sonnet',
      inputWithCache: 68415,
      inputWithoutCache: 902,
      cacheRead: 864450,
      output: 12769,
      totalTokens: 946536,
      apiCost: 0.71,
    },
    {
      model: 'auto',
      inputWithCache: 84551,
      inputWithoutCache: 0,
      cacheRead: 284876,
      output: 9458,
      totalTokens: 378885,
      apiCost: 0.23,
      costToYou: 0
    },
    {
      model: 'sonic',
      inputWithCache: 0,
      inputWithoutCache: 149484,
      cacheRead: 4354855,
      output: 23569,
      totalTokens: 4527908,
      costToYou: 2
    }
];
  <UsageTable 
    title="Usage Summary"
    usageHistory={usageHistory}
    showTotal={true}
    description="Per-model LLM usage with token counts, cache reads, and API cost."
  />

Props

PropTypeRequiredDescription
usageHistoryUsageItem[]List of usage to display
classNamestringAdditional CSS classes for styling
titlestringOptional heading text
descriptionstringOptional description text
showTotalbooleanShow total row (default: true)

UsageItem

interface UsageItem {
  model: string
  inputWithCache: number
  inputWithoutCache: number
  cacheRead: number
  output: number
  totalTokens: number
  apiCost?: number
  costToYou?: number
}

Credits