Skip to content

Deployment & security

dlm serve is a plain HTTP server. In production, require a token, bind deliberately, and terminate TLS at a proxy in front of it.

Authentication

Pass --api-key to require a key on every route except the liveness probes (/, /health, /healthz). Requests without a matching Authorization: Bearer … (OpenAI) or x-api-key (Anthropic) header are rejected with a 401.

That includes GET /metrics, which leaks request and token counts — so a Prometheus scrape needs the key too. Only the liveness probes stay open, which is what lets a load balancer health-check the server without holding a credential.
$dlm serve --model-path /path/to/model --api-key sk-secret
$curl -H 'Authorization: Bearer sk-secret' http://127.0.0.1:8000/v1/models
$curl -H 'Authorization: Bearer sk-secret' http://127.0.0.1:8000/metrics

Bind address

Built-in hardening

Load shedding

Up to --max-batch requests (default 8) decode at once; the rest wait in a queue (on the GPU, until the KV pool can hold a request’s prompt plus max_tokens). By default they wait as long as it takes. --queue-timeout SECS turns away a request that has waited that long with 503 and Retry-After — an HTTP error even for "stream": true, since a response starts only once the request is admitted. A request already decoding always runs to its end. A request’s priority field (OpenAI endpoints, default 0, lowest first) orders the queue; it does not preempt a running request.

$dlm serve --model-path /path/to/model --api-key sk-secret --queue-timeout 30

Monitoring

GET /metrics serves Prometheus counters (requests, prompt and completion tokens, and — when streaming — layer cache hits, misses, evictions and prefetches) and gauges, as of the scheduler’s latest step. The gauges are what to alert or scale on:

--telemetry adds GET /v1/telemetry, a Server-Sent Events stream of per-layer timings and byte counts — no prompt or completion text. Like /metrics, it sits behind --api-key.

TLS via a reverse proxy

dlm serves plain HTTP — it has no built-in TLS. Terminate HTTPS at a reverse proxy (Caddy, nginx) and forward to dlm on localhost.

$ Caddyfile
  api.example.com {
      reverse_proxy 127.0.0.1:8000
  }

Docker

The engine repo has a Dockerfile. Build it from a clone: the image carries the CUDA kernels for Turing to Blackwell (sm_75 to sm_120) with the CUDA runtime linked in, so it needs only the NVIDIA driver, and is 165 MB.

$docker build -t dlm .
$docker run --gpus all -p 8000:8000 -v /path/to/models:/models dlm serve --model-path /models/Qwen2.5-0.5B-Instruct --host 0.0.0.0

Run it as a service

A minimal systemd unit keeps the server running and restarts it on failure:

$ /etc/systemd/system/dlm.service
  [Service]
  ExecStart=/home/USER/.local/bin/dlm serve \
      --model-path /srv/models/model --api-key sk-secret
  Restart=on-failure
  [Install]
  WantedBy=multi-user.target

On Unix, SIGTERM or SIGINT shuts down gracefully: dlm stops accepting connections and drains in-flight requests for up to 8 seconds — inside the 10-second grace period Docker and Kubernetes allow before SIGKILL — so a deploy or systemctl restart doesn’t cut live requests or leave an SSE stream without its final chunk.

Validate the box before going live with dlm doctor — it checks the GPU backend, free VRAM, and that the checkpoint loads.