Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

834 B
Raw Blame
"use client";

// src/app/(dashboard)/dashboard/playground/components/TokenCostCounter.tsx

interface TokenCostCounterProps {
  tokensIn: number;
  tokensOut: number;
  costUsd: number | null;
}

/**
 * Displays token counts and estimated cost.
 * D13: Cost is labeled "(estimated)" to reflect client-side calculation.
 */
export default function TokenCostCounter({ tokensIn, tokensOut, costUsd }: TokenCostCounterProps) {
  if (tokensIn === 0 && tokensOut === 0 && costUsd === null) {
    return null;
  }

  return (
    <span className="text-xs text-text-muted flex items-center gap-1 font-mono">
      {tokensIn > 0 && <span>{tokensIn}↑</span>}
      {tokensOut > 0 && <span>{tokensOut}↓</span>}
      {costUsd !== null && costUsd > 0 && (
        <span>· ${costUsd.toFixed(4)} (estimated)</span>
      )}
    </span>
  );
}