Run many local AI models behind one API and hot-swap them on demand
open sourceMITself-hostablefree
llama-swap is an MIT-licensed proxy, written in Go, that runs many local AI models behind one OpenAI- and Anthropic-compatible API. Each request's model field picks the inference server to use: llama-swap starts it from the command in its YAML config and stops the one it replaces, with optional idle timeouts. It works with llama.cpp and its forks, vLLM, stable-diffusion.cpp, audio.cpp, ComfyUI and any other OpenAI- or Anthropic-compatible server, passes through chat, embeddings, audio, image and rerank endpoints, and serves a web UI. It ships as one binary with no dependencies.
Ways to install
Package managers
Problems it solves
- only one local LLM fits in my GPU memory but my tools need to call several models
- switch between llama.cpp models automatically based on the model name in an OpenAI API request
- unload a local model after it's been idle so the GPU is free for something else
Features
- starts and stops local inference servers on demand from each request's model name
- OpenAI-compatible endpoints: completions, chat, responses, embeddings, audio, images and realtime
- Anthropic-compatible messages endpoint
- works with llama.cpp, vLLM, stable-diffusion.cpp, ComfyUI and other compatible servers
- one binary and one YAML config file, no dependencies
- web UI and API to list and unload running models
Alternatives
The same job
These do what llama-swap does.
- llama.cpp LLM inference in C/C++
- Ollama Start building with open models, locally or in the cloud
- Xinference Open source inference platform: serve LLMs, embeddings, rerankers, image, audio and video models behind OpenAI-compatible APIs
- vLLM A high-throughput and memory-efficient inference and serving engine for LLMs
- TextGen A desktop app for local LLMs, with a UI and an OpenAI/Anthropic-compatible API
- LocalAI Your own AI, on your own hardware
