SwiftLM
A native Swift inference server for MLX models on Apple silicon, with an OpenAI-compatible HTTP API, SSD expert streaming for large MoE models, KV cache compression, and companion SwiftBuddy apps.
View on GitHub ↗- Stars
- ★ 805
- Last commit
- 4 Dec 2026
- Maintenance
- Active
- Licence
- MIT
- Category
- On-device AI SDKs
- GitHub
- SharpAI/
SwiftLM
Overview
SwiftLM is a Swift inference server by SharpAI that runs MLX models on Apple silicon and serves them over an OpenAI-compatible HTTP API. There is no Python runtime in the server path. A typical use is to start the SwiftLM binary with a Hugging Face or local model id and call /v1/chat/completions from any OpenAI-compatible client.
The same project ships SwiftBuddy, a companion app that downloads MLX models and runs them on the device. The README documents an iPhone and iPad source build; the b918 GitHub release also attaches a macOS SwiftBuddy DMG and a self-contained macOS server archive that includes mlx.metallib.
Other local model servers are already listed, including basalt, which also serves MLX models over an OpenAI-compatible API. What sets SwiftLM apart, according to its docs, is SSD expert streaming for large Mixture-of-Experts models, TurboQuant KV cache compression, speculative decoding and multi-token prediction, and vision and audio flags for supported models. The project maintains custom forks of mlx and mlx-c for memory-mapped SSD streaming.
The code is licensed under the MIT licence. Speed-up and memory figures in the README are the author's benchmarks and have not been independently verified. The README also warns that DFlash speculative decoding is currently unsuitable for production on at least one documented Qwen setup.
Features
- A single-binary macOS server with GET /health, GET /v1/models and POST /v1/chat/completions, including streaming.
- Direct loading of Hugging Face format models, with Safetensors parsing.
- Optional --vision and --audio modes for supported vision-language and audio-language models, using OpenAI-style image and audio payloads.
- --stream-experts for streaming MoE expert layers from NVMe, aimed at models that do not fit comfortably in RAM.
- --turbo-kv for TurboQuant KV cache compression on long contexts, plus a per-request kv_bits option for MLX-native quantised KV cache.
- Optional draft-model speculative decoding and native multi-token prediction.
- A broad table of supported model families, including Gemma 4, Qwen 2.5, 3 and 3.5, Llama 3, DeepSeek, LFM, Granite and others, with a shorter vision and audio list.
- SwiftBuddy apps for chatting with downloaded MLX models.
- ./build.sh and make test as the documented source-build and test entry points (the docs advise against running a bare swift test on a fresh checkout).
Requirements
- macOS 14 or later, Apple silicon, Xcode Command Line Tools, and the Metal Toolchain (xcodebuild -downloadComponent MetalToolchain).
- Enough disk and memory for the chosen model. SSD streaming is documented as a way to run larger MoE models with a smaller resident footprint, at lower tok/s than a full-RAM path.
- For the iOS SwiftBuddy source build: Xcode, an Apple Developer team, and a physical iPhone. The README mentions live use on an iPhone 13 Pro (6 GB).
- To build the server from source: cmake, which build.sh installs through Homebrew if needed.
Install
Fast path: download SwiftLM-b918-macos-arm64.tar.gz (or a newer release) from GitHub Releases, extract it, and run ./SwiftLM --model mlx-community/Qwen2.5-3B-Instruct-4bit --port 5413. Models download automatically if they are not already cached. The default bind address is 127.0.0.1.
From source: git clone --recursive https://github.com/SharpAI/SwiftLM, then ./build.sh, then run .build/release/SwiftLM with a --model id. Add --stream-experts for oversized MoE models.
SwiftBuddy on a Mac: the b918 release includes a DMG. SwiftBuddy on iOS: cd SwiftBuddy, run python3 generate_xcodeproj.py, open the generated project, set a development team, and run on a device.
Example
Start the server with a 4-bit instruct model on port 5413, then send a streaming POST to http://127.0.0.1:5413/v1/chat/completions with a standard OpenAI messages body. For a vision model, launch with --vision and include a base64 image_url part in the user message.
Works with
Listed in
- github.com/SharpAI/SwiftLM
- github.com/SharpAI/SwiftLM/blob/main/README.md
- github.com/SharpAI/SwiftLM/releases
Read the code before you install anything. SwiftAgents doesn't review or endorse the tools listed here. Active: a commit in the last 90 days. Slowing: last commit within the past year. Stale: older than a year, or archived.
More in this category
apfel
Command-line tool, chat mode and local OpenAI-compatible server for the on-device model in Apple's FoundationModels framework. Needs macOS 26 and Apple silicon.
Argmax OSS Swift (WhisperKit)
Argmax's open-source on-device speech toolkit for Apple silicon, and the home of WhisperKit.
MLX Swift Examples
Example apps and code showing how to use MLX Swift.
SwiftAgents