How Close Can One Box Get to a Hosted LLM API?

•14 min read
architecturedevopsaiagentic-aiperformance

Most of my agent and coding work runs against hosted APIs: Anthropic directly, or OpenRouter when I want to switch models without changing code. In March I wrote about running Ollama on a DGX Spark, which was me playing with local use cases. This is a different exercise. I wanted to know what it takes to build something robust enough to stand in for a hosted API, the setup a customer would need if their agents can't send data to a cloud endpoint, or that I'd want as a developer who needs local inference to just be there.

So I rebuilt the box around vLLM and LiteLLM and held it to the standard of the thing it replaces. The short answer: the API surface gets very close, the speed is better than I expected, and the gap is in model choice and in the operations you now own.

What a hosted API actually gives you

It's worth listing, because most of it is invisible until you have to supply it yourself:

  • One stable endpoint, with model names decoupled from whatever is serving them
  • API keys per client, with rate limits and usage tracking
  • A catalog of models that are all available at once
  • Throughput that holds up under concurrent requests
  • Structured output and tool calling that agent frameworks can rely on
  • Someone else running it, patching it, and watching its dependencies

I'll take these in order.

The endpoint

The Spark is an ARM64 box with a GB10 chip and 128GB of memory shared between CPU and GPU (the OS reports 121GiB). The stack on it:

  • vLLM serves the models, one container each, all NVFP4 quantized: Qwen3.6-35B-A3B as the default, Qwen3-Embedding-0.6B for embeddings, Nemotron-3-Super-120B for heavy reasoning.
  • LiteLLM is the gateway. Clients request an alias (local, local-agent, local-reasoning, local-embed) and never see a checkpoint name.
  • Traefik terminates TLS with Let's Encrypt certificates, and Pi-hole resolves the hostname on my network1.
  • Prometheus and Grafana watch all of it.

Architecture: laptops, coding agents and agent runtimes reach one HTTPS endpoint on a DGX Spark. Traefik terminates TLS, a LiteLLM gateway backed by Postgres maps aliases to vLLM backends that accept only the gateway's key, and Prometheus and Grafana collect metrics, including per-model GPU memory from a custom exporter. The 120B reasoning model is loaded on demand and replaces the default.

A client needs a base URL ending in /v1 and a key. Anything that speaks the OpenAI API works unchanged, and I can swap the model behind local-agent without touching a single client. On this point the local setup is equivalent to OpenRouter.

Grafana Inference Hub dashboard showing backend status, live request rate, tokens per second, and requests broken down by model alias and by API key

It did not work the first time. The compose file had sat for a month, and the first real start failed three ways in five minutes: vLLM had replaced --task embed with --runner pooling; my ARM64 LiteLLM image was missing prometheus_client and crash-looped 26 times; and the gateway aliases pointed at Hugging Face checkpoint paths when vLLM only answers to its --served-model-name, so every request returned a 404 from a healthy model. None of that is hard. All of it is invisible until something real calls the endpoint.

Keys, limits, and usage

With a hosted API this is a settings page. Here it is a database.

Without Postgres, LiteLLM has exactly one credential, the master key. Scoped, revocable keys with rate limits need its database-backed key system, and on ARM64 the Prisma client needed two fixes in my image: installing libatomic1, and running prisma generate against LiteLLM's bundled schema at build time. With that in place I can issue a key per agent, restrict it to specific aliases, cap its request rate, and see its token usage in Grafana. That matters more locally than it does in the cloud. My default model runs four sequences at a time, so one misbehaving client can occupy the whole box.

Grafana panels showing per-key spend and token usage rate, with separate lines for each API key such as personal-laptop and coding-agent

The backends needed their own lock. I had joined the vLLM containers to the monitoring network so Prometheus could scrape them, which also let any container on that network call the models directly, bypassing the gateway. Each backend now requires an --api-key that only LiteLLM holds. Being reachable and being authorized are separate properties, and a hosted provider handles the second one for you without you noticing.

Throughput

My first dashboard numbers were poor, so I measured properly. Each figure is the change in vLLM's decode-time counter around one identical request (300 completion tokens, temperature 0), which excludes prompt processing, queueing, and the network.

ChangeDecode speedvs. baseline
Starting config (--enforce-eager)9.4 tok/s
Remove --enforce-eager (CUDA graphs on)43.9 tok/s4.7x
Add MTP speculative decoding60.1 tok/s6.4x
--max-num-batched-tokens 409664.4 tok/s6.9x

I had set --enforce-eager as the cautious choice for new hardware. The published vLLM recipe for this model and chip doesn't use it, and removing it caused no instability. MTP (multi-token prediction) lets the model draft a few tokens ahead and verify them in one pass; the Qwen checkpoint ships with the layers for it, so there was nothing extra to download2. The recipe's reference figure is 97.7 tok/s. I'm at about 66% of that in single-stream decode and haven't found the rest.

