LLM Token Calculator
Estimate token count and API cost from text length across different tokenizers (GPT-4, Claude, Llama).
Inputs
Results
Input tokens per request
1,250
Total API cost ($)
$0.02
Output tokens per request1,250
Total tokens per request2,500
Total tokens (all requests)2,500
Input cost ($)$0.00
Output cost ($)$0.01
128K context usage (%)1.95%
Tokenizer NameGPT-4 (cl100k_base)
How to Use This Calculator
- Enter the Text Length in characters — paste your typical prompt and count characters, or use a rough estimate.
- Select the Tokenizer matching your model (GPT-4 uses ~4 chars/token, Claude ~3.5 chars/token).
- Set the Input Price per 1M Tokens from the provider's pricing page and the Output-to-Input Ratio (e.g., 0.3 for summarization, 2 for generation).
- Enter the Number of Requests to estimate total batch cost.
- Review Input Tokens, Output Tokens, Total Cost, and Context Usage % to optimize your prompt length and budget.
How the result changes with Text length (characters)
| Text length (characters) | Input tokens per request | Total API cost ($) |
|---|---|---|
| 1,000,000 | 250,000 | $3.00 |
| 3,500,000 | 875,000 | $10.50 |
| 6,500,000 | 1,625,000 | $19.50 |
| 9,000,000 | 2,250,000 | $27.00 |
What each input means
- Text length (characters)
- Number of characters in your input text. Average English word is ~5 characters.
- Tokenizer
- Select the tokenizer
- Input price per 1M tokens ($)
- Cost per 1 million input tokens. GPT-4o: $2.50, Claude Sonnet: $3, GPT-4 Turbo: $10.
- Output-to-input ratio
- Expected output tokens as a multiple of input tokens. Summarization ~0.3, Q&A ~1, generation ~2+.
- Number of requests
- Total API requests to estimate cost for.
What each result means
- Input tokens per request
- Estimated input token count per request.
- Output tokens per request
- Estimated output token count based on the output ratio.
- Total tokens per request
- Input + output tokens consumed per request.
- Total tokens (all requests)
- Grand total token consumption across all requests.
- Input cost ($)
- Cost for input tokens across all requests.
- Output cost ($)
- Cost for output tokens (typically 3x input price).
- Total API cost ($)
- Combined input + output token cost.
- 128K context usage (%)
- Percentage of a 128K context window used per request.
How this is calculated
Worked example, using the default values
- Identify Input Parameters4 parametersText length (characters) = 5000, Tokenizer = 0, Input price per 1M tokens ($) = 3, Output-to-input ratio = 1 = 5 input(s) provided
- Calculate Input tokens per request1250 = 1250
- Calculate Total API costTotal API cost = inputCost + outputCost0.015 = $0.015
- Calculate Output tokens per requestOutput tokens per request = ceil(inputTokens * outputRatio)1250 = 1250
- Calculate Total tokens per requestTotal tokens per request = inputTokens + outputTokens2500 = 2500
Engine last updated .
Related Calculators
The questions that sit next to this one — chosen by subject, including calculators filed under a different category.
Ai Tools
AI Agent Cost Calculator
Estimate per-task cost for AI agents from multi-step reasoning, tool calls, and context accumulation.
Ai ToolsPrompt Engineering Cost Calculator
Calculate the true cost of iterative prompt development including API tokens and engineer labor time.
MLOps & AI CostingLLM Token Cost Calculator
Calculate API costs for large language models based on input/output tokens and request volume.
Ai ToolsAI Model Cost Comparison Calculator
Compare per-token and per-request costs across AI providers including GPT-4o, Claude, Gemini, and self-hosted Llama.
More in Technology & Computing.