Skip to content
MAMasterAI Now
AI 工具

Self-Host vs API Cost Calculator

One side is a variable bill that scales with every token; the other is a fixed bill you pay whether or not anyone calls it. Enter your own rental price and your own measured throughput to find the volume where the two cross.

完全在浏览器中运行 —— 你输入的内容不会离开本页。

⚠ 此工具尚未完整翻译为中文,因此显示英文版本。翻译正在进行中。

你的负载

API 一侧

每百万 token US$2.50 输入 / US$10.00 输出

价格核对于 2025年2月1日

每月百万 token 数,例如 10 表示一千万。

每月百万 token 数,例如 10 表示一千万。

预设

设置每月的输出量。

自建一侧

只列出显存容量已核实的显卡。

显卡数量

填写服务商给你的价格——这里没有默认值。

请在自己的部署上实测。批量推理的吞吐远高于单流速度,并取决于推理引擎,例如 vLLM。

工程、存储、出网流量——GPU 账单之外的一切。

API

US$45.00

每月

每百万输出 token
US$22.50
模型
GPT-4o

自建

—

每月

每百万输出 token
—
所需显卡
—

填写租金与吞吐量后才能计算自建一侧。

填写租金和实测吞吐量,才能看出哪一边更便宜。

平衡点用量
—
两份账单相等时的每月输出 token 数。
容量
—
该部署每月可提供的输出 token 数。
已用容量
—
请求用量占容量的比例。
成本与用量API自建
0每月输出 token: 8M

最高月成本: US$180.00

这里没有计算的因素

  • 工程与运维时间——自建最大的隐性成本。
  • API 模型与你自建的开源模型之间的质量差异。
  • API 的速率限制、配额与可用性。
  • 空转时间以及为峰值预留的容量。
  • 无服务器 GPU 的冷启动,以及加载权重所需的时间。
  • 把数据留在自己网络中的价值,有时这才是真正的目的。吞吐量必须在你自己的环境中实测。

Fixed versus variable: the whole decision in one sentence

An API bill is variable: zero requests cost zero dollars, and the bill grows in a straight line with tokens. A self-hosted deployment is fixed: the GPU is rented by the hour whether it answers one request or a million, so cost per token falls as utilization rises. There is no universally cheaper option — only a cheaper option at a given volume.

API = in ÷ 1e6 × price_in + out ÷ 1e6 × price_out
The variable side. Two prices, two volumes, nothing else — which is why API costs are easy to forecast and easy to underestimate once prompts grow.
self-host = GPUs × $/hour × hours + extra
The fixed side. Note what is missing: any term for traffic — below capacity, doubling the volume does not change it.

That asymmetry is the entire analysis. Below the crossover an API is cheaper because you pay only for what you use; above it, hardware wins because the marginal cost of one more token is nearly zero.

Utilization is the number that decides it

Two people can rent the same H100 at the same hourly price and get wildly different costs per token. The difference is utilization — the share of rented hours actually doing inference. A card busy 20% of the month costs five times more per token than one kept busy, because the bill is identical and only the denominator moved.

capacity = throughput × hours × 3600 × utilization
Monthly output tokens the deployment can produce. At 500 tokens/s, 730 hours and 50% utilization: 500 × 2,628,000 × 0.5 = 657 million tokens.

This is why self-hosting rarely wins for traffic with a daily peak. Renting for the peak means paying for an idle machine most of the night. Batch work — overnight re-indexing, dataset labelling, synthetic data — is the opposite: it runs flat out, so its utilization approaches 100%.

Watch outA quiet deployment is an expensive one

Before comparing, be honest about utilization. If the box exists for one internal tool that a dozen people use, it will sit idle for most of the month, and the cost per million tokens will look nothing like the number in the blog post that recommended self-hosting.

Throughput is the hardest number on the page

Throughput is the one input this calculator refuses to guess, because it varies by an order of magnitude between a stock single-stream setup and a properly batched engine. A 7B model can answer one chat stream at a few dozen tokens per second and serve hundreds in aggregate once requests are batched. Both numbers are true; they answer different questions.

Three things move it: the engine (vLLM, TensorRT-LLM and llama.cpp trade off differently), the batch size the workload can sustain, and the model itself — a sparse mixture-of-experts model decodes far faster than a dense model of the same total size. That is why the VRAM calculator reports a bandwidth ceiling and warns that real throughput lands 50–80% below it.

NoteMeasure, then calculate

Run your actual model on your actual card at your actual prompt lengths, and note the aggregate output tokens per second at the concurrency you expect. A calculator fed a plausible-sounding benchmark produces a confident answer to somebody else’s question.

