Local models
Serve your own models on your own GPUs through Spare. Your hardware answers first; when it's full, requests overflow to the Spare market.
Run any model on your own GPUs and call it through the Spare API, next to Spare's models and your own Claude or OpenAI key. Your hardware answers first. When it's busy or offline, requests can overflow to the Spare market at the live price, so your app never waits on a full server.
- Any model. Whatever you run in vLLM, SGLang, Ollama or another OpenAI-compatible server.
- Free. Requests your GPUs answer cost nothing. Only overflow to the market is billed.
- No open ports. The CLI proxy connects out to Spare from your network.
How it works
- Connect your server. Run the CLI proxy,
spare-proxy, next to it. It registers your model under a name you choose, and reports how much load your server can take. - Call it by name. Your local model's id is
local/<name>. It shows up inGET /v1/modelsfor your key, and works on every endpoint. - Overflow when full. If you set an overflow model, requests go there whenever your server is at its limit or offline.
resp = client.chat.completions.create(
model="local/my-coder",
messages=[{"role": "user", "content": "Write a unit test for parse_date"}],
)The proxy knows your server's load before a request is sent, so a full server doesn't cost a failed attempt: the request goes straight to the overflow model.
Setting up takes three steps: serve the model, write a spare-proxy.yaml for your engine, then
run the proxy.
vLLM
vllm serve Qwen/Qwen3-Coder-30B-A3B-Instruct \
--served-model-name my-coder \
--tensor-parallel-size 2 \
--port 8000- Use any model vLLM supports.
--served-model-nameis the name your server answers to. - vLLM listens on
http://localhost:8000/v1and exposes Prometheus metrics at/metrics, which the proxy reads to know how busy the server is. - Leave prefix caching on. It's on by default in vLLM, and agents that reuse long prompts get much faster.
- Keep vLLM private. The proxy reaches it on localhost, so there's no need to bind vLLM to a public address or open its port.
mode: private
name: my-coder # your model's id becomes local/my-coder
upstream: http://localhost:8000/v1
upstream_model: my-coder # the --served-model-name above
load:
engine: vllm # reads vllm:num_requests_running,
metrics: http://localhost:8000/metrics # vllm:num_requests_waiting, vllm:kv_cache_usage_perc
max_waiting: 4 # full when more requests than this are queued
overflow: deepseek-v4.1-flash # optionalSGLang
python -m sglang.launch_server \
--model-path Qwen/Qwen3-Coder-30B-A3B-Instruct \
--served-model-name my-coder \
--tp 2 \
--port 30000 \
--enable-metrics- Use any model SGLang supports.
--served-model-nameis the name your server answers to. --enable-metricsexposes Prometheus metrics at/metrics, which the proxy reads to know how busy the server is. With a config file (--config config.yaml), setenable-metrics: truethere.- SGLang binds to
127.0.0.1by default. Keep it that way: the proxy reaches it locally. - RadixAttention caches shared prefixes automatically, so agents that reuse long prompts get much faster.
mode: private
name: my-coder # your model's id becomes local/my-coder
upstream: http://localhost:30000/v1
upstream_model: my-coder # the --served-model-name above
load:
engine: sglang # reads sglang:num_running_reqs,
metrics: http://localhost:30000/metrics # sglang:num_queue_reqs, sglang:token_usage
max_waiting: 4 # full when more requests than this are queued
overflow: deepseek-v4.1-flash # optionalOllama
Ollama is the quickest way to run a model on a laptop or a single workstation, with Spare's market as overflow when your machine is busy, asleep or off.
ollama pull qwen3-coder
ollama serveOllama serves an OpenAI-compatible API at http://localhost:11434/v1.
mode: private
name: my-coder # your model's id becomes local/my-coder
upstream: http://localhost:11434/v1
upstream_model: qwen3-coder # the Ollama model name
load:
engine: none # Ollama has no load metrics
max_concurrency: 2 # full above this many requests in flight
overflow: deepseek-v4.1-flash # optionalOllama doesn't publish load metrics, so the proxy counts requests in flight instead. Match
max_concurrency to OLLAMA_NUM_PARALLEL if you've set it.
Run the proxy
docker run -d --name spare-proxy --network host \
-e SPARE_API_KEY \
-v "$PWD/spare-proxy.yaml:/etc/spare-proxy.yaml" \
ghcr.io/spareinference/spare-proxy:latestSPARE_API_KEY is the same key you use to call the API.
Check it works
docker exec spare-proxy spare-proxy statuscurl -si https://api.spareinference.ai/v1/chat/completions \
-H "Authorization: Bearer $SPARE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"local/my-coder","messages":[{"role":"user","content":"Reply with OK"}]}' \
| grep -i '^x-bitrouter-request-id'Open the console's Activity page: the request's model shows local/my-coder when your server answered.
Stop your server and send it again: with overflow set, the request is answered by deepseek-v4.1-flash
instead.
Overflow
Set overflow in the proxy config to send requests to a Spare model when your server can't take them:
overflow: deepseek-v4.1-flashFor a longer chain, such as your server, then Spare, then your Claude model, define it in the CLI; see Fall back to a different model. The console's Activity page shows which model answered each request.
Proxy configuration
mode: private # private, or sell
name: my-coder # private: your model's id becomes local/<name>
upstream: http://localhost:8000/v1
upstream_model: my-coder # the model name your server answers to
load:
engine: vllm # vllm, sglang, or none
metrics: http://localhost:8000/metrics
max_waiting: 4 # vllm, sglang: full above this many queued requests
max_concurrency: 8 # none: full above this many requests in flight
overflow: deepseek-v4.1-flash # private: where requests go when your server is full| Option | Required | What it does |
|---|---|---|
mode | yes | private serves only your own requests. sell also offers spare capacity to the market; see Sell spare capacity |
name | private | Your model's id is local/<name>. Proxies with the same name share the traffic |
upstream | yes | Your server's OpenAI-compatible base URL |
upstream_model | yes | The model name sent to your server |
load.engine | yes | Where load comes from: the engine's Prometheus metrics, or none to count requests in flight |
load.metrics | vllm, sglang | Your server's metrics URL |
load.max_waiting | no | Queued requests above which the server counts as full. Default 4 |
load.max_concurrency | none | Requests in flight above which the server counts as full |
overflow | no | A Spare model to send requests to when your server is full or offline |
Changes to the file are picked up within a few seconds.
docker exec spare-proxy spare-proxy status # connection, load, requests served today
docker exec spare-proxy spare-proxy pause # stop taking requests; in-flight ones finish
docker exec spare-proxy spare-proxy resumeWhile paused, requests to local/<name> go to the overflow model, or fail with a 503 if none is set.
Billing
| Who answered | Cost |
|---|---|
| Your GPUs | Free |
| A Spare model, after overflow | The live price of the window |
| Your Claude or OpenAI model | Billed by your provider, through your key |
Good to know
- Outbound only. The proxy connects to Spare over TLS; your server and its port stay private.
- Your key, your model. Only requests made with keys in your account can reach
local/<name>. - We don't store requests. Bodies pass through Spare to your server without being logged; we keep token counts and timings for your usage records.
- One extra hop. Requests travel from your app to Spare and back to your server, which adds network latency compared with calling your server directly. Run the proxy close to your server.
- Several servers, one name. Run a proxy on each and give them the same name; requests spread across them by load.
- Sell what you don't use. If you serve a model Spare sells with vLLM or SGLang, the same proxy can sell your spare capacity too: serve the exact snapshot Spare lists and declare its precision. Ollama models can be used privately only.
How is this guide?