A JavaScript Cost Calculator: $0.10/M APIs vs Self-Hosted Models

Inference got cheap on paper: $0.10 per million tokens for a Google model, a Meta model at Haiku-tier pricing, and a claim that open-weight tokens cost about 7x less. None of that settles build versus buy, because almost nobody quoting those numbers is quoting the same unit. This video walks the JavaScript cost calculator from the post. The API side splits input and output tokens, applies cache hit rate and an amplification factor, and returns dollars per million total tokens. The self-hosted side divides a fixed monthly bill by the tokens the GPUs actually emit. Set the two equal and you get a break-even utilization. Numbers from the post's worked example: one rented H100 at 2,500 aggregate tokens per second, a $7,491.67 monthly bill split 56% ops, 24% GPU, 20% platform. Against a frontier-priced API that breaks even at about 1.59 billion tokens per month, roughly 24% utilization. Against a $0.10/M-class API, break-even is about 52.5 billion tokens per month while the same fleet tops out at 6.57 billion — unreachable at any volume it can physically serve. You'd need more than 6,900 tokens per second per $2.50 GPU-hour on raw GPU cost alone, before a single engineer-hour. The post is also explicit about what the price-collapse reports do not establish: the input/output split behind those rates, whether caching or batch tiers are included, what throughput or latency the price buys, and the methodology behind the 7x figure. Full write-up, calculator, and sweep harness: https://hackyjs.com/posts/a-javascript-cost-calculator-for-choosing-between-010m-apis-and-self-hosted-models

javascriptaillmcost-optimizationself-hosting

Read the post →