Skip to content
sinc-LLMBook a 30-minute call

Engineering instrument

OpenAI Token Calculator

Free OpenAI API pricing calculator for GPT-5, GPT-4o, and GPT-4o-mini, with token and cost estimates.

The services, methods, and examples described here do not establish an expected performance result for your workload.

TokenCalc - AI Token Cost Calculator

Estimate token usage and API costs for GPT-5, GPT-4o, GPT-4o-mini, and o3 models.

Your Prompts Never Leave Your Browser Official Tokenizers Free Forever
Use Token Calculator

The displayed OpenAI model rates are per one million tokens. Use the calculator to explore cost estimates for a text input.

Model Input Price Output Price Context Window
Source-snapshot estimate; verify current provider rates and limits: GPT-5Source-listed $15.00 / 1M $45.00 / 1M 256K tokens
Source-snapshot estimate; verify current provider rates and limits: GPT-5.2 $18.00 / 1M $54.00 / 1M 256K tokens
GPT-4oRecommended $2.50 / 1M $10.00 / 1M 128K tokens
GPT-4o-miniBest Value $0.15 / 1M $0.60 / 1M 128K tokens
Source-snapshot estimate; verify current provider rates and limits: o3 $10.00 / 1M $40.00 / 1M 200K tokens
o3-mini $1.10 / 1M $4.40 / 1M 200K tokens

Pro Tip: Prompt Caching

OpenAI supports automatic caching for eligible repeated prompt prefixes. The cached-input discount depends on the model; GPT-4o has a 50% discount. Repeating a system prompt alone does not guarantee a cache hit: check prefix length, matching, routing and retention requirements. Total costs also include uncached input and output.

How to Count OpenAI Tokens

OpenAI uses the tiktoken library for tokenization. Here are the encoding types for each model:

Encoding by Model

  • GPT-5, GPT-4o, GPT-4o-mini: cl100k_base encoding
  • o3, o3-mini: cl100k_base encoding
  • GPT-3.5-turbo: cl100k_base encoding

Python Code Example

import tiktoken

# Example for GPT-4o; choose the exact model tokenizer for other models
enc = tiktoken.encoding_for_model("gpt-4o")
tokens = enc.encode("Your text here")
print(f"Token count: {len(tokens)}")

# Calculate cost
input_tokens = len(tokens)
cost = (input_tokens / 1_000_000) * 2.50  # Source-listed GPT-4o input estimate; verify current provider rate
print(f"Input cost: ${cost:.6f}")

Token Estimation Rules

  • 1 token = approximately 4 characters in English
  • 1 token = approximately 0.75 words
  • 100 words = approximately 133 tokens
  • Code typically uses more tokens than natural language

1. Choose the Right Model

Don't use GPT-5 for everything. Match model capability to task complexity:

  • Simple tasks (classification, extraction): GPT-4o-mini ($0.15/1M)
  • Standard tasks (chat, generation): GPT-4o ($2.50/1M)
  • Complex reasoning: GPT-5 or o3 only when needed

2. Optimize Your Prompts

  • Remove unnecessary whitespace and formatting
  • Use concise system prompts, they're sent with every request
  • Avoid repeating instructions in every message

3. Use Prompt Caching

OpenAI supports automatic caching for eligible repeated prompt prefixes. The cached-input discount depends on the model; GPT-4o has a 50% discount. Repeating a system prompt alone does not guarantee a cache hit: check prefix length, matching, routing and retention requirements. Total costs also include uncached input and output.

4. Batch Requests

Use the Batch API for non-time-sensitive workloads to get 50% discount on all tokens.

Frequently Asked Questions

How much does ChatGPT API cost per 1000 tokens?

The source snapshot lists GPT-4o at $2.50 per 1M input tokens ($0.0025 per 1K) and $10 per 1M output, GPT-4o-mini at $0.15 per 1M input ($0.00015 per 1K), and GPT-5 at $15 per 1M input. These retained estimates are not verified current rates. Compare current provider prices and measured task quality.

How many tokens can GPT-5 process?

The source snapshot lists a GPT-5 context estimate of 256,000 tokens, approximately 192,000 words or 400+ pages, and a GPT-4 estimate of 128K. These retained values are not verified current model limits; word and page conversions vary with the text. Check the exact model’s current input and output limits.

What's the difference between input and output tokens?

Input tokens are the tokens sent in a prompt; output tokens are the tokens generated in the response. Providers set separate rates by model and usage category. Check the selected model’s rates instead of assuming a universal 3–4x output-price multiplier.

How do I count tokens in Python?

Use the official tiktoken library: import tiktoken; enc = tiktoken.encoding_for_model('gpt-4o'); tokens = enc.encode('your text'); print(len(tokens)) . TokenCalc uses tiktoken for its counting calculations; select the encoding for the model.