Skip to main content

slim-serve

SLIM — Small Language Inference Machine. An OpenAI-compatible streaming server for local small language models (llama.cpp GGUF, MLX), with admission control, deadlines, cancellation and Prometheus metrics.

GitHub · Full README · Architecture · Benchmarks · Changelog

Install

pip install "slim-serve[llama]" \
  --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu   # prebuilt CPU wheel

On Apple Silicon, pip install "slim-serve[mlx]" installs the MLX backend instead. Without the extra index, pip builds llama-cpp-python from source, which needs a C++ compiler.

Quick start

curl -L -o qwen.gguf \
  https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct-GGUF/resolve/main/qwen2.5-0.5b-instruct-q4_k_m.gguf
slim-serve serve --model qwen.gguf          # http://127.0.0.1:8000

No model? SLM_ENGINE=fake slim-serve serve serves deterministic fake tokens through the same stack.

The OpenAI Python SDK works against it as is:

from openai import OpenAI

client = OpenAI(base_url="http://127.0.0.1:8000/v1", api_key="unused")
for chunk in client.completions.create(model="any", prompt="Hello", max_tokens=32, stream=True):
    print(chunk.choices[0].text, end="", flush=True)

What you get

  • POST /v1/completions, streaming (SSE) and non-streaming, plus GET /v1/models.
  • Inference on a dedicated thread per model replica, never on the event loop.
  • A bounded queue that fails fast with 503 + Retry-After instead of piling up latency.
  • One deadline per request; timeouts and client disconnects stop generation within a token.
  • /healthz (liveness) and /readyz (model loaded), so orchestrators route correctly.
  • Prometheus metrics that separate queue wait, time to first token and decode speed.

It doesn't batch sequences: for raw GPU throughput, use vLLM or llama-server. Why, and where it breaks down.

Configuration

SLM_* environment variables, a .env file, or serve flags (which take precedence):

Variable Default Meaning
SLM_ENGINE llama_cpp llama_cpp, mlx or fake
SLM_MODEL_PATH models/qwen2.5-0.5b-instruct-q4_k_m.gguf GGUF file, or MLX model dir / HF id
SLM_REPLICAS 1 Independent model copies, each with its own thread
SLM_MAX_QUEUE_SIZE 32 Requests that may wait before 503
SLM_REQUEST_TIMEOUT_S 120 Deadline covering queue wait and generation
SLM_HOST, SLM_PORT 127.0.0.1, 8000 Bind address

All settings · slim-serve info prints the detected hardware and effective configuration.

Learn more

MIT licensed.

Metadata

Release files for slim-serve 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for slim-serve 0.1.1
File Size Uploaded
slim_serve-0.1.1.tar.gz 216.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for slim-serve 0.1.1
File Interpreter ABI Platform
slim_serve-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 238.1 kB

Release files / slim_serve-0.1.1.tar.gz

Download URL slim_serve-0.1.1.tar.gz
Size 216.1 kB
Tags Source
SHA-256 checksum
How to use checksums
cc2496a0ac63634909dfb3ff5e951ff98cd2d4252bf3981cbeb95f8b95f79dff
BLAKE2b-256 checksum
How to use checksums
8ac7abd30bcdb71f8aca52ff5bc915e0535b9218dd93ef53860a26dd949fd3a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.24

Release files / slim_serve-0.1.1-py3-none-any.whl

Download URL slim_serve-0.1.1-py3-none-any.whl
Size 22.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f8a945ea20eba15502e098ec8b13f4cf38fd3f6111f5afb935de5f30198a1d17
BLAKE2b-256 checksum
How to use checksums
2a106d009160a76d0035d5918355c9f3e8a6f8f7b35e4ebd46986c8c4c0881f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.24

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page