
Self-hosting an LLM can look cheaper when an API bill is divided by a GPU price. That shortcut misses the question that matters: can the selected machine deliver the required quality, context, concurrency, and uptime at the volume where the spreadsheet says costs cross?
This guide provides a capacity-aware calculator for a solo operator comparing three options: a token-priced API, a rented GPU, and owned hardware. It separates input, cached input, and output tokens; includes power and maintenance time; and rejects a theoretical break-even point when the hardware cannot process that workload.
Practical conclusion: use an API while demand is variable or poorly measured. Reconsider self-hosting only after a representative local model passes the same task-quality test and the calculated crossover fits inside measured monthly capacity.
Start With Comparable Output, Not a Cheaper Model Name
A cost comparison is invalid if the options cannot complete the same business task. A small local model that needs repeated retries, longer prompts, manual correction, or a second API call may cost more than its headline inference rate suggests.
Create a fixed evaluation set before entering prices. For example, a customer-support workload might contain 50 anonymized requests with approved answers. Score each candidate on factual accuracy, instruction following, required format, unacceptable answers, latency, and human correction minutes. Only models that meet the minimum quality threshold enter the cost worksheet.
| Qualification check | Evidence to record | Why it changes cost |
|---|---|---|
| Task accuracy | Pass rate on the same fixed examples | Failed answers create retries and editing labor |
| Prompt and output length | Median input, cached input, and output tokens | API providers often price these categories differently |
| Context requirement | Typical and maximum context used | Long context can alter price, speed, and memory needs |
| Concurrency | Average and peak simultaneous requests | A single-user benchmark may not meet production latency |
| Reliability | Timeouts, retries, malformed outputs, and unavailable periods | Each failure consumes capacity and founder time |
Do not compare an open-weight model with a frontier API solely because both accept text. First compare equivalent or similarly qualified outputs, then include any higher-quality commercial API that meets the real business requirement.
The Three Operating Models
| Model | Primary billing unit | Best fit | Main hidden cost |
|---|---|---|---|
| Token-priced API | Input, cached input, output, tools, or media | Variable demand and rapid experimentation | Retries, long context, tool calls, and provider changes |
| Rented GPU | Provisioned or active instance hours, storage, and network | Measured batch windows or temporary dedicated capacity | Idle instance time, startup, storage, and availability |
| Owned workstation | Purchase, depreciation, electricity, labor, and failure reserve | Stable local workload, offline operation, or custom weights | Low utilization, maintenance, replacement, and one-machine failure risk |
API pricing pages from OpenAI, Anthropic, and Google show why a single “price per million tokens” is often insufficient. Input, output, caching, context, speed tiers, batch modes, and additional tools can have separate prices. Copy the current rates on the date of the calculation instead of preserving an old comparison table.
Build the Input Sheet Before Calculating
Collect at least two weeks of real or pilot usage. If the product does not yet exist, label every number as a scenario and run low, expected, and high cases.
| Input | How to obtain it | Common mistake |
|---|---|---|
| Monthly uncached input tokens | Provider usage export or application logs | Counting all input at the cheapest cached rate |
| Monthly cached input tokens | Billing category reported by the provider | Assuming every repeated prompt qualifies for caching |
| Monthly output tokens | Provider usage export | Using the input price for output |
| Retry and failure rate | Application logs and manual review | Ignoring tokens spent on unusable answers |
| Measured local tokens per second | Representative prompt, context, quantization, and concurrency | Copying a short single-user benchmark |
| Active and idle power | Wall-power meter during the same test | Using GPU board power as the entire system draw |
| Maintenance hours | Time log for setup, updates, monitoring, and incidents | Valuing founder time at zero |
| Usable hours and uptime target | Operating schedule and maintenance window | Assuming 24/7 perfect utilization |
If local hardware is part of the decision, use the complete 36-month framework in the Local AI Cost calculator for purchase price, accessories, electricity, labor, and residual value.
Formula 1: Calculate the Real Monthly API Cost
Use separate quantities and rates:
Monthly API cost = (uncached input millions × input price) + (cached input millions × cached price) + (output millions × output price) + tool, search, storage, media, retry, and network charges
Keep subscription products separate from API billing. A consumer chat plan does not automatically include developer API usage. Save the pricing URL, model identifier, region or service tier, calculation date, and billing currency.
If an API offers batch or cached-input discounts, apply them only to traffic that actually qualifies. A theoretical discount should not be used for interactive requests that require immediate responses.
Formula 2: Calculate Self-Hosted Monthly Cost
For owned hardware:
Owned monthly cost = (purchase price − expected residual value) ÷ useful months + active electricity + idle electricity + maintenance labor + monitoring, backup, network, and failure reserve
For rented infrastructure:
Rented monthly cost = GPU instance rate × provisioned hours + CPU, memory, storage, image, network, and operations cost
Cloud rates depend on region, machine configuration, commitment, and whether capacity is spot or on demand. Google Cloud’s accelerator pricing illustrates that the GPU line item may sit beside CPU and memory requirements. Use the complete configured instance price.
For electricity, use the marginal rate on the actual utility bill. The U.S. Energy Information Administration publishes retail electricity price data as a fallback reference, but national or state averages do not replace local tariffs and time-of-use charges.
Manufacturer power specifications are boundaries, not measurements of your inference workload. NVIDIA lists official memory and total graphics power on its RTX 5090 specification page, but the real calculation should use whole-system wall power during the target model, context, and concurrency test.
Formula 3: Test Cost Break-Even and Capacity
Convert the real API bill into a blended price per one million total processed tokens:
Blended API rate = monthly API cost ÷ total token millions
Then estimate self-hosted variable cost per million tokens using the measured throughput and wall power. Separate fixed monthly costs from variable electricity or usage costs.
Break-even token millions = fixed monthly self-host cost ÷ (blended API rate − self-host variable cost per million)
This equation works only when the API rate is higher than the self-hosted variable rate. It also needs a second test:
Maximum monthly capacity = measured tokens per second × 3,600 × usable hours × utilization factor ÷ 1,000,000
If break-even volume is higher than maximum capacity, the machine cannot reach the advertised crossover. The answer is not “buy the GPU.” The answer is to change the hardware, improve throughput, reduce fixed cost, or continue using the API.
Run the benchmark with the exact serving engine and settings you intend to operate. The llama.cpp project provides a widely used local inference implementation and benchmark tooling, but results still depend on model, quantization, context, batch size, backend, and hardware.
Worked Example: A Theoretical Crossover That Cannot Fit
The following figures are hypothetical and demonstrate the method. They are not a hardware recommendation or current vendor quote.
- 12 million uncached input tokens at $1 per million
- 3 million cached input tokens at $0.10 per million
- 3 million output tokens at $5 per million
- API bill: $12 + $0.30 + $15 = $27.30 per month
- $3,000 workstation, $600 expected residual value, 36-month life: $66.67 per month
- Three maintenance hours at $40 plus $20 monitoring and reserve: $140 per month
- Measured 450-watt active system for 80 hours at $0.18/kWh: $6.48
- Total self-hosted cost at the current workload: about $213.15 per month
At 18 million total tokens, the blended API rate is about $1.52 per million. If the local system produces 62.5 tokens per second, one million tokens takes about 4.44 hours and active electricity is about $0.36 per million. Fixed monthly self-hosted cost is $206.67.
The simple crossover is approximately:
$206.67 ÷ ($1.52 − $0.36) = about 178 million tokens per month
But 62.5 tokens per second running continuously for 720 hours produces only about 162 million tokens. Even before downtime and utilization loss, this machine cannot reach the calculated break-even volume. The capacity check reverses the decision that a cost-only formula might suggest.
A Practical Observation From My Claude Workflow
In my own Claude workflow, long conversations became slower and reached usage limits sooner when unrelated tasks and large context remained in the same session. I documented that operating problem in the Korean article “Claude Token Guide: Practical Ways to Reduce Usage”, published May 14, 2026.
This is a personal workflow observation, not a universal provider benchmark or a promise of a specific savings rate. Its relevance to this calculator is that prompt length, retained context, repeated attachments, and retries change the measured workload. Optimize the application first, then compare infrastructure using the resulting usage rather than paying to self-host avoidable tokens.
A 7-Day Measurement Plan Before Buying Hardware
- Day 1: export API usage and separate input, cached input, output, tool calls, retries, and failed requests.
- Day 2: build the fixed quality set and establish the minimum acceptable score.
- Day 3: test the candidate local model on the same examples and record human correction time.
- Day 4: benchmark the exact quantization, context, batch size, and expected concurrency.
- Day 5: measure active and idle wall power and log setup or maintenance time.
- Day 6: calculate low, expected, and peak scenarios, including downtime and a failure reserve.
- Day 7: compare break-even volume with maximum capacity and choose API, rented GPU, owned hardware, or a hybrid.
For a wider decision that includes vendor dependence, lock-in, migration, and founder time, use the AI Tool Costs and Business Risk framework. If you will deploy a custom endpoint or internal application, apply the permission and testing controls in the Vibe Coding build-control workflow. Review provider data use, retention, ownership, and exit terms with the AI Contract Review checklist.
Decision Rules
| Observed condition | Likely starting decision |
|---|---|
| Demand is early, irregular, or hard to forecast | Token-priced API |
| Workload is predictable but needed only in scheduled windows | Rented GPU that can shut down |
| Qualified model fits one machine and remains highly utilized | Evaluate owned hardware |
| Break-even volume exceeds measured hardware capacity | API, larger deployment, or workload redesign |
| Data or offline requirements dominate cost | Self-hosting may be justified even without the lowest token cost |
| No one owns monitoring, updates, backup, and incidents | Do not launch a production self-hosted service |
Pre-Purchase Checklist
- The local and API candidates passed the same quality threshold.
- Input, cached input, output, retries, and tools are measured separately.
- Local throughput was tested at the target context and concurrency.
- Power came from a wall measurement, not only a GPU specification.
- Founder maintenance and incident time has a realistic value.
- Residual value, storage, network, backup, and failure reserve are included.
- Break-even volume fits inside maximum monthly capacity.
- A manual or API fallback exists when the local system is unavailable.
- Pricing and model versions are dated and can be updated without rewriting the method.
Frequently Asked Questions
What is the fastest useful break-even calculation?
Measure one month of API usage, calculate the blended cost per million total tokens, estimate complete fixed and variable self-host costs, then divide fixed cost by the difference between the two variable rates. Finally compare that volume with measured hardware capacity.
Should I include a computer I already own as free?
No. Include the portion of depreciation, electricity, maintenance, and opportunity cost attributable to the workload. If the machine would exist anyway, run both an incremental-cost scenario and a full-cost scenario and label them clearly.
Does private data automatically require self-hosting?
No single infrastructure choice guarantees privacy or compliance. The answer depends on the data, provider terms, retention settings, access controls, contracts, jurisdiction, and your local security practices. A poorly secured local server can create its own risks.
Can I use published tokens-per-second benchmarks?
Use them to select candidates, not to approve a purchase. Repeat the benchmark with your model file, serving engine, prompt length, output length, quantization, concurrency, and hardware. Save the command, date, versions, and raw result.
How often should I redo the calculation?
Recalculate after major changes in API pricing, model quality, context length, caching, traffic, local hardware, electricity rates, serving software, or maintenance burden.
Final Takeaway
The correct question is not whether self-hosting has a lower theoretical cost per token. It is whether a qualified local model can serve the measured workload reliably, within capacity, for less complete cost than the API alternative.
AI models, pricing, caching rules, and hardware evolve quickly. Treat every result as a dated scenario. Preserve the worksheet and raw measurements, verify current official pricing, and rerun the same quality and capacity tests before purchasing hardware or making a long-term infrastructure commitment.
