Prompt Tokenizer & Pricing Estimator
Paste your prompt, estimate token count, and see what it would cost across every major LLM API.
Token estimate
Approximation ±10–15% depending on tokenizer and language.
Workload
Cost per request and per month
| Provider / Model | Input / 1M | Cached / 1M | Output / 1M | Per request | Per month | Best for |
|---|---|---|---|---|---|---|
| OpenAI GPT-4o gpt-4o | $2.50 | $1.250 | $10.00 | — | — | General agent tasks, vision, tool use |
| OpenAI GPT-4o-mini gpt-4o-mini | $0.15 | $0.075 | $0.60 | — | — | Cheap high-volume agents |
| Anthropic Claude 3.5 Sonnet claude-3-5-sonnet-20240620 | $3.00 | $3.750 | $15.00 | — | — | Long context, reasoning, coding |
| Anthropic Claude 3 Haiku claude-3-haiku-20240307 | $0.25 | $0.030 | $1.25 | — | — | Fast, cheap agent calls |
| Google Gemini 1.5 Pro gemini-1.5-pro | $3.50 | — | $10.50 | — | — | Massive context, multimodal |
| Google Gemini 1.5 Flash gemini-1.5-flash | $0.35 | — | $1.05 | — | — | Low-latency, high-volume |
| Groq Llama 3.1 70B llama-3.1-70b-versatile | $0.59 | — | $0.79 | — | — | Fast open-weight inference |
| Together AI Llama 3.1 70B llama-3.1-70b | $0.90 | — | $0.90 | — | — | Open-weight fine-tuning hub |
| Cohere Command R+ command-r-plus | $2.50 | — | $10.00 | — | — | RAG and enterprise search |
Cheapest for this prompt
Paste a prompt to see the cheapest provider.
Frequently asked questions
How accurate is this tokenizer estimate?
It uses a fast approximation based on whitespace, punctuation, and average token ratios (~0.6 tokens per word for English, adjusted for code and special characters). It is accurate within ±10-15% for most LLM tokenizers. For exact counts, use the provider's own tokenizer API or tiktoken.
Which provider pricing is used?
Prices are pulled from the dedicated Prompt Tokenizer dataset and reviewed monthly. Last updated: 2026-07-12. Always confirm current rates on the provider's pricing page before committing to a budget.
Does this include cached input discounts?
Yes. Select a provider that supports cached input (OpenAI GPT-4o/4o-mini and Anthropic Claude 3.5 Sonnet/Haiku), then set the cached input percentage. The estimator applies the cached rate to that portion and the standard rate to the rest.
What about system prompts and repeated context?
Paste the full prompt including system instructions, examples, and user messages. The tokenizer counts everything. For multi-turn chat, duplicate turns to simulate context-window growth.
🤖 Use this tool in your agent
✓ Agent-ready codeCopy the snippet below into your agent, newsletter, or script. The tool page at hermesdispatch.dev/tools/prompt-tokenizer-pricing-estimator/ is the canonical contract: inputs, outputs, and formulas.
# Hermes Dispatch Tool — Prompt Tokenizer & Pricing Estimator
# Source: https://hermesdispatch.dev/tools/prompt-tokenizer-pricing-estimator/
# Description: Estimate tokens in a prompt and compare LLM API pricing across providers.
# License: MIT (generated by hermesdispatch.dev)
#
# INSTALL:
# 1. Save this file as ~/.hermes/hermes-agent/tools/prompt_tokenizer_pricing_estimator.py
# 2. Restart Hermes or run /reset in a session
# 3. The tool auto-registers if Hermes uses auto-discovery of tools/*.py
#
# MANUAL REGISTRY (if auto-discovery is off):
# from tools.prompt_tokenizer_pricing_estimator import register
# register()
import json
import math
DATA = {"last_updated": "2026-07-12", "note": "Prices are per 1M tokens in USD. Token counts are estimates (~4 chars/token or 1.3x words, whichever is higher). Confirm current rates on provider sites before committing to a budget.", "providers": [{"name": "OpenAI GPT-4o", "model": "gpt-4o", "input_per_1m": 2.5, "output_per_1m": 10.0, "cached_input_per_1m": 1.25, "request_fee": 0.0, "context_window": 128000, "best_for": "General agent tasks, vision, tool use"}, {"name": "OpenAI GPT-4o-mini", "model": "gpt-4o-mini", "input_per_1m": 0.15, "output_per_1m": 0.6, "cached_input_per_1m": 0.075, "request_fee": 0.0, "context_window": 128000, "best_for": "Cheap high-volume agents"}, {"name": "Anthropic Claude 3.5 Sonnet", "model": "claude-3-5-sonnet-20240620", "input_per_1m": 3.0, "output_per_1m": 15.0, "cached_input_per_1m": 3.75, "request_fee": 0.0, "context_window": 200000, "best_for": "Long context, reasoning, coding"}, {"name": "Anthropic Claude 3 Haiku", "model": "claude-3-haiku-20240307", "input_per_1m": 0.25, "output_per_1m": 1.25, "cached_input_per_1m": 0.03, "request_fee": 0.0, "context_window": 200000, "best_for": "Fast, cheap agent calls"}, {"name": "Google Gemini 1.5 Pro", "model": "gemini-1.5-pro", "input_per_1m": 3.5, "output_per_1m": 10.5, "cached_input_per_1m": 0.0, "request_fee": 0.0, "context_window": 2000000, "best_for": "Massive context, multimodal"}, {"name": "Google Gemini 1.5 Flash", "model": "gemini-1.5-flash", "input_per_1m": 0.35, "output_per_1m": 1.05, "cached_input_per_1m": 0.0, "request_fee": 0.0, "context_window": 1000000, "best_for": "Low-latency, high-volume"}, {"name": "Groq Llama 3.1 70B", "model": "llama-3.1-70b-versatile", "input_per_1m": 0.59, "output_per_1m": 0.79, "cached_input_per_1m": 0.0, "request_fee": 0.0, "context_window": 131072, "best_for": "Fast open-weight inference"}, {"name": "Together AI Llama 3.1 70B", "model": "llama-3.1-70b", "input_per_1m": 0.9, "output_per_1m": 0.9, "cached_input_per_1m": 0.0, "request_fee": 0.0, "context_window": 131072, "best_for": "Open-weight fine-tuning hub"}, {"name": "Cohere Command R+", "model": "command-r-plus", "input_per_1m": 2.5, "output_per_1m": 10.0, "cached_input_per_1m": 0.0, "request_fee": 0.0, "context_window": 128000, "best_for": "RAG and enterprise search"}]}
def _ok(result):
return json.dumps({"success": True, "data": result}, indent=2)
def _err(message):
return json.dumps({"success": False, "error": message}, indent=2)
def estimate_tokens(text):
if not text:
return 0
chars = len(text)
words = len(text.strip().split())
return math.ceil(max(chars / 4.0, words * 1.3))
def cost_for_provider(p, input_tokens, output_tokens, cache_hit=0.0, requests=1):
cached = cache_hit * (p.get("cached_input_per_1m") or p["input_per_1m"])
uncached = (1 - cache_hit) * p["input_per_1m"]
in_cost = (input_tokens / 1_000_000) * (cached + uncached)
out_cost = (output_tokens / 1_000_000) * p["output_per_1m"]
per_request = in_cost + out_cost + (p.get("request_fee") or 0)
return {
"provider": p["name"],
"model": p.get("model", ""),
"per_request": round(per_request, 6),
"monthly": round(per_request * requests, 2),
"best_for": p.get("best_for", "")
}
TOOL_NAME = "prompt_tokenizer_pricing_estimator"
TOOLSET = "agents"
SCHEMA = {
"type": "function",
"function": {
"name": "prompt_tokenizer_pricing_estimator",
"description": "Estimate tokens in a prompt and compare LLM API pricing across providers.",
"parameters": {
"type": "object",
"properties": {
"prompt": {
"type": "string",
"description": "The prompt text to tokenize and price."
},
"input_tokens": {
"type": "integer",
"description": "Optional override for input token count."
},
"output_tokens": {
"type": "integer",
"description": "Output tokens per request."
},
"requests_per_month": {
"type": "integer",
"description": "Number of requests per month."
},
"cache_hit_percent": {
"type": "number",
"description": "Percentage of input tokens that hit a context cache (0-100)."
}
},
"required": ["prompt"]
}
}
}
def _run(args):
prompt = args.get("prompt", "")
input_tokens_override = args.get("input_tokens")
input_tokens = int(input_tokens_override) if input_tokens_override is not None else estimate_tokens(prompt)
output_tokens = int(args.get("output_tokens", 500))
requests = int(args.get("requests_per_month", 100000))
cache_hit = max(0.0, min(100.0, float(args.get("cache_hit_percent", 0)))) / 100.0
results = [cost_for_provider(p, input_tokens, output_tokens, cache_hit, requests) for p in DATA["providers"]]
results.sort(key=lambda x: x["monthly"])
return _ok({
"estimated_input_tokens": input_tokens,
"output_tokens_per_request": output_tokens,
"total_tokens_per_request": input_tokens + output_tokens,
"requests_per_month": requests,
"cache_hit_percent": cache_hit * 100,
"cheapest_provider": results[0]["provider"] if results else None,
"provider_costs": results
})
def HANDLER(args):
try:
return _run(args)
except Exception as e:
return _err(str(e))
def register():
"""Manual registry hook. Import and call this to register with Hermes."""
try:
from tools.registry import registry
registry.register(
name=TOOL_NAME,
toolset=TOOLSET,
schema=SCHEMA,
handler=HANDLER,
)
except ImportError:
print("Hermes registry not found; skipping manual registration.")
if __name__ == "__main__":
# CLI smoke test
print(HANDLER({"prompt": "You are a helpful coding assistant. Explain the code the user pastes, then suggest three concrete improvements with brief rationale."}))
Want early access to the next locked tool? Subscribe to The Hermes Dispatch.