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 development (against the Allternit API server):
The API server proxies requests to the Local Engine controller at the URL configured by LOCAL_ENGINE_URL, defaulting to http://127.0.0.1:3015.

Authentication

All routes require a valid bearer token in the Authorization header. Requests without a recognized user receive 401 Unauthorized. See Authentication for details.

Endpoints

Health

Returns the controller’s health and version.

Example request

Example response

Status

Returns host-level diagnostics, including active runtimes, cached models, CPU, RAM, disk, and GPU information when available.

Example response

GPU probes in /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

Returns this device’s profile and the memory budget for loading models. Every client’s on-device fit check (Desktop, web, Gizzi) reads 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 has id (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

Inference engines are not in the Desktop installer. The local engine downloads them as signed engine packs: llama.cpp builds per OS and GPU (Metal, CUDA, ROCm, Vulkan, CPU) and, on Apple silicon, the MLX engine. Before any engine starts, the local engine checks the pack’s Ed25519 signature and the sha256 of every file. A pack that fails the check is never run. The engine rolls back to the previous version, or removes the pack. 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

Returns every model currently tracked in the local cache.

Example response

Model object fields

Import a model

Imports a model that already exists on disk into the local cache. The path must be a directory and must be accessible to the controller.

Request body

Example request

Example response

Download a model

Queues a download from a Hugging Face repository. The returned state reflects the current tracking entry; the download continues asynchronously.

Request body

Example request

Example response

Every file is fetched through the model source contract. Data with no hash fails unless allow_unverified is true. A failed download can be retried with the same request.

Verify a model

Re-hashes the local files of a downloaded model against the source it was checked against. On a mismatch the response has 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

Returns all runtimes known to the controller, including starting, running, stopped, and errored instances.

Example response

Runtime object fields

Launch a runtime

Spawns a local backend process from a recipe and returns the runtime snapshot immediately. Health is checked in the background; poll GET /api/local-engine/runtimes to wait for status: "running".

Request body

Recipe variants

The recipe object is a tagged union keyed by backend.

Example request

Example response

Stop a runtime

Stops the runtime with the given id. The runtime entry remains in the list with status: "stopped".

Path parameters

Example request

Example response

Chat-completions models list

Returns a chat-completions-compatible model list backed by the local cache.

Example response

Chat completions

Proxies a chat-completions-shaped request to a healthy local runtime serving the requested 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 an allternit 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

Set stream: 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.