API vs self-hosted LLM: where the cost lines cross
Compare API vs self-hosted LLM cost: where per-token pricing stops being cheaper, and how to find that volume for your own workload, step by step.
Updated
A hosted API bills you per token, so it is usually cheaper at low volume. Self-hosting bills you for the time a server runs, so it becomes cheaper once steady traffic keeps that server busy. The crossover point depends on your volume, your prompt sizes and how much accuracy you need, so you have to calculate it for each task. Own Weights runs this math for each task before recommending a move.
How each side bills
An API invoice is a sum of input tokens and output tokens, each priced per million. Input and output rates are set separately, so check both on the vendor’s current pricing page before you compare, since those rates change. Batch processing is priced below real-time calls, which matters for work that can wait. For the unit itself, see cost per million tokens.
Self-hosting bills for a server that costs the same whether it is busy or idle. You also pay for the people who install it, patch it, monitor it and plan for traffic spikes. None of that appears on a token invoice, which is why comparisons built only on token counts tend to undercount self-hosting.
Find the crossover for one task
Work through these steps for each task separately. One high-volume task may cross over while another stays cheaper on an API.
- Count calls per day and tokens per call, input and output together. Multiply them, then by the days in a month, to get monthly token volume.
- Price that volume on the API you use today, using the input and output rates separately.
- Add the fixed monthly cost of the server you would run, plus the engineering hours to operate it at your expected load.
- Divide that total by the tokens the server can really process in a month. Use measured throughput, not the theoretical maximum.
- Compare the two cost-per-million figures, then repeat the check at double your volume, because the answer moves as traffic grows. The LLM cost calculator runs steps 1 and 2 with your numbers.
How to price both options on your own files
Token math only holds if both options do the job equally well, so run the current API model and the self-hosted candidate on the same checked inputs, with the candidate on the server you would pay for and at your expected concurrency, and compare cost per correct result rather than cost per token. The full method is in how to build a test set.
Throughput belongs in the same calculation. A system that moves more tokens per second finishes the same batch sooner, so its fixed cost is spread over more documents. For why this unit matters more than tokens, read cost per document.
Common mistakes in the comparison
- Comparing a server bill against the per-token price of a model you would not use for the job. Hold the quality bar constant.
- Using peak throughput instead of real throughput. A server sized for its busiest hour sits idle the rest of the day.
- Leaving out setup, patching, monitoring and on-call time because nobody sends an invoice for it.
- Forgetting that an idle server still costs money when traffic drops.
- Comparing cost per call instead of cost per correct result. A model that gets one extraction in ten wrong may cost more after someone reviews the misses. Hidden LLM costs covers more of the lines that get missed.
- Treating the crossover as a fixed number. It moves with volume, prompt length and how often the task changes.
When self-hosting wins and when the API does
Self-hosting tends to win when volume is high and steady, the task is narrow and repeats every day, and the documents or prompts cannot leave your environment. It also helps when you want the weights to stay under your control. If a vendor retires the model you depend on, you need a plan either way. Model retirements explain how that usually goes.
The API tends to win when volume is low or spiky, when one general model covers many jobs, or when nobody on the team can run a server. It also wins while the task changes every week, because retraining after each change costs time.
Mid-volume tasks are the hard case. The per-token gap can be small, so the decision rests on control, data rules and risk as much as on the invoice. Send the same test set through both options and compare cost per correct result before you decide. That test is what makes the comparison fair.
The free AI cost audit reads your code and lists your AI calls, the models they use and their estimated cost, so you can see which tasks carry the volume. If one of them looks like a candidate, book a call. We will walk through the crossover math for that task and test it against your current model on your own data.
Questions
At what volume does self-hosting an LLM become cheaper than an API?
There is no universal number. It depends on your steady monthly token volume, the per-token price of the API model you compare against, and the fixed cost of running the server. Run the math at your own volume, and include the engineering time that no invoice shows.
Does the Batch API close the gap with self-hosting?
Anthropic's Batch API is half price on list rates, so it narrows the gap for work that can wait. Whether it beats self-hosting depends on how many tokens you process and how much of that work is latency tolerant. Check the current pricing pages of other vendors before you compare.
Do I need to self-host to keep prompts private?
Read your vendor's data terms and your own policy first. If your rules say prompts cannot leave your environment, a model running in your cloud account or on-prem is the direct route, under your own controls.