Overview

The Allternit Local Engine is a self-hosted service that downloads model weights from the Hugging Face Hub, keeps them in a local cache, and manages the lifecycle of local inference backends. It exposes a small HTTP API for model download/import, runtime launch/stop, hardware status, and a /v1/chat/completions proxy that routes requests to a healthy backend serving the requested model.
Models, runtime logs, and inference traffic stay on the host. Nothing is sent to Allternit-managed inference endpoints unless you explicitly route traffic through them.

Base URL

Local development (default):
The host and port can be changed with environment variables:

What it does

  1. Model cache — tracks downloaded and imported models with their byte-level progress, status, and local paths.
  2. Hugging Face downloads — verifies the repo, filters out non-essential files, resumes partial downloads, and validates safe filesystem paths.
  3. Local imports — registers models already on disk, including exports produced by Unsloth training jobs.
  4. Runtime manager — spawns inference backends on a free port, polls their health endpoint, and captures logs.
  5. Chat proxy — forwards /v1/chat/completions requests to the correct healthy runtime using the model field.
  6. Host diagnostics — reports CPU, RAM, disk, and GPU information so clients can pick compatible models.

Installation

The Local Engine is a Rust binary in the Allternit workspace.
Or from the workspace root:

Requirements

  • Rust toolchain (workspace edition 2021)
  • For the llama.cpp backend, llama-server must be on PATH
  • Sufficient disk space under the OS data directory for cached models
The service creates two directories on startup:
{data_dir} is dirs::data_dir() on your platform (for example, ~/Library/Application Support on macOS or ~/.local/share on Linux).

Endpoints

Model cache

Every cached model has a stable local ID derived from the source repo, revision, and optional quantization suffix:
For example, meta-llama/Llama-2-7b-hf at main becomes:

Model status values

List cached models

Response:

Download a model

Response:
The download runs in the background. Poll /models to watch downloaded_bytes and status. The engine filters the Hugging Face tree to keep only config/tokenizer files and weight files (.safetensors, .bin, .gguf, .mlx, .pt, .pth), while skipping READMEs, images, and metadata files. Partial .part files are resumed when possible.

Import a local model

Use this for weights already on disk or for Unsloth exports.
Response:
source can be local_path or unsloth_output. The path must be a directory.

Launch a runtime

A recipe tells the engine which backend to spawn and how to configure it.
Response:
The engine allocates a free port on 127.0.0.1, spawns the backend, and polls its /health endpoint for up to 30 seconds. Once healthy, status becomes running. Logs are written to {data_dir}/allternit-local-engine/logs/runtimes/{runtime_id}.log.

Supported backends

The recipe schema supports four backends. Today, llama_cpp is fully implemented; the others are reserved for future releases.

Recipe fields for llama.cpp

List and stop runtimes

List runtimes

Response:

Stop a runtime

Response:

Chat completions proxy

Once a runtime is running, send chat completion requests through the Local Engine. The proxy reads the model field, finds a healthy runtime serving that model ID, and forwards the request to the backend.
The response shape is whatever the backend returns, so it works with any client that speaks the standard /v1/chat/completions schema.

Service status and diagnostics

Response:
GPU detection uses system_profiler on macOS and nvidia-smi on Linux. On Apple Silicon, GPU memory is reported as shared system memory.

Error codes