Skill in AI engineering
LLM workload cost from current prices
Estimates what a language-model workload costs a month from dated list prices, real-time and batch.
- Changed 4 Dec 2026
- Sources read 4 Dec 2026
- Version 1
- About 4,200 tokens
- Needed by both models tested, 4 Dec 2026
Say this to your agent
Use https://mysi.dev/llm-cost-planning/ to price 3,000 GPT-6.2 Astra calls a day, 12,000 tokens in and 800 out. Nothing to install, no key, no settings. An agent that can open web pages opens the page, follows the steps with the figures and code on it and gives you the answer.
When to use
- Someone wants a monthly cost for a workload: calls a day, input and output tokens per call, on a named model.
- Someone compares real-time with prompt caching against the batch endpoint, or one model against another.
- Not for rate limits, long-prompt surcharges, cache-write costs, fine-tuning or self-hosted models.
Steps
- Write down the model, calls (jobs) a day, input tokens and output tokens per call, the share of input read from the prompt cache, the retry rate, and how many hours the results may wait.
- Find the model in the figures below and take its input, output and cached-input prices per million tokens. If the model is not there, read the dataset at https://mysi.dev/llm-models/ ; if you cannot open it, ask the user for the prices. Never use a price from memory: they change often.
- If the model has no cached-input price, use its input price as the cached price. Some vendors charge more above a prompt size, given as
long_contextin the model's dataset entry; these functions do not price that, so say so when prompts may run past that size. - Real-time cost: call
token_cost_optimizer()with the three prices,input_tokens_per_call,output_tokens_per_call,cache_hit_rate(0.6 for 60%),retry_rate(0 if none is stated),calls_per_idea=1,ideas_per_day= calls a day andvalidation_rate=1. Pass every argument: the defaults are for a trading research loop (5 calls, 15% retries, 50% cache hits), not for a plain workload. ReadcostPerMonth(30 days). - Batch cost: call
batch_vs_realtime_cost()with the input and output prices,batch_discount_pct,batch_sla_hours,jobs_per_day,input_tokens_per_job,output_tokens_per_jobanddeadline_hours. The batch documentation of Anthropic, OpenAI and Google, as read for the batch-vs-realtime-cost calculator, states 50% off input and output and a 24-hour window: use those terms for those three, say they are as documented, and ask the user to confirm them. For any other vendor, ask the user for its batch terms. ReadeffectiveCostPerMonth: it is the batch price only whendeadline_hoursis at leastbatch_sla_hours, else the real-time price. - This function has no cache input. To compare batch against real-time with caching, compare
effectiveCostPerMonthfrom step 5 withcostPerMonthfrom step 4, and name the cheaper. - To compare models, repeat steps 2 to 6 for each model with the same workload.
- Report the monthly cost in US dollars, the mode it assumes, the prices used and the date of the figures.
Mistakes this prevents
- Using a remembered price for a model whose price has changed, or a price of an older model of the same family.
- Leaving the research-loop defaults in
token_cost_optimizer(): five calls per idea and 15% retries multiply the cost, and a 50% cache hit rate is assumed. - Counting a batch discount for a job whose results are needed sooner than the batch window.
- Forgetting that cached input is billed at the cached price, or applying the cache discount twice.
- Mixing up per-thousand and per-million token prices.
Tell the user
- The prices are list prices before tax on the date shown with the figures; long-prompt rates, cache writes and committed-use discounts are not in the result.
- A month here is 30 identical days; real traffic varies, so the result is an estimate.
- Batches often finish sooner than the window, but the vendors promise only the window.
Figures: Language model prices and limits
- Claude Fable 5.2 (claude-fable-5-2) from Anthropic costs $8 per million input tokens and $40 per million output tokens; cached input costs $0.2 per million. Context window 1,000,000 tokens. Largest output 128,000 tokens.
- GPT-6.2 Astra (gpt-6.2-astra) from OpenAI costs $8 per million input tokens and $40 per million output tokens; cached input costs $0.4 per million. Context window 1,050,000 tokens. Largest output 128,000 tokens.
- Gemini 4 Carbon (gemini-4-carbon) from Google costs $4 per million input tokens and $20 per million output tokens; cached input costs $0.2 per million. Context window 1,048,576 tokens. Largest output 65,536 tokens.
- DeepSeek V4 Pro (deepseek-v4-pro) from DeepSeek costs $1.32 per million input tokens and $3.96 per million output tokens; cached input costs $0.044 per million. Context window 1,000,000 tokens. Largest output 384,000 tokens.
- Grok 4.7 (grok-4.7) from xAI costs $2 per million input tokens and $6 per million output tokens; cached input costs $0.5 per million. Context window 500,000 tokens.
- Mistral Large 4 (mistral-large-4) from Mistral costs $0.7 per million input tokens and $2.1 per million output tokens. Context window 1,000,000 tokens.
- Muse Wonder 1.0 (muse-wonder-1.0) from Meta costs $4 per million input tokens and $20 per million output tokens; cached input costs $0.2 per million. Context window 1,048,576 tokens.
- Qwen3.8-Max (qwen3.8-max) from Qwen costs $2 per million input tokens and $6 per million output tokens; cached input costs $0.25 per million. Context window 1,000,000 tokens. Largest output 131,072 tokens.
Sources read 4 Dec 2026. Current figures: https://mysi.dev/llm-models/
The code
Copy each function into your Python tool. Run its check first.
LLM research loop token cost
"""LLM research loop token cost: what a loop of model calls costs per call, per idea, per
validated trade, per day, per 30-day month and per 365-day year.
Inputs: input_usd_per_mtok, output_usd_per_mtok, cached_input_usd_per_mtok (list prices in USD
per million tokens, 0 to 1000, no default); input_tokens_per_call (default 8000) and
output_tokens_per_call (default 1500), 0 to 10000000; calls_per_idea (0 to 1000000, default 5);
retry_rate (0 to 1, default 0.15); ideas_per_day (0 to 10000000, default 10); validation_rate
(0.0001 to 1, default 0.3); cache_hit_rate (0 to 1, default 0.5).
Returns effectiveCostPerCall, costPerIdea, costPerValidatedTrade, costPerDay, costPerMonth,
costPerYear, all in USD.
mysi, LLM research loop token cost, mysi.dev/token-cost-optimizer, version 1, changed 2026-12-04.
MIT.
"""
def _token_cost_optimizer_num(name, value, low, high):
if isinstance(value, bool) or not isinstance(value, (int, float)) or not low <= value <= high:
raise ValueError(f"{name} must be a number from {low} to {high}")
return float(value)
def token_cost_optimizer(input_usd_per_mtok, output_usd_per_mtok, cached_input_usd_per_mtok,
input_tokens_per_call=8000, output_tokens_per_call=1500,
calls_per_idea=5, retry_rate=0.15, ideas_per_day=10,
validation_rate=0.3, cache_hit_rate=0.5):
num = _token_cost_optimizer_num
p_in = num("input_usd_per_mtok", input_usd_per_mtok, 0, 1000)
p_out = num("output_usd_per_mtok", output_usd_per_mtok, 0, 1000)
p_cached = num("cached_input_usd_per_mtok", cached_input_usd_per_mtok, 0, 1000)
t_in = num("input_tokens_per_call", input_tokens_per_call, 0, 10000000)
t_out = num("output_tokens_per_call", output_tokens_per_call, 0, 10000000)
calls = num("calls_per_idea", calls_per_idea, 0, 1000000)
retry = num("retry_rate", retry_rate, 0, 1)
ideas = num("ideas_per_day", ideas_per_day, 0, 10000000)
valid = num("validation_rate", validation_rate, 0.0001, 1)
hit = num("cache_hit_rate", cache_hit_rate, 0, 1)
cached = t_in * hit
# prices per million tokens; cache-read price from the vendor's pricing page (an input)
per_call = ((t_in - cached) * p_in + cached * p_cached + t_out * p_out) / 1000000
per_idea = per_call * calls * (1 + retry)
per_day = per_idea * ideas
return {
"effectiveCostPerCall": per_call,
"costPerIdea": per_idea,
"costPerValidatedTrade": per_idea / valid,
"costPerDay": per_day,
"costPerMonth": per_day * 30, # by definition: 30-day month, 365-day year
"costPerYear": per_day * 365,
}
TOKEN_COST_OPTIMIZER_CASES = [
({"input_usd_per_mtok": 2, "output_usd_per_mtok": 10, "cached_input_usd_per_mtok": 0.1},
{"effectiveCostPerCall": 0.0234, "costPerValidatedTrade": 0.4485, "costPerMonth": 40.365}),
({"input_usd_per_mtok": 5, "output_usd_per_mtok": 25, "cached_input_usd_per_mtok": 0.5,
"input_tokens_per_call": 12000, "output_tokens_per_call": 2000, "calls_per_idea": 6,
"retry_rate": 0.1, "ideas_per_day": 20, "validation_rate": 0.25, "cache_hit_rate": 0.7},
{"effectiveCostPerCall": 0.0722, "costPerValidatedTrade": 1.90608, "costPerMonth": 285.912}),
({"input_usd_per_mtok": 0.75, "output_usd_per_mtok": 4.5, "cached_input_usd_per_mtok": 0.075,
"input_tokens_per_call": 5000, "output_tokens_per_call": 800, "calls_per_idea": 4,
"retry_rate": 0.2, "ideas_per_day": 50, "validation_rate": 0.1, "cache_hit_rate": 0},
{"effectiveCostPerCall": 0.00735, "costPerValidatedTrade": 0.3528, "costPerMonth": 52.92}),
]
def token_cost_optimizer_check(tolerance=1e-3):
for given, want in TOKEN_COST_OPTIMIZER_CASES:
got = token_cost_optimizer(**given)
for name, value in want.items():
close = abs(got[name] - value) <= tolerance * max(1, abs(value))
assert close, (name, got[name], value)
return "ok"
if __name__ == "__main__":
import json, sys
token_cost_optimizer_check()
given = dict(a.split("=", 1) for a in sys.argv[1:] if "=" in a)
js = lambda v: v.lstrip("-")[:1].isdigit() or v[:1] in '[{".' or v in ("true", "false", "null")
given = {k: json.loads(v) if js(v) else v for k, v in given.items()}
if given:
print(json.dumps(token_cost_optimizer(**given))) Batch against real-time LLM cost
"""Batch against real-time LLM API cost: the daily and 30-day cost of a workload on the real-time
API and on the vendor's batch endpoint, and which one the deadline allows.
Inputs: input_usd_per_mtok, output_usd_per_mtok (list prices, 0 to 1000, no default);
batch_discount_pct (0 to 100, no default) and batch_sla_hours (1 to 720, no default), from the
vendor's batch documentation; jobs_per_day (0 to 100000000, default 500); input_tokens_per_job
(default 15000) and output_tokens_per_job (default 1500), 0 to 10000000; deadline_hours
(0.01 to 8760, default 24).
Returns realtimeCostPerDay, batchCostPerDay, effectiveCostPerDay, savingsPerDay and the same per
30-day month (USD), batchEligible and usingBatch.
mysi, Batch against real-time LLM cost, mysi.dev/batch-vs-realtime-cost, version 1,
changed 2026-12-04. MIT.
"""
def _batch_vs_realtime_cost_num(name, value, low, high):
if isinstance(value, bool) or not isinstance(value, (int, float)) or not low <= value <= high:
raise ValueError(f"{name} must be a number from {low} to {high}")
return float(value)
def batch_vs_realtime_cost(input_usd_per_mtok, output_usd_per_mtok, batch_discount_pct,
batch_sla_hours, jobs_per_day=500, input_tokens_per_job=15000,
output_tokens_per_job=1500, deadline_hours=24):
num = _batch_vs_realtime_cost_num
p_in = num("input_usd_per_mtok", input_usd_per_mtok, 0, 1000)
p_out = num("output_usd_per_mtok", output_usd_per_mtok, 0, 1000)
discount = num("batch_discount_pct", batch_discount_pct, 0, 100)
sla = num("batch_sla_hours", batch_sla_hours, 1, 720)
jobs = num("jobs_per_day", jobs_per_day, 0, 100000000)
t_in = num("input_tokens_per_job", input_tokens_per_job, 0, 10000000)
t_out = num("output_tokens_per_job", output_tokens_per_job, 0, 10000000)
deadline = num("deadline_hours", deadline_hours, 0.01, 8760)
# prices are per million tokens; batch terms: Anthropic, OpenAI and Google batch docs (inputs)
per_job = (t_in * p_in + t_out * p_out) / 1000000
realtime = per_job * jobs
batch = realtime * (1 - discount / 100)
eligible = deadline >= sla
effective = batch if eligible else realtime
return {
"realtimeCostPerDay": realtime,
"batchCostPerDay": batch,
"effectiveCostPerDay": effective,
"savingsPerDay": realtime - effective,
"realtimeCostPerMonth": realtime * 30, # a month is defined as 30 identical days
"batchCostPerMonth": batch * 30,
"effectiveCostPerMonth": effective * 30,
"savingsPerMonth": (realtime - effective) * 30,
"batchEligible": eligible,
"usingBatch": eligible,
}
BATCH_VS_REALTIME_COST_CASES = [
({"input_usd_per_mtok": 2, "output_usd_per_mtok": 10, "batch_discount_pct": 50,
"batch_sla_hours": 24},
{"realtimeCostPerDay": 22.5, "effectiveCostPerMonth": 337.5, "savingsPerMonth": 337.5}),
({"input_usd_per_mtok": 5, "output_usd_per_mtok": 25, "batch_discount_pct": 50,
"batch_sla_hours": 24, "jobs_per_day": 120, "input_tokens_per_job": 40000,
"output_tokens_per_job": 3000, "deadline_hours": 6},
{"realtimeCostPerMonth": 990.0, "effectiveCostPerMonth": 990.0, "savingsPerMonth": 0.0}),
({"input_usd_per_mtok": 0.75, "output_usd_per_mtok": 4.5, "batch_discount_pct": 50,
"batch_sla_hours": 24, "jobs_per_day": 2000, "input_tokens_per_job": 8000,
"output_tokens_per_job": 800, "deadline_hours": 48},
{"realtimeCostPerMonth": 576.0, "effectiveCostPerMonth": 288.0, "savingsPerMonth": 288.0}),
]
def batch_vs_realtime_cost_check(tolerance=1e-3):
for given, want in BATCH_VS_REALTIME_COST_CASES:
got = batch_vs_realtime_cost(**given)
for name, value in want.items():
close = abs(got[name] - value) <= tolerance * max(1, abs(value))
assert close, (name, got[name], value)
return "ok"
if __name__ == "__main__":
import json, sys
batch_vs_realtime_cost_check()
given = dict(a.split("=", 1) for a in sys.argv[1:] if "=" in a)
js = lambda v: v.lstrip("-")[:1].isdigit() or v[:1] in '[{".' or v in ("true", "false", "null")
given = {k: json.loads(v) if js(v) else v for k, v in given.items()}
if given:
print(json.dumps(batch_vs_realtime_cost(**given))) What it reads
- https://mysi.dev/llm-models/Dataset
Keep it: save https://mysi.dev/llm-cost-planning.md as SKILL.md in a folder named llm-cost-planning, and it is a skill in agents that have skill folders.
Tested
Tested 4 Dec 2026: claude-haiku-5-5 was right on 0 of 3 questions without this page and 3 of 3 with it; claude-fable-5-2 was right on 0 of 3 questions without this page and 3 of 3 with it.
Changes
- Opened on mysi.4 Dec 2026
Cite as: mysi, LLM workload cost from current prices, mysi.dev/llm-cost-planning, version 1, changed 2026-12-04. Code MIT.