Part of Running LLMs on Your Own Hardware: From “Will It Even Fit” to a Model That Does Your Work — running large language models on your own hardware.
tests/live_local.rs) · Ollama with qwen3:0.6b · llama.cpp llama-server build 11782 with Qwen3.5-2B Q4_K_M · single runs, debug test build · Windows 11 · AMD Radeon PRO W7900.
A local LLM gateway puts one endpoint, one credential and one audit log in front of Ollama, LM Studio and llama.cpp. In this article I connect all three to LLM Vault and measure what the gateway costs in latency. The short answer: about 7 ms on a 1.1 s Ollama call and 42 ms on a 40 s llama.cpp generation. I also cover the pitfall that costs the most time with reasoning models.
- Ollama, LM Studio, llama.cpp and vLLM all speak the OpenAI Chat Completions API, so one gateway handles them with the same code path.
- Measured gateway overhead: about 7 ms (Ollama, qwen3:0.6b) and 42 ms (llama.cpp, Qwen3.5-2B), below 1% of the call time.
- Thinking models can return an empty answer: qwen3 spent all 200 tokens on reasoning. Raise
max_tokensor add/no_think. - Local calls have no invoice, so LLM Vault prices them as an estimated energy cost and flags them that way.
Why a local LLM gateway in front of local servers
Local models look free and safe, so a gateway seems unnecessary at first. However, three problems appear as soon as several tools share the machine.
First, every server has its own port and quirks. Ollama listens on 11434, LM Studio on 1234, llama.cpp usually on 8080 and vLLM on 8000. Second, local servers usually run without authentication. Any process on the box, including a browser tab or an agent, can call them. Third, you lose track of who used what, and therefore you cannot compare a local model with the cloud model it replaces.
A gateway fixes all three. Clients get one URL and one scoped token. Meanwhile, the vault records each request with its client, agent, project, tokens and estimated cost. In addition, cloud models sit behind the same endpoint, so switching a script from qwen-local to foundry-glm is a one-word change.
This article is part of a series. The pillar post explains why agents should never hold API keys, and a separate guide covers Copilot Chat in VS Code.
Connect Ollama, LM Studio and llama.cpp to the local LLM gateway
LLM Vault ships presets for every common local server. Moreover, the “Detect local servers” button probes the default ports and adds whatever answers. These are the probes it runs:
// A server counts as present when its model list answers within 1.5 s.
let probes = [
("ollama-local", "http://127.0.0.1:11434/api/tags"),
("lmstudio", "http://127.0.0.1:1234/v1/models"),
("llama-cpp", "http://127.0.0.1:8080/v1/models"),
("vllm", "http://127.0.0.1:8000/v1/models"),
];
Ollama
Ollama needs no key locally, and its OpenAI compatibility layer serves /v1/chat/completions on port 11434. You can pull a model with the CLI or, as here, straight through the HTTP API:
curl http://127.0.0.1:11434/api/pull -d '{"model":"qwen3:0.6b","stream":false}'
# {"status":"success"} - about 523 MB
In LLM Vault, the Ollama provider uses the OpenAI-compatible /v1 API for chat and the native /api/tags for model discovery. Notably, Ollama also implements the Anthropic Messages API, so Claude Code can reach a local model through the same vault.
llama.cpp
Install llama.cpp with winget and start llama-server on a GGUF file. The --jinja flag matters, because without it tool calling does not use the model’s chat template:
winget install ggml.llamacpp
llama-server -m Qwen3.5-2B-Q4_K_M.gguf --host 127.0.0.1 --port 8080 -c 8192 --jinja -ngl 99
LM Studio
LM Studio exposes the same OpenAI-compatible API on port 1234. You start it from the Developer tab or with lms server start, as the lms CLI documentation shows. Because LM Studio runs GGUF models on the llama.cpp engine, the same model file also runs under llama-server with an identical API.

Measured local LLM gateway overhead
The live test sends the same decision prompt directly to the server and then through the vault. The prompt asks whether a client should retry an HTTP 429 immediately, retry with backoff or give up. After that, the test streams the answer, sends a tool-calling request and checks the audit log.
Free ebook
Free AI Video, Generated Locally
Working scripts and measured benchmarks. Free.
No spam. Unsubscribe at any time.
| Backend and model | Direct call | Through LLM Vault | Overhead | Streaming |
|---|---|---|---|---|
| Ollama, qwen3:0.6b | 1,087 ms, 200 tokens | 1,094 ms, 44 in / 200 out | about 7 ms | 199 SSE chunks |
| llama.cpp, Qwen3.5-2B Q4_K_M | 39,846 ms, 1,200 tokens | 39,888 ms, 44 in / 1,200 out | about 42 ms (0.1%) | 1,202 SSE chunks |
Treat single runs as an order of magnitude, because model-side variance is larger than the gateway itself. A repeated Ollama run even measured the vault call faster than the direct one. The conclusion holds either way: the gateway adds single-digit to low double-digit milliseconds, while generation time dominates.
The answers themselves were sensible. qwen3:0.6b replied “retry with backoff” and justified it in one sentence. In the tool-calling test, it called read_file with the right argument, and the call streamed through the gateway intact. Finally, the /v1/messages endpoint returned HTTP 200 through Ollama with usage reported as 10 input tokens and 3 cached tokens.
The pitfall with reasoning models
One problem shows up with every local server, so it deserves its own section.
An empty answer from a reasoning model
A reasoning model can return HTTP 200, a full count of completion tokens and an empty content field at the same time. The gateway is not the cause: the model spends the whole budget inside its thinking block. With qwen3:0.6b, a limit of 200 tokens produced no answer, while 1,200 tokens did. Qwen3.5-2B, however, used all 1,200 tokens for reasoning. For quick decisions, append /no_think to the prompt or pick a non-thinking model.
The same behaviour appears with larger models. In ollama-python issue #597, qwen3:32b put its whole output into the thinking field and left response blank. So when an answer comes back empty, check the thinking field first.
What a local LLM token costs
Local inference has no invoice, but it is not free. LLM Vault therefore lets you attach an estimated price to a local alias, and it marks those costs as estimates everywhere.
A simple way to derive the price uses three numbers: power draw, generation time and tokens. For example, assume the GPU draws 300 W while generating. The llama.cpp run produced 1,244 tokens in 39.8 s, which is about 3.3 Wh. That works out to roughly 2.7 kWh per million tokens. At 0.30 USD per kWh, the estimate becomes about 0.80 USD per million tokens. The 300 W figure is an assumption here, not a measurement, so replace it with your own meter reading.

