Self-hosted LLM vs API: calculating the breakeven point

10 min read

Renting a server with a single RTX 4090 graphics card costs about $317 a month. API requests for the Llama 3.1 8B model on OpenRouter start from $0.05 per 1 million tokens.

A self-hosted server pays off only with continuous 24/7 generation. Any pause in operation makes buying tokens significantly cheaper.

Calculating hardware rental costs against buying tokens

Developers often view dropping an API provider as direct savings. In practice, renting a bare chip eats up more budget due to the radical drop in token prices over recent years. Provider price wars have pushed inference costs to an absolute minimum.

Server rack shaped like a piggy bank dropping a coin
A rented server continuously drains the budget even with no active workload

An RTX 4090 server costs $0.44 for every hour of operation. Multiply $0.44 by 24 hours to get $10.56 a day. Multiply that by 30 days to get $316.80 a month. Round it up to $317.

A monthly rent of $317 equals buying 6.34 billion tokens for Llama 3.1 8B at $0.05 per million. You divide 317 by 0.05 and multiply by a million.

To justify the hardware rental, the server must generate 211 million tokens every single day. Divide 6.34 billion by 30 days. The hardware has to crunch requests 24/7 without weekends at a speed of 2442 tokens per second. Loading a server with this volume of tasks at the start of a project is practically impossible. Most applications generate short responses, consuming hundreds of tokens per call. You can only accumulate billions of tokens during massive text processing.

For local tests without complex terminal setup, there is Unsloth Desktop. The software allows sharing model access over a local network. A developer downloads the app, selects a model, and gets a ready endpoint. Transferring this experience to rented servers in production requires accounting for night downtime. A local computer can be turned off. A rented server continues to consume money every second.

VRAM requirements for different models

The 16-bit Llama 3.1 8B model requires about 16 GB of memory. It fits perfectly on a single RTX 4090 with 24 GB on board. This leaves room for the context window and request batching. Batching allows processing multiple requests simultaneously, which increases server throughput.

The Llama 4 Scout model requires about 28 GB of VRAM to run with QLoRA quantization. This volume does not fit into a single consumer card. It fits on two RTX 4090s or one A100 40GB server card. Renting an A100 instance on RunPod costs $2.72 per hour. Multiply 2.72 by 720 hours a month to get $1958. The sum looks massive for a small project.

The API for Llama 4 Scout costs on average between $0.15 and $0.50 per 1 million tokens at third-party hosting providers. The difference in fixed costs is huge. Renting an A100 pays off only with giant traffic volumes.

Running large models with 70B parameters or more requires professional hardware. The Qwen 2.5 72B model takes up about 140 GB of memory when using full weights. It needs an H100 80GB level graphics card, which costs from $2.49 per hour to rent.

The API for Qwen 2.5 72B costs from $0.35 to $1.20 per 1 million tokens depending on the provider. Together AI charges $1.20 for this model. With H100 rental prices starting at $2.49 per hour, the server must generate 2.07 million tokens every hour just to break even. You divide 2.49 by 1.20. More details about pricing are written in our article about neural network API prices.

Breakeven point using a vectorization pipeline

The breakeven point occurs at a specific mathematical mark. The calculation depends on the task type and the chosen model. Text vectorization shows this boundary perfectly.

The breakeven point for renting an RTX 4090 at $317 a month compared to the OpenAI text-embedding-3-small API comes at a stable volume of about 1.06 million requests per day.

Before reaching the 1.06 million daily requests mark, using an API is cheaper and requires no maintenance. The API cost curve goes above the fixed server cost only after crossing this threshold. Vectorizing a medium-sized knowledge base rarely demands millions of daily requests. Usually, the base is indexed once. Then only new documents and user queries are vectorized. The main token volume is spent during the initial data load phase.

Cheap APIs often have strict limits on requests per minute. Providers rarely write about this on their main pricing pages. When the threshold is reached, the service returns an error, which you can read about in the article on /en/blog/oshibka-429-rate-limit/. Rate limits force developers to switch to more expensive plans or spin up their own servers to bypass the restrictions.

Downtime impact and hidden infrastructure costs

The load schedule breaks ideal utilization calculations. Startups with uneven traffic have pronounced peaks during the day and deep drops at night. Users sleep, and the server sits idle. Rent is charged every hour regardless of the actual payload.

Server unit peacefully lying on a soft white pillow
Nighttime hardware downtime does not exempt you from hourly rental payments

If the server is idle at night or during traffic dips, the breakeven point shifts significantly. With a 12-hour downtime, you will need to generate twice as many tokens during active hours to justify the fixed rental fee. The server continues to consume money even without requests. The zero operational overhead of an API beats renting hardware under an erratic load schedule.

