Local LLM vs hosted API: the comparison almost everyone gets wrong
Search for "local LLM vs API" and you get two camps shouting past each other. One side posts an API invoice next to the price of a GPU. The other side posts a local model answering a question and calls it free. Both are comparing the wrong things.
The honest framing: self-hosting converts a variable cost into a fixed cost plus an ops salary. Renting keeps it variable. The GPU you buy is billed to you every hour of the month whether or not a single token flows through it, and the engineer who keeps drivers, quantization settings, and eval suites healthy is a real line item. Once you see it that way, the decision stops being ideological and becomes a utilization question — with a quality rider attached.
What self-hosting genuinely wins at
Data residency you actually control. Prompts never leave your network. For regulated data or air-gapped environments, this isn't a nice-to-have, it's the whole argument.
Zero marginal cost once saturated. If the GPU is already busy, the next request is close to free. That makes large batch jobs — backfills, re-embedding a corpus, overnight classification — very attractive.
No shared tenancy. Your p95 latency is your own problem, not a neighbor's traffic spike. Predictable throughput on a LAN is a real advantage for interactive tooling.
Custom weights. Fine-tuning, LoRA adapters, logit access, and custom sampling are all yours to play with.
Offline operation. Nothing to authenticate against, nothing to rate-limit you during a demo.
What a hosted API genuinely wins at
You pay nothing for idle. A side project that handles a few hundred requests a day should never own a GPU.
Frontier quality on demand. Route the routine 80% of traffic to
deepseek-v4-flashand the hard cases todeepseek-v4-pro, without buying hardware that can hold the bigger model at interactive speed.Pricing that rewards the way real apps behave. Off-peak requests cost less than peak, and repeated prompts benefit from cache hits — both push the effective rate below the headline rate.
Upgrades are a string change. New model generation, no re-qualifying hardware, no re-tuning quantization.
Failed experiments are cheap. You spend tokens, not a quarter of capital budget, to learn that an idea didn't work.
Where the break-even actually sits
The break-even isn't a token count, it's a duty cycle. Two teams can process the same monthly volume and get opposite answers: one has a constant queue that never drains, the other has a spiky workload where the 95th percentile is busy and the average is nearly idle. The second team is buying a whole GPU to do a fraction of a GPU's work.
The second variable is who owns the stack. If you already employ people who run infrastructure and want to own CUDA upgrades and eval regressions, self-hosting is an incremental cost. If your team is three product engineers, every hour spent debugging a driver is an hour not spent on the product — and that cost dominates everything else in the model.
| Dimension | Self-hosted | Hosted API |
|---|---|---|
| Upfront capital | GPU/server cost, depreciated over its useful life | None; you pay per token |
| Marginal cost of one more request | Near zero until the GPU saturates | Metered, but lower for flash models, cache hits, and off-peak traffic |
| Cost of being idle | Full fixed cost, every hour of the month | Zero |
| Data residency | Full control, air-gap possible | Contract- and provider-dependent |
| Model ceiling | Whatever fits in VRAM at usable speed | Frontier models you could never host |
| Upgrade cadence | Re-qualify hardware, re-run evals | Change a model string |
| Failure mode | Pager at 2 a.m.; the queue backs up | Rate limits or an outage you can't fix — so plan a fallback |
Step 1: measure your real token profile
Arguments about cost should start with your own numbers, not someone's blog post. Run a representative slice of your actual prompts through the hosted endpoint and record input/output tokens per request — the ratio matters as much as the total, because output tokens are the expensive half.
import os
from openai import OpenAI
client = OpenAI(
base_url='https://api.aicreditsapi.com/v1',
api_key=os.environ['AICREDITS_API_KEY'],
)
PROMPTS = [
'Summarize this support ticket in two sentences: my invoice shows a charge after I cancelled.',
'Rewrite this changelog entry for end users: refactored auth middleware, fixed a race condition.',
'Extract JSON with keys company and role from: Senior backend engineer at Nordwind Labs.',
]
def profile(prompts, model='deepseek-v4-flash'):
prompt_tokens = 0
completion_tokens = 0
for p in prompts:
resp = client.chat.completions.create(
model=model,
messages=[{'role': 'user', 'content': p}],
max_tokens=300,
)
prompt_tokens += resp.usage.prompt_tokens
completion_tokens += resp.usage.completion_tokens
n = len(prompts)
print(f'prompt tokens/request: {prompt_tokens / n:.1f}')
print(f'completion tokens/request: {completion_tokens / n:.1f}')
return prompt_tokens / n, completion_tokens / n
profile(PROMPTS)
Step 2: run the break-even with your own numbers
Plug in your own hardware quote, your electricity estimate, your honest ops hours, and the current hosted rates from aicreditsapi.com/deepseek-prices. If the ratio printed is above 1, the hosted bill is cheaper at that volume.
import os
# Your numbers, not mine: hosted rates from aicreditsapi.com/deepseek-prices,
# local numbers from your own quotes.
HOSTED_IN = float(os.environ['HOSTED_INPUT_PER_MTOK'])
HOSTED_OUT = float(os.environ['HOSTED_OUTPUT_PER_MTOK'])
GPU_MONTHLY = float(os.environ['LOCAL_GPU_AMORTIZED_MONTHLY'])
POWER_MONTHLY = float(os.environ['LOCAL_POWER_MONTHLY'])
OPS_HOURS = float(os.environ['LOCAL_OPS_HOURS_MONTHLY'])
ENG_RATE = float(os.environ['ENG_HOURLY_RATE'])
def hosted_cost(mtok_in, mtok_out):
return mtok_in * HOSTED_IN + mtok_out * HOSTED_OUT
def local_cost():
return GPU_MONTHLY + POWER_MONTHLY + (OPS_HOURS * ENG_RATE)
# Replace with what the profiler printed, and your real monthly request count.
in_per_req, out_per_req, reqs = 900, 250, 300_000
mtok_in = reqs * in_per_req / 1e6
mtok_out = reqs * out_per_req / 1e6
ratio = local_cost() / hosted_cost(mtok_in, mtok_out)
print(f'hosted at your volume: {hosted_cost(mtok_in, mtok_out):.2f}')
print(f'local fixed cost: {local_cost():.2f}')
print(f'ratio: {ratio:.2f} (>1 means renting wins)')
Step 3: test quality, not just cost
The hidden cost of local inference is silent quality drift. A quantized model can look great on your demo prompt and quietly degrade on the long-tail inputs that actually matter — nested JSON, multi-step arithmetic, non-English text. If you can't measure that drift, "free" inference is being paid for with customer trust.
Build a golden set of 50–200 real requests with known-good answers and run it against both candidates. The same script works in both directions, and it's what makes a future migration cheap.
import os
import time
from openai import OpenAI
targets = {
'local': OpenAI(
base_url=os.environ.get('LOCAL_BASE_URL', 'http://localhost:11434/v1'),
api_key=os.environ.get('LOCAL_API_KEY', 'ollama'),
),
'hosted': OpenAI(
base_url='https://api.aicreditsapi.com/v1',
api_key=os.environ['AICREDITS_API_KEY'],
),
}
models = {'local': os.environ['LOCAL_MODEL'], 'hosted': 'deepseek-v4-flash'}
prompt = 'Return JSON with keys risk (low|medium|high) and why (max 20 words) for: customer asks for a refund 40 days after purchase.'
for name, client in targets.items():
start = time.perf_counter()
resp = client.chat.completions.create(
model=models[name],
messages=[{'role': 'user', 'content': prompt}],
temperature=0,
)
elapsed = time.perf_counter() - start
print(f'{name}: {elapsed:.2f}s, {resp.usage.completion_tokens} out tokens')
print(resp.choices[0].message.content[:200])
The hybrid that usually wins
Most mature teams end up with both, split by data sensitivity and traffic shape rather than by ideology. Privacy-sensitive classification and offline batch jobs stay on your own hardware. Bursty, quality-critical, long-context work — the part where a deepseek-v4-pro call is the difference between a usable answer and a correction email — goes to the hosted endpoint. The routing lives in one function, and the eval set from Step 3 tells you when to move a workload across the line.
For international developers, the practical friction on the hosted side has usually been billing. AiCredits accepts an international card or PayPal, with no Chinese phone number or bank account required, and speaks the OpenAI SDK protocol at https://api.aicreditsapi.com/v1 — so the scripts above are the whole integration.
FAQ
There's no universal threshold, because it depends on your hardware quote, power, and what your engineers' time is worth. The reliable signal is direction, not a number: if your GPU sits idle most of the day, or nobody on staff wants to own driver upgrades and eval regressions, renting wins. If your queue never drains and you already pay for infra people, owning hardware starts to make sense. Run the Step 2 script with your own inputs instead of trusting a rule of thumb.
Some DeepSeek model families have published open weights, and you can serve quantized versions on your own hardware. But the model you can fit and run at interactive speed on one machine is not the same model you get from the hosted deepseek-v4-flash or deepseek-v4-pro endpoints — expect a gap on long-context and reasoning-heavy work. Test both on your golden set before assuming parity.
Not automatically, but you are trading control for convenience. Local inference is the only option that keeps prompts on hardware you own, which matters for regulated or air-gapped environments. For everything else, read the provider's retention and logging terms and redact sensitive fields before they leave your network.
For a small model on warm hardware over a LAN, often yes, and it's more predictable because nobody shares the GPU. But a local server cold-loading weights will lose badly, and a single GPU degrades quickly under concurrency while a hosted provider absorbs spikes you couldn't. Measure p95 on both, not the average.
That's the friction AiCredits exists to remove: top up DeepSeek API credits with an international card or PayPal, no Chinese phone number or bank account needed, then point the OpenAI SDK at https://api.aicreditsapi.com/v1. Current rates are listed at aicreditsapi.com/deepseek-prices.
The question isn't "local or API". It's "which token streams are steady enough to own, and which ones should stay metered?"