LLM Cost Calculator
Compare token costs across cloud APIs and local GPU inference. See when it pays to own the hardware.
| Provider / Model | Input/$1M | Output/$1M | Monthly cost | Context | Note |
|---|---|---|---|---|---|
| OpenAI GPT-4o | $2.50 | $10.00 | — | 128K | Best general-purpose API |
| OpenAI GPT-4o mini | $0.15 | $0.60 | — | 128K | Cheapest OpenAI model |
| Anthropic Claude 3.5 Sonnet | $3.00 | $15.00 | — | 200K | Best coding / reasoning |
| Anthropic Claude 3 Haiku | $0.25 | $1.25 | — | 200K | Fast Anthropic option |
| Google Gemini 1.5 Flash | $0.07 | $0.30 | — | 1000K | Lowest API cost, huge context |
| Google Gemini 1.5 Pro | $1.25 | $5.00 | — | 2000K | Largest context window |
| Groq Llama 3 70B | $0.59 | $0.79 | — | 8K | Fastest API inference |
| Groq Mixtral 8x7B | $0.27 | $0.27 | — | 32K | Fast and cheap |
| Local RTX 4090 (Llama 3 8B) | $0.00 | $0.00 | — | 8K | Hardware + electricity only |
| Local RTX 4090 (Llama 3 70B) | $0.00 | $0.00 | — | 8K | Requires quantization |
When does local win?
At your selected volume, cloud APIs cost roughly —/month.
A local RTX 4090 setup breaks even in about — months if electricity is $0.12/kWh and the GPU is used 40% of the time.
Local inference avoids per-token pricing but requires upfront hardware, maintenance, and uptime. Use this calculator to find your crossover point.
🤖 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/llm-cost-calculator/ is the canonical contract: inputs, outputs, and formulas.
# Hermes Dispatch Tool — LLM Cost Calculator
# Source: https://hermesdispatch.dev/tools/llm-cost-calculator/
# Description: Compare cloud API token prices vs local GPU cost per 1M tokens.
# License: MIT (generated by hermesdispatch.dev)
#
# INSTALL:
# 1. Save this file as ~/.hermes/hermes-agent/tools/llm_cost_calculator.py
# 2. Restart Hermes or run /reset in a session
#
# MANUAL REGISTRY:
# from tools.llm_cost_calculator import register
# register()
import json
def _ok(result):
return json.dumps({"success": True, "data": result}, indent=2)
def _err(message):
return json.dumps({"success": False, "error": message}, indent=2)
TOOL_NAME = "llm_cost_calculator"
TOOLSET = "cost"
SCHEMA = {
"type": "function",
"function": {
"name": TOOL_NAME,
"description": "Compare monthly cloud LLM API cost vs local GPU inference cost.",
"parameters": {
"type": "object",
"properties": {
"input_tokens_per_call": {"type": "integer", "default": 1000, "description": "Average input tokens per API call."},
"output_tokens_per_call": {"type": "integer", "default": 500, "description": "Average output tokens per API call."},
"calls_per_month": {"type": "integer", "default": 10000, "description": "Number of calls per month."},
"provider": {"type": "string", "default": "openai", "description": "Cloud provider: openai, anthropic, google, groq, together."},
"local_gpu_cost": {"type": "number", "default": 2000, "description": "Upfront local GPU cost in USD."},
"gpu_lifespan_months": {"type": "integer", "default": 36, "description": "Expected GPU lifespan in months."},
},
"required": []
}
}
}
# Approximate per-1M-token pricing in USD (input, output)
PRICING = {
"openai": {"input": 0.150, "output": 0.600, "name": "OpenAI GPT-4o-mini"},
"anthropic": {"input": 0.800, "output": 2.400, "name": "Anthropic Claude 3 Haiku"},
"google": {"input": 0.350, "output": 1.400, "name": "Google Gemini 1.5 Flash"},
"groq": {"input": 0.050, "output": 0.080, "name": "Groq Llama 3 8B"},
"together": {"input": 0.200, "output": 0.200, "name": "Together AI Llama 3 8B"},
}
def calculate_cost(input_tokens_per_call=1000, output_tokens_per_call=500, calls_per_month=10000,
provider="openai", local_gpu_cost=2000, gpu_lifespan_months=36):
rates = PRICING.get(provider.lower(), PRICING["openai"])
monthly_input_tokens = input_tokens_per_call * calls_per_month
monthly_output_tokens = output_tokens_per_call * calls_per_month
cloud_cost = (monthly_input_tokens / 1_000_000) * rates["input"] + (monthly_output_tokens / 1_000_000) * rates["output"]
local_amortized = local_gpu_cost / gpu_lifespan_months
break_even_months = local_gpu_cost / cloud_cost if cloud_cost > 0 else float('inf')
cheaper = "local GPU" if local_amortized < cloud_cost else "cloud API"
return _ok({
"cloud_cost_per_month": round(cloud_cost, 2),
"local_gpu_cost_per_month": round(local_amortized, 2),
"break_even_months": round(break_even_months, 1) if break_even_months != float('inf') else None,
"cheaper_option": cheaper,
"provider": rates["name"],
})
def HANDLER(args):
try:
return calculate_cost(
input_tokens_per_call=int(args.get("input_tokens_per_call", 1000)),
output_tokens_per_call=int(args.get("output_tokens_per_call", 500)),
calls_per_month=int(args.get("calls_per_month", 10000)),
provider=args.get("provider", "openai"),
local_gpu_cost=float(args.get("local_gpu_cost", 2000)),
gpu_lifespan_months=int(args.get("gpu_lifespan_months", 36)),
)
except Exception as e:
return _err(str(e))
def register():
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__":
print(HANDLER({{}}))
Want early access to the next locked tool? Subscribe to The Hermes Dispatch.