The basic formula
Cost = (tokens ÷ 1,000,000) × price_per_million
For example: 50,000 input tokens on Claude Sonnet 4 ($3.00/M): (50,000 ÷ 1,000,000) × $3.00 = 0.05 × $3.00 = $0.15
Simple — but most API calls have both input and output tokens, each priced differently.
Full cost calculation with input and output
Full formula: Total cost = (input_tokens / 1,000,000 × input_price) + (output_tokens / 1,000,000 × output_price)
Example: 2,000 input tokens + 500 output tokens on GPT-4o ($2.50 input / $10.00 output): (2,000/1,000,000 × $2.50) + (500/1,000,000 × $10.00) = $0.005 + $0.005 = $0.01 per call
Current pricing for major models (2025)
GPT-4o Mini: $0.15 input / $0.60 output per million tokens GPT-4o: $2.50 input / $10.00 output per million tokens GPT-4.5 Turbo: $75.00 input / $150.00 output per million tokens
Gemini 1.5 Flash: $0.075 input / $0.30 output per million tokens Gemini 1.5 Pro: $1.25 input / $5.00 output per million tokens Gemini 2.0 Flash: $0.10 input / $0.40 output per million tokens
Scaling to production: monthly cost estimation
1. Measure average input tokens per call (your prompt + context) 2. Measure average output tokens per call (model response length) 3. Multiply by your expected daily call volume 4. Multiply by 30 for monthly totals
Example: An app with 1,500 input tokens + 300 output tokens per call, 10,000 calls/day on Claude Sonnet 4: Input: (1,500 × 10,000 × 30) / 1,000,000 × $3.00 = 450M tokens / 1M × $3 = $1,350/month Output: (300 × 10,000 × 30) / 1,000,000 × $15.00 = 90M tokens / 1M × $15 = $1,350/month Total: $2,700/month
Use the TokenRate calculator to run these numbers without the math.
Quick reference: tokens to dollars at a glance
1,000 tokens on Claude Sonnet 4 (output): $0.015 1,000 tokens on GPT-4o (output): $0.01 1,000 tokens on Gemini 1.5 Flash (output): $0.0003
For real-time conversion across all models, enter any token count into the TokenRate calculator.