Calculator in Markets and quant
Batch against real-time LLM cost
Prices an LLM workload per day and per 30 days on the real-time API and on the batch endpoint, by deadline.
- Changed 4 Dec 2026
- Sources read 4 Dec 2026
- 8 test cases pass
- Version 1
- About 3,500 tokens
- Needed by both models tested, 4 Dec 2026
In short
| Formula | per job = (input_tokens_per_job × input_usd_per_mtok + output_tokens_per_job × output_usd_per_mtok) ÷ 1000000realtimeCostPerDay = per job × jobs_per_daybatchCostPerDay = realtimeCostPerDay × (1 − batch_discount_pct ÷ 100)batchEligible = deadline_hours ≥ batch_sla_hourseffectiveCostPerDay = batchCostPerDay if batchEligible, else realtimeCostPerDaysavingsPerDay = realtimeCostPerDay − effectiveCostPerDayEach PerMonth output = the PerDay output × 30 |
| Units | Prices in US dollars per million tokens, batch_discount_pct in percent, hours, results in US dollars. |
| Defaults | jobs_per_day = 500, input_tokens_per_job = 15000, output_tokens_per_job = 1500, deadline_hours = 24. Prices, discount and batch window have no default: take them from the vendor (Anthropic, OpenAI and Google document 50% off and 24 hours). |
| Worked example | 500 jobs a day of 15000 input and 1500 output tokens at $2 and $10 per million, 50% batch discount, 24-hour window, 24-hour deadline. per job = (15000 × 2 + 1500 × 10) ÷ 1000000 = 0.045realtimeCostPerDay = 0.045 × 500 = 22.5realtimeCostPerMonth = 22.5 × 30 = 675batchCostPerDay = 22.5 × (1 − 50 ÷ 100) = 11.2524 ≥ 24, so batchEligible is true, effectiveCostPerMonth = 11.25 × 30 = 337.5 and savingsPerMonth = (22.5 − 11.25) × 30 = 337.5 |
By hand: yes. A small model got these answers from the formulas above, without running code.
Say this to your agent
Use https://mysi.dev/batch-vs-realtime-cost/ to compare batch and real-time cost: 500 jobs a day, 15000 in, 1500 out, $2 and $10. Nothing to install, no key, no settings. An agent that can open web pages and run Python opens the page, runs the tested code in its own sandbox and gives you the answer.
The code
Copy this into your Python tool. Run batch_vs_realtime_cost_check() first, then call batch_vs_realtime_cost() with your numbers. Give the answer with the cite line.
"""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))) List prices before tax. Check the vendor's current pricing before budgeting.
Figures it needs, from llm-models
- 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. Give these to the function as inputs. The dataset holds the current figures.
What it takes
| Input | Meaning | Default | Allowed |
|---|---|---|---|
| input_usd_per_mtok | The model's real-time list price for input, in US dollars per million tokens, from the llm-models dataset or the vendor's pricing page. No default | required | 0 to 1000 |
| output_usd_per_mtok | The model's real-time list price for output, in US dollars per million tokens. No default | required | 0 to 1000 |
| batch_discount_pct | The vendor's batch discount on input and output, in percent, from its batch documentation. No default | required | 0 to 100 |
| batch_sla_hours | The hours within which the vendor promises to finish a batch. No default | required | 1 to 720 |
| jobs_per_day | Requests sent per day | 500 | 0 to 100,000,000 |
| input_tokens_per_job | Input tokens per request | 15000 | 0 to 10,000,000 |
| output_tokens_per_job | Output tokens per request | 1500 | 0 to 10,000,000 |
| deadline_hours | How long results may take, in hours; batch is used only when this is at least batch_sla_hours | 24 | 0.01 to 8760 |
What it returns
| Output | Meaning |
|---|---|
| realtimeCostPerDay, batchCostPerDay | The day's cost on the real-time API and on the batch endpoint, in US dollars |
| effectiveCostPerDay | The day's cost in the mode the deadline allows, in US dollars |
| savingsPerDay | Real-time cost minus effective cost per day; 0 when the deadline rules batch out |
| realtimeCostPerMonth, batchCostPerMonth, effectiveCostPerMonth, savingsPerMonth | The same over 30 days, in US dollars |
| batchEligible, usingBatch | True when deadline_hours is at least batch_sla_hours, so the batch endpoint is used |
Where the method comes from
Anthropic, OpenAI and Google each sell a batch endpoint: requests are queued and answered within a stated window, typically 24 hours, at a discount on input and output tokens, typically half the real-time price. The function prices one workload both ways at flat per-token rates and uses the batch price only when the results may wait at least as long as the vendor's batch window. It is good for a first budget and for seeing whether a pipeline's deadline leaves room for batching. It does not apply long-prompt rates, prompt caching, rate limits, taxes or a price change during the month; a month is thirty identical days. Batches often finish sooner than the window, but the vendors promise only the window, so a deadline shorter than it is treated as needing the real-time API.
Sources
- Anthropic, Message Batches (50% off input and output, processed within 24 hours)published 2026
- OpenAI, Batch API guide (50% discount, 24-hour completion window)published 2026
- Google, Gemini API Batch Mode (50% of the interactive price, 24-hour target turnaround)published 2026
Used by
- llm-cost-planningSkill
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
- Moved from aifinhub.io as Python. The model id is gone; the input and output prices, the batch discount and the batch completion window are inputs with no default (they were a built-in price list and 50% and 24 hours). Long-prompt rates and price changes announced for a future date are not applied, and a month is 30 times one day. The model record, the mode sentence, the pricing note and the cheapest-model-per-provider table are no longer returned. Answers unchanged at the same prices, except where the old price list carried a dated price change inside the 30 days.4 Dec 2026
Cite as: mysi, Batch against real-time LLM cost, mysi.dev/batch-vs-realtime-cost, version 1, changed 2026-12-04. Code MIT.