Under concurrency the picture improves. With four requests in flight, two bursts measured 171 and 253 tok/s in aggregate, because continuous batching spreads per-step overhead across sequences. That is two data points at one concurrency level, so I'd call it a direction until I run a proper sweep. In day-to-day use I see around 125.

Grafana panels under sustained mixed traffic: generation tokens per second climbing past 100, p95 time to first token, and queue depth per backend

The queue-depth panel shows where the ceiling is. Under sustained mixed traffic, p95 time to first token sits around a quarter of a second, and it jumps to about four seconds in the minute where requests start waiting.

For a single developer or a handful of agents, that is enough that inference speed stops being the thing I notice. The ceiling is the difference from a hosted API: four concurrent sequences is my configured limit, and there is no second box behind it.

Agent-shaped requests

Agent frameworks lean on structured output, so I tested the request shape one of mine sends: a chat completion with a json_schema response format, against the Nemotron alias. The response was clean JSON matching the schema, finish_reason: stop, nothing leaked into a reasoning field.

The reason it was clean is worth knowing. vLLM's guided decoding constrains output to the schema from the first token, so a reasoning model never gets to emit its reasoning. You get a valid answer from a 120B model that was prevented from doing the thing it is tuned for. For that request shape, the smaller default model is the better choice, and it is always loaded.

I've only verified a trivial schema. A real one with nested objects, arrays, and enums is where grammar compilation tends to fail, and I haven't run that test yet.

The model catalog

This is the largest gap, and no amount of tuning closes it.

A hosted API has every model warm. I have one memory pool. The Nemotron checkpoint is 74.8GB and takes 80% of that pool, so it cannot share the box with the default model. Switching is a deliberate act: a Make target stops one set and starts the other, and a cold load takes on the order of ten to twenty minutes depending on the model.

My first attempt at that switch nearly took the host down. My budget said stopping the default set would leave about 105GB free. The load started with 33GB, because the Spark is also my desktop and a browser, GNOME, and several Claude Code sessions were holding the difference. Swap climbed to 13GB of 15GB before I stopped it. After I closed the desktop session, the second attempt loaded with swap under 3GB.

Part of why I misjudged it: the usual tools can't see GPU memory on this chip. docker stats and process RSS agreed on roughly 10GB in use while the real figure was about 70GB, and the device-level nvidia-smi memory query returns N/A. The per-process query works:

nvidia-smi --query-compute-apps=pid,process_name,used_memory --format=csv

It returns a PID with no hint of which model that process serves, so I wrote a small Prometheus exporter (standard-library Python) that walks /proc from each PID to its parent and reads --served-model-name off the command line. Grafana now shows memory per model, which DCGM can't do on this hardware3.

Grafana panel showing GPU memory per served model on the DGX Spark, with the Qwen3.6 35B backend holding most of the pool and the embedding model a small slice

Then there is model quality. A 35B open-weight model is useful and fast, and I haven't benchmarked it against the hosted models I use, so I won't claim a number. I still send my hardest work to a hosted API. The local box takes the high-volume, lower-stakes loops where zero marginal cost and data staying put matter more.

The operations you inherit

The last item on the list is the one a hosted API hides best.

Health is yours to define. After I put API keys on the backends, I updated the healthcheck for two of the three. The Nemotron container reported "unhealthy" for hours while serving requests correctly, because its healthcheck was collecting a 401. That overlapped with the memory problem above, and I blamed both on memory.

The gateway is a supply-chain target. LiteLLM shipped compromised releases twice in 2026: versions 1.82.7 and 1.82.8 in March, and 1.107.0 in October, which also reached the latest Docker tags for a few hours. Both carried credential stealers. My image pins 1.103.2, which falls between them, and confirming that took five minutes. A hosted provider doesn't remove this risk; it moves the release pipeline you're trusting to theirs. Running it yourself means the watching is your job.

So what? How close is it?

What a hosted API gives youLocal equivalentHow close
Stable endpoint, model aliasesLiteLLM over vLLMEquivalent
Per-client keys, limits, usageLiteLLM with PostgresEquivalent, after ARM64 fixes
Throughput64 tok/s single stream, 170 to 250 aggregate at four concurrentClose for one team; hard ceiling
Structured outputjson_schema via guided decodingWorks on a simple schema; complex schemas untested
Model catalogOne resident tier at a timeFar
Frontier model quality35B-class open weightsNot measured; I keep a hosted model for the hardest work
Operations and securityYouThis is the price