Hidden infrastructure costs change the calculations even more. Comparisons usually feature only bare metal versus token prices. They do not factor in an engineer's salary. Setting up vLLM takes time from a qualified specialist. The same goes for debugging CUDA crashes and configuring a load balancer.

API providers have implemented automatic prompt caching. This reduces the cost of repeating tokens by 50 to 90 percent. System instructions or heavy context in RAG systems cost pennies. You will have to configure your own server for prefix caching manually, allocating precious VRAM for this task. The memory fills up with cache, leaving less room for the actual generation.

Quality degradation when quantizing large models

Running heavy neural networks on cheap hardware requires compromises. To squeeze Qwen 2.5 72B into affordable graphics cards, the model must be heavily quantized to 4-bit. Quantization trims the precision of floating-point numbers. The model weights take up less space but lose some information.

Scissors cutting metal contacts on a microchip
Compressing a model to run on cheap hardware leads to irreversible loss of precision

Sources stay silent about quality degradation during such compression. The responses of a local server with a quantized model will be worse than those from an API provider. Providers spin full weights in FP16 or BF16 formats on H100 clusters. They can afford to keep giant models in RAM without compression.

Saving on rent turns into a drop in response accuracy. Complex logical tasks require full weights, which are available via API without buying expensive servers. The neural network starts confusing facts and writing less coherent code. A developer spends hours debugging prompts, trying to make the quantized model work properly. The project loses users due to low generation quality. The cheapskate pays twice.

Generation speed and latency

Time to first token is highly important for interactive applications. Standard GPU inference using vLLM provides a time to first token of 50-200 ms for 7B size models. The time depends heavily on the current server load. A request queue increases latency. One heavy request blocks the processing of the rest.

Achieving a latency of less than 100 ms during inference requires using specialized Groq LPU chips or self-hosting on an H100 with the TensorRT-LLM library. Setting up TensorRT-LLM takes days and demands a deep understanding of the CUDA architecture.

Groq chips deliver a generation speed of 500 to 800 tokens per second. A rented RTX 4090 is physically incapable of showing such throughput due to memory bus limitations. Providers with optimized hardware beat a budget solution in speed.

Interruptible instances and the hybrid approach

Server costs can be optimized at high traffic volumes. Using interruptible spot instances on platforms like Vast.ai allows reducing GPU inference costs by 66% compared to on-demand pricing.

Instead of $0.44 an hour for an RTX 4090, you are charged about $0.15. The risk lies in the possible termination of the machine at any moment. The provider gives the capacity to another client when the bid goes up. For production, you build an architecture with a minimal pool of permanent servers and spot machines for peak loads. A load balancer redirects traffic when a node drops. Setting up such a system requires time and experience.

Using a hybrid approach lets you save 50 to 70 percent of the budget compared to using only a managed API. Complex tasks go to the paid API. Massive simple tasks are sent to your own server with spot instances. Request routing reduces the total cost of the system. The developer balances between reliability and price.

Task splitting via API

The hybrid approach is easy to implement in practice. Heavy tasks of image or video generation are more profitable to send to an API, leaving only text routing to the local server.

The qwen-image-3 model is available in the catalog at a cost of $0.0276 per image. Local image generation requires a separate graphics card and complicates load balancing. An API call solves this problem with a single function.

Python
import requests
import json

# Example of calling the qwen-image-3 model via API
# The local server does not waste VRAM on generating images
url = "https://api.altrouter.ai/images/generations"
headers = {
    "Authorization": "Bearer ar-...",
    "Content-Type": "application/json"
}
payload = {
    "model": "qwen-image-3",
    "prompt": "Server rack with graphics cards, neon lighting, 4k",
    "resolution": "1K",
    "response_format": "url",
    "async": False
}

response = requests.post(url, headers=headers, data=json.dumps(payload))
print(response.json())

The code sends a text description to the provider's server. The provider allocates capacity to generate the image. Then it returns a link. The local RTX 4090 continues to process user text requests at this moment without speed drops. Task splitting increases the fault tolerance of the application.

The decision making rule

Choosing between an API and renting a server comes down to evaluating resource utilization.

Switching to rented graphics cards makes sense under stable and high load. The server must not sit idle at night or on weekends.

Paying for tokens saves the budget during uneven traffic. A developer pays exactly for the consumed volume.

ParameterChoosing an APIChoosing a self-hosted server
Daily volumeUnder 1.06 million requestsOver 1.06 million requests stably
Load schedulePeaks by day, idle by nightEven load without drops
InfrastructureNo dedicated DevOpsResources available to set up vLLM
Hardware requirementsGroq LPU speed neededRTX 4090 speed is enough
Response qualityFull FP16 weights needed4-bit quantization is acceptable

Models in this article