Overview
The Local Engine API is a thin, authenticated proxy to the Allternit Local Engine controller (services/local-engine). All routes are mounted under /api/local-engine and forward request bodies and responses verbatim, so the gateway never becomes a second source of model or runtime state.
Use this surface to:
- Inspect the health and host status of the local engine.
- Read the device profile and model memory budget that the on-device fit check uses.
- Manage cached models: list, import from disk, and queue downloads from Hugging Face.
- Launch and stop local model runtimes.
- Call a running local model through a chat-completions-compatible surface.
Base URL
Production:LOCAL_ENGINE_URL, defaulting to http://127.0.0.1:3015.
Authentication
All routes require a valid bearer token in theAuthorization header. Requests without a recognized user receive 401 Unauthorized. See Authentication for details.
Endpoints
Health
Example request
Example response
Status
Example response
/status run with a 2 second time limit each. A probe that fails or runs too long leaves gpu as null. It never fails the request.
Hardware
budget from this route. Engines older than this route return 404. Clients then fall back to /status.
Example request
Example response
Measured on an Apple M1 Pro with 32 GB:Hardware fields
All sizes are bytes.Budget
budget holds kind, fast_bytes and spill_bytes. The rules follow the on-device fit spec (spec/on-device/fit.md):
A discrete GPU whose VRAM could not be read does not set the budget. The device then counts as
unified or cpu.
Engines
Each entry hasid (llama.cpp or mlx), backend (metal, cuda, rocm, vulkan, sycl or cpu), version, pack_id and state.
Engines come from signed engine packs (see Engine packs). An installed pack reports
pack_id, its llama.cpp build or MLX version as version, and ready, or fallback when it is the CPU pack on a device with a usable GPU. With no pack installed, a llama-server found on PATH is used as a development fallback and reports fallback (or installed if it did not answer in time) with pack_id: null. MLX is missing on Apple silicon until its pack is installed, and off elsewhere.
Running models
running lists every loaded model with live numbers. It is also in /status and in each runtime from /runtimes.
A runtime the engine stopped for being idle shows
status: "stopped" and stop_reason: "idle" in /runtimes. Launch it again to reload it.
Caching
GPU and engine probes run outside commands, each with a 2 second time limit, so the engine caches the full report for 5 minutes. If an engine probe timed out (state: "installed"), the next probe comes after 30 seconds. ram_available_bytes, gpus[].vram_free_bytes and disk_free_bytes refresh at most every 3 seconds.
Errors
A failed GPU probe never turns into an error. It only makes
gpus shorter.
Engine packs
ensure picks the pack from the device: Metal on Apple silicon, CUDA for NVIDIA with a working driver (else Vulkan), ROCm for AMD on Linux when ROCm is installed (else Vulkan), Vulkan for Intel, CPU first on Windows on Arm, else CPU. The body is optional: {"engines": ["llamacpp", "mlx", "colibri"], "update": false} (the default is all three). colibri has one CPU pack per device: colibri-linux-x86_64, colibri-linux-aarch64, colibri-windows-x86_64 or colibri-macos-arm64; Intel Macs and Windows on Arm get none, and its engine entry is off. update: true also installs a newer version of a pack that is already installed. The call returns at once with 202 when it started an install (200 when nothing was needed). Progress is in jobs here and in engine_packs in /status.
jobs[].state is queued, downloading, verifying, installed or failed (with error). A launch while no pack is installed fails with 501 and a message that names the pack to install. A pack that fails its check at launch fails with 503.
List models
Example response
Model object fields
Import a model
Request body
Example request
Example response
Download a model
Request body
Example request
Example response
allow_unverified is true. A failed download can be retried with the same request.
Verify a model
ok: false and the model is marked failed.
Request body
Older engine builds return 404 for this route. Clients show “Not checked by this version”.
List runtimes
Example response
Runtime object fields
Launch a runtime
GET /api/local-engine/runtimes to wait for status: "running".
Request body
Recipe variants
Therecipe object is a tagged union keyed by backend.
Example request
Example response
Stop a runtime
status: "stopped".
Path parameters
Example request
Example response
Chat-completions models list
Example response
Chat completions
model. Both non-streaming and streaming (stream: true) requests are supported; streaming responses are returned as server-sent events.
The request body is forwarded as sent, so all standard chat-completions options—temperature, max_tokens, tools, response_format, and stream—are supported when the underlying backend accepts them. Streams pass through token by token.
Token numbers
Every reply carries real numbers in anallternit object: tok_per_sec, first_token_ms, ctx_used, ctx_max and mem_bytes. On a non-streaming reply it sits next to usage. On a stream, set stream_options.include_usage: true to get a final chunk with choices: [], the standard usage (prompt_tokens, completion_tokens) and the allternit object. Without it the engine still reads the numbers (they show in running), but sends no usage chunk. llama.cpp replies also keep their timings object (predicted_per_second, prompt_ms); the MLX engine sends the same fields.
Request body
Example request
Example response
Streaming example
Setstream: true and Accept: text/event-stream to receive incremental deltas:
Error codes
Upstream status codes and response bodies are forwarded transparently whenever possible, so a
400 from the controller is returned as a 400 to the caller.
Related pages
- Local Brains API — Ollama-based local memory and sidecar models
- Models — gateway model catalog and policy aliases
- Chat Completions — hosted gateway chat-completions surface
- Runtime Backend API — configure local, BYOC, and remote runtimes
- Runtime Discovery API — probe local runtime instances
- Authentication — virtual keys and bearer tokens