import React, { useState, useEffect } from 'react' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { Checkbox } from '@/components/ui/checkbox' import { Input } from '@/components/ui/input' import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table' import { mockData } from './lib/data' export interface Model { name: string inputPrice: number outputPrice: number } export interface Provider { provider: string uri: string models: Model[] } const App: React.FC = () => { const [data, setData] = useState([]) const [comparisonModels, setComparisonModels] = useState([]) const [inputTokens, setInputTokens] = useState(1) const [outputTokens, setOutputTokens] = useState(1) useEffect(() => { setData(mockData) // Set default comparison models setComparisonModels(['GPT-4o', 'Claude 3.5 (Sonnet)', 'Gemini 1.5 Pro']) }, []) const calculatePrice = (price: number, tokens: number): number => { return price * tokens } const calculateComparison = (modelPrice: number, comparisonPrice: number): string => { return (((modelPrice - comparisonPrice) / comparisonPrice) * 100).toFixed(2) } return ( LLM Pricing Comparison Tool

Select Comparison Models

setInputTokens(Number(e.target.value))} className="mt-1" />
setOutputTokens(Number(e.target.value))} className="mt-1" />
{data .flatMap((provider) => provider.models) .map((model) => (
{ if (checked) { setComparisonModels((prev) => [...prev, model.name]) } else { setComparisonModels((prev) => prev.filter((m) => m !== model.name)) } }} />
))}

Note: If you use Amazon Bedrock or Azure prices for Anthropic, Cohere or OpenAI should be the same.

Provider Model Input Price (per 1M tokens) Output Price (per 1M tokens) Total Price {comparisonModels.map((model) => ( Compared to {model} ))} {comparisonModels.flatMap((model) => [ Input, Output, ])} {data.flatMap((provider) => provider.models.map((model) => ( {provider.provider} {model.name} ${model.inputPrice.toFixed(2)} ${model.outputPrice.toFixed(2)} $ {( calculatePrice(model.inputPrice, inputTokens) + calculatePrice(model.outputPrice, outputTokens) ).toFixed(2)} {comparisonModels.flatMap((comparisonModel) => { const comparisonModelData = data.flatMap((p) => p.models).find((m) => m.name === comparisonModel)! return [ 0 ? 'bg-red-100' : '' }`} > {model.name === comparisonModel ? '0.00%' : `${calculateComparison(model.inputPrice, comparisonModelData.inputPrice)}%`} , 0 ? 'bg-red-100' : '' }`} > {model.name === comparisonModel ? '0.00%' : `${calculateComparison(model.outputPrice, comparisonModelData.outputPrice)}%`} , ] })} )) )}
) } export default App