#!/usr/bin/env python3 """Cost per million tokens: every number printed in "Cost per Million Tokens, Computed". Standard library only. Run: python3 token_cost.py Inputs, all read 2026-11-07 unless stated: - InferenceX, GLM-5.3 on B200 (AgentX agentic-coding workload, Dynamo + SGLang, FP4, runs 2026-10-22 to 2026-11-06): total tokens/s per GPU on the frontier at 100, 150, 200 tok/s per user. Price tiers from the SemiAnalysis AI Cloud TCO model: $1.73 (owning at large hyperscaler volume) and $3.70 (retail) per GPU-hour. https://inferencex.semianalysis.com/run/glm-5-3-on-b200 - Lambda on-demand B200: $7.69 per GPU-hour from 2026-11-16. https://lambda.ai/pricing - API list prices per million tokens (input, cached input, 5- or 30-minute cache write, output): Z.ai GLM-5.3 1.40 / 0.26 / none / 4.40 (https://docs.z.ai/guides/overview/pricing); Claude Sonnet 5.5 2 / 0.10 / 2.50 / 10; Claude Opus 5.5 4 / 0.20 / 5 / 20 (https://platform.claude.com/docs/en/about-claude/pricing); OpenAI GPT-6.1 Sol, short context, 2 / 0.10 / 2.50 / 10 (https://developers.openai.com/api/docs/pricing). - Our sweep (ttft-itl-goodput, 2026-10-17): Qwen3-8B BF16, vLLM 0.31.0, one GB10, 1,024 in / 256 out. - ASUS Ascent GX10 1 TB: $5,999 on ASUS eShop USA (out of stock). GB10 box: 240 W supply (NVIDIA DGX Spark user guide). Electricity: 18.2 cents/kWh, EIA STEO (6 Oct 2026) US residential 2026. - Revolut (AI Engineer NYC 2026 talk): 56 B200, $0.30 blended per million, over 7 req/s in August. """ HOURS_PER_MONTH = 730 def per_mtok(dollars_per_hour: float, tokens_per_s: float, utilization: float = 1.0) -> float: """$ per million tokens for a GPU (or box) at a throughput, busy a fraction of paid hours.""" return dollars_per_hour / (tokens_per_s * 3600 / 1e6) / utilization def implied_utilization(reported: float, dollars_per_hour: float, tokens_per_s: float) -> float: return per_mtok(dollars_per_hour, tokens_per_s) / reported def owned_hourly(price: float, months: float, watts: float, kwh: float) -> float: return price / (months * HOURS_PER_MONTH) + watts / 1000 * kwh def api_blended(p: dict, input_share: float, hit: float) -> float: """Price per million tokens of a mix: input_share of tokens are prompt, hit of those are cached. Uncached prompt tokens are billed as a cache write when caching is in use and the API charges one.""" uncached = p["write"] if (hit > 0 and p.get("write")) else p["input"] return input_share * (hit * p["cached"] + (1 - hit) * uncached) + (1 - input_share) * p["output"] INFERENCEX = {100: 16341, 150: 13021, 200: 9876} TIERS = {"own, hyperscaler volume": 1.73, "retail": 3.70, "Lambda on-demand": 7.69} APIS = { "Z.ai GLM-5.3": {"input": 1.40, "cached": 0.26, "write": None, "output": 4.40}, "Claude Sonnet 5.5": {"input": 2.00, "cached": 0.10, "write": 2.50, "output": 10.00}, "Claude Opus 5.5": {"input": 4.00, "cached": 0.20, "write": 5.00, "output": 20.00}, "GPT-6.1 Sol": {"input": 2.00, "cached": 0.10, "write": 2.50, "output": 10.00}, } AGENTX_IN, AGENTX_OUT = 142016, 444 # median request, AgentX v1.0 SWEEP = [ # offered req/s, completed req/s, output tok/s (0.5, 0.43, 110), (1, 0.81, 208), (1.5, 1.15, 296), (2, 1.33, 341), (2.5, 1.42, 365), (3, 1.40, 357), (4, 1.36, 347), ] def main() -> None: print("== B200, GLM-5.3, InferenceX frontier ($/Mtok total tokens at full load)") for user, tps in INFERENCEX.items(): row = ", ".join(f"{name} ${per_mtok(h, tps):.3f}" for name, h in TIERS.items()) print(f" {user} tok/s/user, {tps:,} tok/s/GPU: {row}") lam = TIERS["Lambda on-demand"] print(f" 100 -> 200 tok/s/user at Lambda's price: " f"{per_mtok(lam, INFERENCEX[200]) / per_mtok(lam, INFERENCEX[100]):.2f}x") print("== Utilization behind Revolut's $0.30 (200 tok/s/user)") for name, h in TIERS.items(): u = implied_utilization(0.30, h, INFERENCEX[200]) fleet = 56 * INFERENCEX[200] * u # tokens/s served on average print(f" {name} ${h}: {u:.0%}; fleet {fleet:,.0f} tok/s; " f"{fleet / 7:,.0f} tokens per request at 7 req/s around the clock; " f"{fleet * 3600 * HOURS_PER_MONTH / 1e9:,.0f} B tokens/month; " f"GPU bill ${56 * h * HOURS_PER_MONTH:,.0f}/month; " f"+$10k/month adds ${10000 / (fleet * 3600 * HOURS_PER_MONTH / 1e6):.4f}/Mtok") print(f" fleet capacity at 200 tok/s/user: {56 * INFERENCEX[200]:,} tok/s") agentx_share = AGENTX_IN / (AGENTX_IN + AGENTX_OUT) print(f"== API prices, blended ($/Mtok); AgentX median input share {agentx_share:.4f}") for share, label in ((0.95, "95% input"), (agentx_share, "AgentX median")): for hit in (0.0, 0.90, 0.95, 0.99): row = ", ".join(f"{n} ${api_blended(p, share, hit):.3f}" for n, p in APIS.items()) print(f" {label}, hit {hit:.0%}: {row}") for share in (0.95, agentx_share): for n, p in APIS.items(): r90, r99 = (api_blended(p, share, hit) / 0.30 for hit in (0.90, 0.99)) print(f" ratio to $0.30, share {share:.3f}: {n} {r90:.2f}x at hit 90%, {r99:.2f}x at hit 99%") for hit in (0.90, 0.99): z = api_blended(APIS["Z.ai GLM-5.3"], agentx_share, hit) print(f" $0.30 vs Z.ai GLM-5.3 at the AgentX mix, hit {hit:.0%}: {1 - 0.30 / z:+.1%} cheaper than the API") print("== Break-even utilization against the same model's API (200 tok/s/user, hit 90%)") for share in (0.95, agentx_share): api = api_blended(APIS["Z.ai GLM-5.3"], share, 0.90) row = ", ".join(f"{name} {per_mtok(h, INFERENCEX[200]) / api:.0%}" for name, h in TIERS.items()) print(f" share {share:.3f} (API ${api:.3f}): {row}") print("== GB10, Qwen3-8B, owned") h = owned_hourly(5999, 36, 240, 0.182) print(f" hourly ${h:.4f} (amortization ${5999 / (36 * HOURS_PER_MONTH):.4f}, power ${0.24 * 0.182:.4f})") for offered, done, out in SWEEP: total = done * 1280 print(f" {offered} req/s offered: {total:,.0f} total tok/s -> ${per_mtok(h, total):.3f}/Mtok total, " f"${per_mtok(h, out):.3f}/Mtok output") duty = 50 / 168 print(f" ratio goodput point / peak: {per_mtok(h, 110) / per_mtok(h, 365):.2f}x (output), " f"{per_mtok(h, 0.43 * 1280) / per_mtok(h, 1.42 * 1280):.2f}x (total)") print(f" business hours (10 h x 5 days = {duty:.1%}): chat SLO ${per_mtok(h, 0.43 * 1280, duty):.3f}/Mtok total, " f"${per_mtok(h, 110, duty):.3f}/Mtok output") month = 0.43 * 1280 * 3600 * HOURS_PER_MONTH print(f" monthly tokens at the chat SLO, full-time: {month / 1e9:.2f} B; $100/month adds ${100 / (month / 1e6):.3f}/Mtok") if __name__ == "__main__": main()