The cost formula is the same for every alias. Uncached input, output and cached input each have their own price per million tokens. Furthermore, every request stores the price version it used, so a later price change never rewrites history.
Mix local and cloud models behind one LLM gateway
The real payoff comes when local and cloud aliases share the same gateway. A script then picks a model by name, and the vault handles keys, consent and accounting for both.
Consider a nightly batch of 10,000 ticket summaries. Each call sends about 2,000 input tokens and returns 300 output tokens. On foundry-glm, priced at 2.00 USD per million input and 8.00 USD per million output tokens, the batch costs 10,000 × 0.0064 = 64 USD. On the local alias with the 0.80 USD estimate from above, the same 23 million tokens cost about 18 USD in energy. In other words, the local run is roughly 70% cheaper, but only if the small model’s summaries are good enough.
That last condition is the whole point of measuring. Because both runs go through the same gateway, the dashboard compares them on equal terms: same token counting, same project label, same report. As a result, the decision rests on numbers instead of a feeling that “local is free”.
A practical pattern is to give each batch job two aliases. For example, the job tries qwen-local first and escalates hard cases to foundry-glm. The client token allows both aliases, while the daily budget caps the cloud spend. Consequently, a bug that escalates every request cannot burn more than the budget.
Reproduce the measurements
The live tests are part of the LLM Vault test suite but skipped by default. Start the servers, then run:
ollama pull qwen3:0.6b
llama-server -m model.gguf --port 8080 --jinja
cargo test --test live_local -- --ignored --nocapture
Each test creates a throw-away vault, a provider, a model alias and a pre-approved client token. Then it compares a direct call with a call through the gateway and prints the table above. In addition, it asserts that the audit log recorded the request with reported usage.
When a local LLM gateway is worth it
- Several tools share one GPU box, and you want to know which agent uses it most.
- A script should switch between a local and a cloud model without code changes.
- The local server runs on a LAN machine, and you do not want it open to every device.
- You plan to replace a paid model and need comparable token counts first.
Frequently asked questions
Does a gateway slow down local models?
Barely. I measured about 7 ms on Ollama and 42 ms on llama.cpp, both well below 1% of the generation time.
Which local servers work with LLM Vault?
Ollama, LM Studio, llama.cpp, vLLM, SGLang and any server that implements /v1/chat/completions. Ollama additionally works on /v1/messages.
Why is my model’s answer empty?
A reasoning model probably used the whole max_tokens budget for thinking. Raise the limit or disable thinking with /no_think.
What if the LM Studio server does not start?
Run lms server status, then start the server from the Developer tab and check that nothing else uses port 1234. Alternatively, run the same GGUF file with llama-server, because LM Studio uses the llama.cpp engine and the API is identical.
What if the Ollama CLI does not respond?
Check the HTTP API first: curl http://127.0.0.1:11434/api/tags. If it answers, the server is fine, and the gateway talks to the API, not to the CLI.
Does Claude Code work with a local model through the vault?
Yes, when the alias is served by Ollama. Ollama speaks the Anthropic Messages API, and the vault passes /v1/messages through to it with usage tracking.
Can I expose a local server on my LAN safely?
Keep the model server on localhost and run the gateway on the LAN instead. LLM Vault accepts plain HTTP to a LAN host only after an explicit opt-in per provider.
How are local costs calculated?
You set an estimated price per million tokens, for example from your energy cost. Reports keep those values flagged as estimates.
Summary
A local LLM gateway gives Ollama, LM Studio and llama.cpp one endpoint, one credential and one audit trail. In my runs, LLM Vault added about 7 ms to a 1,087 ms Ollama call and 42 ms to a 39,846 ms llama.cpp generation. Streaming, tool calls and the Anthropic-format endpoint all passed through. The main pitfall sits in the model, not the gateway: reasoning models can spend the whole token budget on thinking.
LLM Vault itself is free and open source. The installer, the portable version and the example scripts from the videos are on the LLM Vault download page.
The download bundle local-llm-gateway-ollama-lm-studio-llama-cpp.zip contains the live test file, the raw measurement notes and the provider presets used above.
Companion code — the fragments above are the working parts: the port probes behind local server detection, the server start commands and the test command that reproduces the latency table.
Free ebook
Free AI Video, Generated Locally
Run Wan 2.1 in ComfyUI on your own GPU — the scripts I use, measured times, sample clips. No cloud, no API keys.
No spam. Unsubscribe at any time.


Leave a Reply