No. 009 AI essay 7 min, about 1200 words

MLX Studio: a macOS app to download, run and serve MLX models on Apple Silicon

Problem
To run a local model on a Mac you usually need three command-line tools: one to download the weights, one to serve them and one to chat. You find out that a model does not fit in memory at a given context length only when loading fails. Connecting your own code to the model is one more integration.
Fix
Search, download, size and serve a model from one app.

MLX Studio is a macOS desktop app. It downloads models from the mlx-community catalog on Hugging Face and runs them with mlx-lm for text and mlx-vlm for vision. It serves every installed model on an OpenAI-compatible API on 127.0.0.1. We built it as the model runtime for another system we are developing. Any component that uses the OpenAI protocol connects to it by changing the base URL, without adapter code.

The app runs only on Apple Silicon, so we chose MLX over llama.cpp or Ollama. MLX is the array framework from Apple, built on Metal and unified memory. The weights load once into the memory that the GPU uses, and nothing is copied between CPU memory and GPU memory. On a 48 GB MacBook, the 4-bit build of Qwen2.5 7B uses 4.0 GB for the weights and answers at 35 tok/s.

MLX Studio Overview page: a memory dial, the split of unified memory, the running model and the recent activity

The Overview page shows how the unified memory is split, the running models and the recent activity.


From the catalog to the first reply

The workflow uses four screens.

1
Catalog: search mlx-community and filter by quantization, vision or instruct support. Each row shows the estimated memory and a badge: Fits, Tight or Too big. A bar compares the estimate with the memory that is free on the Mac now, so you see that a model is too big before you download it. Model catalog: each row has the estimated memory, a Fits, Tight or Too big badge and a download button
2
Download: the app shows the progress over SSE, with bytes and speed. You can pause, resume and cancel a download, and it continues from the last complete file, so a 14 GB model stopped at 90% does not start again from zero. MLX Studio downloads up to four files in parallel. The Hub limits anonymous requests to much less than a fast connection can carry. A free read token from huggingface.co/settings/tokens, saved in Settings ▸ Hugging Face, raises the limit for downloads and for catalog searches. Downloads view with a completed model and one downloading at 14 MB/s
3
Start: you choose the context length with a slider, and the memory estimate changes as you move it. The estimate adds the weights, the KV cache, which grows with the context, and the runtime overhead, and compares the total with the free memory. Qwen2.5 7B with 8,192 tokens needs 5.0 GB. The Start button is disabled when the total does not fit. Start dialog with context length slider and live memory estimate breakdown
4
Chat: replies stream with Markdown and code highlighting. The app saves the conversations and shows the measured tokens per second under each reply. The selector in the header switches between running models. Chat view with model selector and a streamed reply at 35.1 tok/s

The OpenAI-compatible API

The app serves every installed model on http://127.0.0.1:11535/v1 with the OpenAI protocol. The chat tab is one client of this API. If a request names a model that is installed but not running, the app loads it, so the client does not need to check the state first. On a running model, Use from code opens a dialog with the base URL, the API key and code snippets for the Python OpenAI SDK, LangChain, Java with LangChain4j (builder or Spring Boot starter properties), Rust with Rig and curl.

Use from code dialog with the base URL, API key, model name and the Java LangChain4j snippet, with tabs for Python, LangChain, Java, Rust and curl

Use from code has snippets for Python, LangChain, Java (LangChain4j), Rust (Rig) and curl.

Listing 1python
from openai import OpenAI

client = OpenAI(base_url="http://127.0.0.1:11535/v1", api_key="<MLX Studio API key>")
resp = client.chat.completions.create(
    model="qwen2.5-7b-instruct-4bit",
    messages=[{"role": "user", "content": "Hello!"}],
    stream=True,
)

The same endpoint works with Continue, Cursor and any tool where you can set the OpenAI base URL. Our own system uses it in the same way. The app handles downloads, memory and the model processes. The clients see a standard OpenAI server that works offline.


Vision models

Models with a vision encoder, such as Qwen-VL, LLaVA and the Gemma vision models, run on mlx-vlm instead of mlx-lm. The app reads the config.json of each model to choose. When the running model supports images, the chat input has an attach button and accepts pasted images. The /v1 endpoint accepts the standard OpenAI image_url content parts, as base64 data URLs or http URLs. On the same MacBook, Qwen2.5-VL 3B (4-bit, 2 GB) described a test photo correctly at 81 tok/s.

Chat with an attached photo of a black dog and the model's streamed description

Qwen2.5-VL 3B describes an attached photo at 81 tok/s.

mlx-vlm 0.6.4 has a bug: in one process, every generation after the first one stops after one token. The first request works, so unit tests and single CLI calls pass. We found the bug only when we sent three requests in a row to the running server. MLX Studio pins mlx-vlm>=0.6.3,<0.6.4. The pin stays until a newer release passes the same test with several requests.


Architecture

LayerTech
Desktop shellTauri 2 (Rust)
FrontendVue 3 + TypeScript + Vite
Backend sidecarPython, FastAPI, bundled with PyInstaller
Inference enginemlx-lm (text), mlx-vlm (vision)
StorageSQLite

At launch, the Rust core starts the Python sidecar and gives it a new bearer token. Other processes on the Mac cannot call the local API without that token. When the app quits, the core stops the sidecar and frees the port. The sidecar also watches the process ID of the app and exits if the app dies without cleanup. After a force quit, no process stays in memory with 4 GB of weights.


Status

The code is on GitHub under the MIT license, at version 0.4.0. CI builds an Apple Silicon DMG on every push. MLX needs Metal and unified memory, so there is no Intel build. The DMG needs nothing else. The Python sidecar is inside the bundle as a PyInstaller binary, and the shell uses the WebView of macOS. On a Mac with an M-series chip the app runs without Python, Homebrew or any other install. The next planned changes are versioned releases for the in-app updater, and a shared memory budget so that two models can run at the same time.