When each side actually wins

  • APIs win below the crossover, for spiky traffic, for prototypes, for anything with a compliance budget instead of an ops team, and whenever the frontier model you need is one you cannot host at all.
  • Self-hosting wins at steady high volume, on batch pipelines, when the data cannot leave your network, when you need a specific fine-tune you own, and when you already employ someone who can run a serving stack.
  • Both win in the hybrid pattern most teams settle on: a small self-hosted model for the bulk of cheap classification and extraction, with an API for the rare hard request.

A word on quality: the API model and the open model are almost never the same model. A frontier model and a self-hosted 7B are not substitutes for every task, so price the gap deliberately instead of assuming the cheap option is good enough.

The costs that never appear on the invoice

The GPU hourly rate is the visible part. The invisible part is a person: someone has to pick a serving engine, tune batching, watch for out-of-memory crashes at 3 a.m. and keep the thing patched. That is a real salary, and it does not shrink because the instance is small.

  • Engineering time — the largest hidden line item, and what the extra-cost field exists for.
  • Storage and egress — model weights are tens of gigabytes, and moving them between regions is not free.
  • Idle capacity — you provision for the peak and pay for it through the trough.
  • Cold starts — a serverless GPU that loads 15 GB of weights before answering is not comparable to a warm API.
  • Rate limits — an API that throttles you at the wrong moment has a cost too, just not on the invoice.
  • Privacy and control — sometimes worth paying for, and sometimes the entire reason for the exercise.
NoteEverything runs in this tab

The API prices come from this site’s checked catalogue and are shown with the date they were verified; the GPU table holds only memory and bandwidth, never a rental price. The rental rate and the throughput are yours to enter, and the arithmetic runs in your browser: no request leaves the page.

常见问题

Is it cheaper to self-host an LLM or use an API?
It depends entirely on volume and utilization, which is why this page asks for both. Below the break-even volume the API wins, because you pay only for the tokens you use. Above it, the fixed GPU bill is spread over enough tokens that the marginal cost falls near zero. One $2/hour card at 50% utilization costs about $1,560 a month and serves roughly 657 million output tokens; whether that beats an API depends on the API price and your real throughput.
How do you calculate the break-even volume?
Divide the fixed monthly self-host bill by the API cost per output token at your own input:output ratio. If the API charges $30 per million output tokens at your ratio and the hardware costs $1,560 a month, the crossover is 1,560 ÷ 30 = 52 million output tokens per month. Keeping the ratio fixed is what makes the number meaningful: change the mix of prompt and completion and the crossover moves.
Why do you not fill in a GPU rental price for me?
Because there is no single price. The same card rents for very different amounts depending on provider, region, commitment length and whether it is on-demand or spot, and the spread is a factor of several. A default would anchor the whole comparison on a number you were never quoted, so the field stays empty until you enter what your provider actually charges.
What throughput should I enter?
The aggregate output tokens per second your deployment sustains at the concurrency you expect, measured on your own hardware. Do not enter single-stream chat speed, which is far lower, and do not enter a vendor benchmark for a different model. If you have not measured it yet, run a short load test with realistic prompt lengths — this is the input that moves the answer most.
Why does utilization matter so much?
Because the bill does not care. Renting a GPU for 730 hours costs the same whether it serves one request or a billion, so utilization is the denominator of your cost per token. Halving utilization doubles the effective cost per million tokens. Spiky consumer traffic is the worst case for self-hosting; steady batch work is the best.
Does this account for the API model being better than the open model?
No, and it cannot. This is a cost comparison between two line items, not a quality comparison between two models. If the open model you can host is weaker at your task, the real comparison is between the frontier API and an open model plus whatever extra work closes the gap. Price that gap explicitly rather than assuming it away.
What if my volume exceeds one GPU?
The calculator steps the bill up in whole cards and shows the figure for however many GPUs the volume actually needs, because comparing an API bill against an under-provisioned cluster is the classic mistake. Capacity grows with the added cards, so the cost per million tokens is recomputed against the larger deployment rather than the original one.
Do the API prices on this page update themselves?
No. They come from this site’s checked catalogue and the page prints the date they were last verified against provider pricing pages. An unpriced model is excluded rather than treated as free. Always confirm the current rate on the provider’s own page before committing to a budget.

在课程中学习

此工具是免费 11 阶段课程中以下阶段的动手实践配套。

  • LLM VRAM Calculator →

    Pick a model and a card to see how many gigabytes it really takes to serve — weights, the KV cache your context length creates, and the runtime overhead nobody mentions. Every formula is printed on the page.

  • LLM API Cost Calculator →

    Turn a token count and a traffic guess into a real monthly bill. Set the prompt size, the answer size and how many requests you expect, and every priced model is compared side by side.

全部工具建议更正