Understanding LLM Tokens and API Pricing
Published: October 7, 2026 ยท 8 min read ยท By JSON Suite Team
If you're using AI APIs like OpenAI's GPT-4, Anthropic's Claude, or Google's Gemini, you've seen pricing in "tokens." But what exactly is a token, and how do you estimate costs? This guide explains everything you need to know.
What is a Token?
A token is the basic unit that language models process. It's not a word, character, or sentence โ it's something in between. Tokens are pieces of text that the model's tokenizer splits input into.
Roughly speaking:
- 1 token โ 4 characters (in English)
- 1 token โ 0.75 words (common estimate)
- 100 tokens โ 75 words
How Tokenization Works
Most modern LLMs use subword tokenization (like BPE โ Byte Pair Encoding). Common words become single tokens, while rare words are split into pieces:
Why Tokens Matter
Tokens affect two things:
- Cost โ APIs charge per token (usually per 1,000 tokens)
- Context limits โ Models have maximum token limits (context window)
Input vs Output Tokens
Most APIs charge differently for:
- Input tokens โ Your prompt, system message, and any context you send
- Output tokens โ The model's generated response
Output tokens are typically 2-4x more expensive than input tokens because generation is more compute-intensive.
Model Pricing Comparison (2026)
| Model | Input (per 1M tokens) | Output (per 1M tokens) | Context Window |
|---|---|---|---|
| GPT-4 Turbo | $10 | $30 | 128K |
| GPT-4o | $2.50 | $10 | 128K |
| GPT-3.5 Turbo | $0.50 | $1.50 | 16K |
| Claude 3 Opus | $15 | $75 | 200K |
| Claude 3 Sonnet | $3 | $15 | 200K |
| Claude 3 Haiku | $0.25 | $1.25 | 200K |
| Gemini 1.5 Pro | $3.50 | $10.50 | 1M |
| Gemini 1.5 Flash | $0.075 | $0.30 | 1M |
Note: Prices change frequently. Always check official pricing pages.
Calculating Costs
Here's how to estimate API costs:
Context Window Explained
The context window is the total tokens the model can handle in one request (input + output combined). This affects what you can do:
- 4K tokens โ Short conversations, simple tasks
- 16K-32K tokens โ Document summarization, code review
- 128K tokens โ Analyze entire codebases, long documents
- 1M+ tokens โ Process books, massive datasets (Gemini 1.5)
Tips to Reduce Token Usage
1. Be Concise in Prompts
2. Limit Output Length
3. Use Cheaper Models for Simple Tasks
Not every task needs GPT-4. Use GPT-3.5 or Claude Haiku for:
- Simple classification
- Text extraction
- Basic formatting
- Translations
4. Compress Context
5. Remove Unnecessary Data
JSON and Tokens
JSON is commonly used in LLM APIs for structured input/output. However, JSON uses more tokens than plain text:
Different Tokenizers
Each model family uses different tokenizers, so the same text produces different token counts:
| Text | GPT-4 (cl100k) | Claude | Gemini |
|---|---|---|---|
| "Hello, world!" | 4 tokens | 4 tokens | 3 tokens |
| "JSON formatting" | 3 tokens | 3 tokens | 2 tokens |
| 1000-word essay | ~1200 tokens | ~1100 tokens | ~1000 tokens |
This is why counting tokens accurately requires using the right tokenizer for your model.
Batch Processing for Savings
Some providers offer batch/async APIs at lower costs:
- OpenAI Batch API โ 50% discount, 24-hour processing
- Anthropic Batches โ Similar discounts for async workloads
Great for non-urgent tasks like content generation, data processing, or analysis.
Count Your Tokens
Before sending expensive API calls, count your tokens! Use our free LLM Token Counter to:
- Count tokens for GPT-4, Claude, Gemini, and more
- Calculate estimated API costs
- Optimize prompts before sending
- Stay within context limits
It's especially useful when working with JSON APIs where structured data can quickly add up.