llama-skein — fork of mostlygeek/llama-swap for the Skein ecosystem.
Adds: /api/resources, /api/storage, model lifecycle API, mDNS registration, ROCm targets, slot-cancel on disconnect, autoUnload.
Ecosystem map: ECOSYSTEM.md (this repo) · ~/dev/skein/docs/ECOSYSTEM.md (sibling checkout, if present)

llama-skein
Why this exists
You want to run OpenRouter models and your own open-weight models on the GPUs in your
homelab, but you also want Claude Code — and Anthropic won't let you route their
subscription through a third-party harness. So you end up running two agent
harnesses side by side, and now they fight over the same VRAM and OOM each other
independently.
llama-skein is the inference layer that makes the local half of that setup
usable: a single static Go binary that fronts llama.cpp (and other
OpenAI-compatible engines) on every GPU host, hot-swaps models on demand so you
don't need one process per model sitting idle in VRAM, and unifies local models
with remote ones (e.g. OpenRouter) behind one OpenAI-compatible endpoint via its
peers config. It also exposes hardware-aware resource/storage/lifecycle APIs and
advertises itself over mDNS, so other agent runners on the LAN can find it — and
each other — without hardcoded addresses or manual VRAM bookkeeping.
It's one of three repos in the Skein ecosystem:
skein (supervisor) → opencode-skein (agent runner) → llama-skein (this repo: inference proxy)
- opencode-skein — "opencode, tuned
for people who run their own models." It's llama-skein's main consumer: it
discovers llama-skein instances on the LAN via mDNS, shows live per-host VRAM
usage, and asks llama-skein to load/unload models instead of guessing.
- skein — the supervisor that routes requests across the fleet and gives you
one place to see everything running.
llama-skein works standalone too — point any OpenAI-compatible client at it — but
it's built to be the thing the rest of the fleet discovers and shares.
It is a fork of mostlygeek/llama-swap — everything llama-swap does, this repo does too, plus the extensions below.
Divergence from upstream
llama-skein tracks mostlygeek/llama-swap via make upstream-check / rebase (see ECOSYSTEM.md) and adds:
GET /api/resources — unified GPU/CPU/RAM snapshot
GET /api/storage — model dir disk usage
POST /api/models/pull — HuggingFace model download with streaming progress
DELETE /api/models/:id — unload + delete weight file
PATCH /api/config/models/:id — live model config patch (ctx-size, n_gpu_layers)
POST/DELETE /api/config/models — add/remove models at runtime
GET /api/config/info — config path + file existence
- mDNS registration (
_llamaswap._tcp.local.) on startup
- Ollama-compat endpoints
- HTTP 413 on context size exceeded
context_length / max_output_tokens in /v1/models
autoUnload config for model groups
- Slot-cancel on client disconnect (prevents zombie GPU allocations)
- ROCm build targets for AMD GPUs on inference hosts
See ECOSYSTEM.md for the full ecosystem map and upstream-sync workflow, and contracts/llama-skein.openapi.json for the control-plane API contract (design-first source of truth; not duplicated here). Fleet-specific deploy details (host IPs, container topology) intentionally live outside this public repo, in the private companion repo docs-skein — ECOSYSTEM.md's "Deploying" section has the clone instructions and where to look once you have it.
Everything below this point is inherited from upstream llama-swap and describes functionality both projects share.
Features (inherited from llama-swap):
- ✅ Easy to deploy and configure: one binary, one configuration file. no external dependencies
- ✅ On-demand model switching
- ✅ Use any local OpenAI compatible server (llama.cpp, vllm, tabbyAPI, stable-diffusion.cpp, etc.)
- future proof, upgrade your inference servers at any time.
- ✅ OpenAI API supported endpoints:
v1/completions
v1/chat/completions
v1/responses
v1/embeddings
v1/models - list available models
v1/audio/speech (#36)
v1/audio/transcriptions (docs)
v1/audio/voices
v1/images/generations
v1/images/edits
- ✅ Anthropic API supported endpoints:
v1/messages
v1/messages/count_tokens
- ✅ llama-server (llama.cpp) supported endpoints
v1/rerank, v1/reranking, /rerank
/infill - for code infilling
/completion - for completion endpoint
- ✅ SDAPI via stable-diffusion.cpp's server
/sdapi/v1/txt2img
/sdapi/v1/img2img
/sdapi/v1/loras - requires model in request body to fetch the correct loras
- ✅ llama-swap API (inherited; llama-skein adds its own control-plane API on top, see Divergence above)
/ui - web UI
/upstream/:model_id - direct access to upstream server (demo)
/running - list currently running models (#61)
POST /api/models/unload - manually unload all running models (#58)
POST /api/models/unload/:model_id - unload a specific model
/logs - remote log monitoring
GET /logs returns buffered plain text logs.
- If
Accept: text/html is sent, /logs redirects to /ui/.
GET /logs/stream keeps the connection open for live log streaming.
- Stream endpoints send buffered history first by default; add
?no-history to stream only new lines.
GET /logs/stream/proxy streams proxy logs only.
GET /logs/stream/upstream streams upstream process logs only.
GET /logs/stream/{model_id} streams logs for one model (including IDs with slashes, like author/model).
/health - just returns "OK"
/metrics - system and GPU metrics for prometheus
- ✅ API Key support - define keys to restrict access to API endpoints
- ✅ Customizable
- Run concurrent models with a custom DSL swap matrix (#643)
- Automatic unloading of models after timeout by setting a
ttl
- Docker and Podman support using
cmd and cmdStop together
- Preload models on startup with
hooks (#235)
- Apply filters to requests to control inference with
stripParams, setParams and setParamsByID
Web UI
llama-swap includes a real time web interface with a playground for testing out all sorts of local models:
View detailed token metrics:
Inspect request and responses:
Manually load and unload models:
Real time log streaming:
Installation
llama-skein is a fork and does not publish to upstream's Docker/Homebrew/WinGet channels — those install upstream llama-swap, which does not have the fork extensions listed above. The supported way to run llama-skein is building from source.
Building from source (primary install path)
- Building requires Go and Node.js (for the UI, in
ui-svelte/).
git clone https://github.com/androidand/llama-skein.git
cd llama-skein && make clean all
- look in the
build/ subdirectory for the llama-skein binary
Upstream channels (llama-swap, not this fork)
The channels below install mostlygeek/llama-swap, not llama-skein. They do not contain /api/resources, /api/storage, the model lifecycle API, mDNS registration, ROCm targets, or any other fork extension. Listed here only so it's clear what they are, in case you land on this README while looking for upstream:
- Docker:
ghcr.io/mostlygeek/llama-swap (images)
- Homebrew:
brew tap mostlygeek/llama-swap && brew install llama-swap
- WinGet:
winget install llama-swap (community-maintained, not official)
- Pre-built binaries: mostlygeek/llama-swap releases
Configuration
# minimum viable config.yaml
models:
model1:
cmd: llama-server --port ${PORT} --model /path/to/model.gguf
That's all you need to get started:
models - holds all model configurations
model1 - the ID used in API calls
cmd - the command to run to start the server.
${PORT} - an automatically assigned port number
Almost all configuration settings are optional and can be added one step at a time:
- Advanced features
matrix to run concurrent models with a custom swap logic DSL
hooks to run things on startup
macros reusable snippets
- Model customization
ttl to automatically unload models
aliases to use familiar model names (e.g., "gpt-4o-mini")
env to pass custom environment variables to inference servers
cmdStop gracefully stop Docker/Podman containers
useModelName to override model names sent to upstream servers
${PORT} automatic port variables for dynamic port assignment
filters rewrite parts of requests before sending to the upstream server
See the configuration documentation for all options.
Running MLX models on Apple Silicon? See
Apple Silicon / MLX for backend: mlx setup, the Metal
memory ceiling (iogpu.wired_limit_mb) that governs what fits, and how to
recover a host that's run low on memory.
How does llama-skein work?
When a request is made to an OpenAI compatible endpoint, llama-skein will extract the model value and load the appropriate server configuration to serve it. If the wrong upstream server is running, it will be replaced with the correct one. This is where the "swap" part comes in (inherited from llama-swap). The upstream server is automatically swapped to handle the request correctly.
In the most basic configuration llama-skein handles one model at a time. For more advanced use cases, using a matrix allows multiple models to be loaded at the same time. You have complete control over how your system resources are used.
Reverse Proxy Configuration (nginx)
If you deploy llama-skein behind nginx, disable response buffering for streaming endpoints. By default, nginx buffers responses which breaks Server‑Sent Events (SSE) and streaming chat completion. (mostlygeek/llama-swap#236)
Recommended nginx configuration snippets:
# SSE for UI events/logs
location /api/events {
proxy_pass http://your-llama-skein-backend;
proxy_buffering off;
proxy_cache off;
}
# Streaming chat completions (stream=true)
location /v1/chat/completions {
proxy_pass http://your-llama-skein-backend;
proxy_buffering off;
proxy_cache off;
}
As a safeguard, llama-skein also sets X-Accel-Buffering: no on SSE responses. However, explicitly disabling proxy_buffering at your reverse proxy is still recommended for reliable streaming behavior.
Monitoring Logs on the CLI
# sends up to the last 10KB of logs
$ curl http://host/logs
# streams combined logs
curl -Ns http://host/logs/stream
# stream llama-skein's proxy status logs
curl -Ns http://host/logs/stream/proxy
# stream logs from upstream processes that llama-skein loads
curl -Ns http://host/logs/stream/upstream
# stream logs only from a specific model
curl -Ns http://host/logs/stream/{model_id}
# stream and filter logs with linux pipes
curl -Ns http://host/logs/stream | grep 'eval time'
# appending ?no-history will disable sending buffered history first
curl -Ns 'http://host/logs/stream?no-history'
Do I need to use llama.cpp's server (llama-server)?
Any OpenAI compatible server would work. llama-swap (and this fork) was originally designed for llama-server and it is the best supported.
For Python based inference servers like vllm or tabbyAPI it is recommended to run them via podman or docker. This provides clean environment isolation as well as responding correctly to SIGTERM signals for proper shutdown.
Credit
llama-skein is a fork of mostlygeek/llama-swap by Benson Wong. All credit for the original design and the majority of the codebase goes to the upstream project and its contributors. If you don't need the Skein-specific extensions, use upstream llama-swap directly — it's the more widely used, more broadly supported project.