If this decision is landing on your desk, what I'd plan for:

  • The API contract is the easy part. An OpenAI-compatible gateway with keys and usage tracking is a few days of work, most of it finding what your platform's images are missing.
  • Memory is the real capacity plan. On unified-memory hardware, decide which models are resident and treat switching as an operation with a duration. Read free memory from the driver, just before you load.
  • Tune before you judge. One flag was worth 4.7x. Benchmark against a published reference for your model and hardware, and measure decode time directly.
  • Pick your throughput metric. Single-stream speed and aggregate throughput under concurrency are different numbers, and a wall-clock dashboard panel will show you a third4.
  • Staff the watching. Version pins, advisories, healthchecks, and auth on every internal surface are now yours.

I'd build it again, and I'd still keep a hosted API key.

What I'd test next

Near term: a concurrency sweep, the complex-schema test, and a side-by-side of a few other models in the same size class as the default.

Reading other people's dual-Spark write-ups turned up one number that reorders that list. Someone instrumented a real coding-agent session and logged 252,173 prompt tokens against 2,012 output tokens, about 170 to 15. If my traffic looks like that, the decode speed I spent a day tuning barely matters and prefill is the whole game. Three flags I haven't touched:

  • Prefix caching (--enable-prefix-caching). Agent traffic resends a long, stable system prompt every turn, which is the shape this reuses. It cuts prefill, so it should show up in time to first token rather than tok/s.
  • FP8 KV cache (--kv-cache-dtype fp8). Halves the bytes per cached token, which converts into context length or concurrent sequences out of the pool that is my binding constraint.
  • Chunked prefill. A long prompt monopolizes a step while decodes wait, which explains a p95 time to first token of four seconds better than queue depth does.

Further out, a second Spark, where the nominal spec oversells the link. Two boxes connect over ConnectX-7 at 200Gb/s rather than NVLink, and measured NCCL all-reduce across a directly cabled pair lands at 10.2 GB/s, with raw RDMA at 24.6 GB/s6. A single box reads its own memory at 273 GB/s.

I assumed that made splitting a model across the link a straight loss. The published A/B runs show a gain, and the reason is mechanical: decode is bandwidth-bound, tensor parallelism shards the weights, and each box then reads half of them per step against its own 273 GB/s. One pair measured single-stream decode at 21.1 tok/s across two boxes against 12.4 on one, which is 1.71x7.

The size of that gain is the part that applies to me. It tracks how hard a model leans on memory bandwidth, so dense models gain and sparse MoE models gain much less, because an MoE reads only its active parameters per token and never saturated one box to begin with. My default is Qwen3.6-35B-A3B, 3B active. For the model I actually serve, a second Spark is a capacity purchase for checkpoints over 128GB rather than a speed purchase.

Two things I'd want settled before spending the money: none of those numbers are mine, and upstream vLLM doesn't do multi-node tensor parallelism on a Spark without patching, because its V1 engine hardcodes a loopback address for the NCCL rendezvous. The configuration I'd rather test is prefill on one box and decode on the other, since the two phases are bound by different resources. I'm also talking to hardware vendors through work about testing some alternatives.

Footnotes

  1. Two separate jobs that are easy to conflate. The Cloudflare DNS challenge proves I control the domain so Let's Encrypt will issue a certificate. Resolution inside the network is Pi-hole. The hostname only resolves on my LAN and tailnet, which is deliberate. ↩

  2. A vLLM speculative config with "method": "mtp" and no separate draft model reuses the target model's weights; I confirmed that in vllm/config/speculative.py. Draft acceptance was 52% overall, falling from 74% on the first speculated token to 35% on the third. ↩

  3. The per-process numbers were 63.4GB for Qwen and 6.8GB for the embedding model. The Qwen checkpoint is about 22GB on disk; vLLM preallocates KV cache up to --gpu-memory-utilization (0.55 here), so holding 63GB is the setting doing its job. ↩

  4. During light test traffic my tokens-per-second panel read 5 while the model was decoding at about 120 whenever it was working. The panel was dividing by idle time. ↩

  5. From a two-Spark write-up that sampled real coding-agent sessions instead of a benchmark harness, which is how they caught it. Their argument is that generation throughput is the wrong headline number for agent traffic, and the ratio is why. ↩

  6. Measured with nccl-tests and ib_write_bw on a directly cabled pair: 10.2 GB/s all-reduce, about 9 GB/s sendrecv, 24.6 GB/s raw RDMA. Pipeline parallelism is the usual advice when an interconnect is slow, but sendrecv measuring about the same as all-reduce means it buys less here than it would on a faster fabric. ↩

  7. 21.11 against 12.36 tok/s, which that author puts at 85.4% scaling efficiency (source). A different model and harness, Qwen3.8-Flash-Next at NVFP4, shows a smaller gain: 51.9 against 41.7 tok/s, up 24.5%. The spread across models is the point. ↩