Eidetic

AI Token Usage

AI
Settings
Block

Display component for showing token consumption, limits, cost estimates, and usage breakdown. Includes warning states and multiple display variants.

Preview

Full token usage card with breakdown

Token Usage

120.0K tokens remaining

40% used
80.0K of 200.0K tokens$0.1600 spent
Estimated: +5.0K tokens
Resets in 17h 59m
Est. total cost: $0.4000

Warning State

Shows warning when approaching limit (75%+)

Token Usage

40.0K tokens remaining

80% used
160.0K of 200.0K tokens$0.3200 spent
Resets in 5h 59m
Est. total cost: $0.4000

Critical State

Shows critical warning when near limit (90%+)

Token Usage

10.0K tokens remaining

95% used
190.0K of 200.0K tokens$0.3800 spent
Estimated: +15.0K tokens
Exceeds limit

This request would exceed your token limit by 5.0K tokens

Est. total cost: $0.4000

Compact Variant

Smaller card without breakdown

45.0K / 100.0K
45%

Inline Variant

Single line for toolbars or headers

25.0K left

Minimal Variant

Just the progress bar

60.0K / 100.0K60%

Without Cost Display

Hide cost estimates

Token Usage

100.0K tokens remaining

33% used
50.0K of 150.0K tokens
Monitor your token usage

Props

AITokenUsage component API reference

PropTypeDefaultDescription
tokensUsed*numberCurrent number of tokens consumed
tokenLimit*numberMaximum token allocation
costPer1knumber0.002Cost per 1000 tokens for estimates
currencystring'$'Currency symbol for cost display
breakdownTokenBreakdown[]Token usage breakdown by category
estimatedTokensnumberEstimated tokens for pending request
resetDateDateWhen token usage resets
onRequestMore() => voidCallback when user requests more tokens
onRefresh() => voidCallback to refresh usage data
warningThresholdnumber0.75Percentage (0-1) to show warning state
criticalThresholdnumber0.9Percentage (0-1) to show critical state
showCostbooleantrueShow cost estimates
showBreakdownbooleantrueShow expandable breakdown section
variant'card' | 'compact' | 'inline' | 'minimal''card'Display variant
tokenLabelstring'tokens'Label for the token unit

TokenBreakdown Type

PropTypeDefaultDescription
label*stringCategory label
tokens*numberToken count for this category
colorstringColor for the breakdown indicator

Usage

Import and implementation example

import { AITokenUsage } from '@/blocks/ai-tools/ai-token-usage'
export default function Example() {
const breakdown = [
{ label: 'Input tokens', tokens: 45000, color: '#6366f1' },
{ label: 'Output tokens', tokens: 30000, color: '#14b8a6' },
{ label: 'System prompt', tokens: 5000, color: '#f59e0b' },
]
return (
<AITokenUsage
tokensUsed={80000}
tokenLimit={200000}
breakdown={breakdown}
estimatedTokens={5000}
resetDate={new Date(Date.now() + 1000 * 60 * 60 * 18)}
onRequestMore={() => openUpgradeModal()}
onRefresh={() => refetchUsage()}
warningThreshold={0.75}
criticalThreshold={0.9}
/>
)
}

Built With

2 components

This block uses the following UI components from the design system:

Features

Built-in functionality

  • Four variants: Card, compact, inline, and minimal displays
  • Usage states: Normal, warning (75%), and critical (90%) thresholds
  • Cost estimates: Calculate and display cost based on token usage
  • Usage breakdown: Expandable breakdown by category
  • Estimated preview: Show estimated tokens for pending requests
  • Exceeds warning: Alert when estimated usage exceeds limit
  • Reset countdown: Show time until usage resets
  • Number formatting: Automatic K/M formatting for large numbers
  • Dark mode: Full dark mode support

Accessibility

Accessibility considerations

ARIA Attributes

Progress bar uses visual indicatorColor-coded states for usage levelsButtons are native elements

Keyboard Navigation

KeyAction
TabNavigate between interactive elements
Enter / SpaceExpand breakdown or trigger actions

Notes

  • Color is not the only indicator - text shows percentage
  • Consider adding role="progressbar" with aria-valuenow
  • Warning/critical states have text descriptions