Run language models locally on your Apple Silicon Mac and connect them to your apps.
Mei is a native Swift/MLX inference server with an OpenAI-compatible API. Use it as a local backend for a chat app, coding agent, or your own software. Model inference runs on your Mac; Mei serves one model per process.
Website · Releases · API compatibility
- An Apple Silicon Mac running macOS 15 or later.
- Enough unified memory for the model, its context, and your other apps. The larger models below have been tested on a 32 GB Mac; memory needs vary with the model and request size.
- Disk space for model weights, which are downloaded separately. Check the model repository for download size before fetching a bundle.
- Homebrew for the installation steps below.
brew install tijs/tap/mei
mei --version
# Skip these if uv and the Hugging Face CLI are already installed.
brew install uv
uv tool install --upgrade huggingface_hub
hf --versionAlready have Mei? Run brew update && brew upgrade mei to update it. You can
also download a prebuilt bundle from the latest release:
verify its accompanying SHA-256 checksum, unpack it, and run bin/mei. Keep
mlx.metallib beside the executable. No Xcode or source build is needed for
these installations.
This example uses the Groot text model. mei pull uses the Hugging Face CLI to
download the profile's pinned model revision into your local cache.
mei pull groot-19b-a3b-text
mei --model groot-19b-a3b-textLeave this terminal running. Wait for Mei to print
listening on http://127.0.0.1:8024 before sending a request. Model loading can
take a while. Stop the server with Ctrl-C.
To inspect the download location and pinned revision first, use
mei pull groot-19b-a3b-text --dry-run. To choose a download directory, use
mei pull groot-19b-a3b-text --dest /path/to/model, then pass that directory
to --model-dir.
In another terminal:
curl -fsS http://127.0.0.1:8024/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{
"model": "groot-19b-a3b-text",
"messages": [{"role": "user", "content": "Explain unified memory in two sentences."}],
"max_tokens": 256
}'The response is JSON; the reply is in choices[0].message.content. Add
"stream": true to the request and -N to curl for server-sent events.
Choose your app's OpenAI-compatible Chat Completions provider and set:
| Setting | Value for the quickstart |
|---|---|
| Base URL | http://127.0.0.1:8024/v1 |
| Model ID | groot-19b-a3b-text |
| API key | No key required by Mei; use local if your app requires a value |
The model ID must match the one Mei serves. --served-model-id gives it a
custom name. By default, Mei uses the selected model name or the bundle
directory name and prints it at startup.
Check it at any time with:
curl -fsS http://127.0.0.1:8024/v1/modelsMei supports chat completions, streaming, native tool calls, and structured JSON output. Support depends on the model and chat template; the compatibility guide describes the supported request fields and schema subset. Apps must support the Chat Completions API.
Mei listens on loopback by default and has no built-in API authentication. Keep the default for apps on the same Mac. An app connected to Mei may still make its own network requests or execute tools locally.
These named profiles can be downloaded with mei pull <profile>:
| Model | Profile | Input |
|---|---|---|
| Inkling 2 Mini | inkling-2-mini |
Text |
| Inkling 2 Mini, Mei vocabulary Q4 | inkling-2-mini-mei-q4 |
Text |
| Groot 19B-A3B | groot-19b-a3b-text |
Text |
| Qwen3.6 35B-A3B, text-only | qwen3.6-35b-a3b-text |
Text |
| Ornith 1.5 35B-A3B | ornith-1.5-35b-a3b |
Text |
| Qwen3.6 35B-A3B, vision bundle | qwen3.6-35b-a3b |
Text and images; see model-specific limits |
Use the same name with mei pull <model> and mei --model <model>. Mei
recognizes the downloaded bundle and selects its runtime settings automatically; startup logs show what was selected. Explicit
flags override those settings.
For the Qwen vision bundle, send images to POST /v1/chat/completions as
image_url parts in a user message's content array. Set image_url.url
to an inline base64 PNG, JPEG, or WebP data URL. Text and image parts can be
interleaved. The request limit is 24 megapixels across all images. Both
buffered and streaming chat count the expanded image tokens toward context.
You can also point Mei at an existing compatible MLX model directory containing its configuration, tokenizer, chat template, and safetensors weights. Support is specific to the architecture and weight format. Check the model guide for artifact requirements, preparation steps, and limitations before downloading an arbitrary checkpoint. Weights are not included with Mei and have their own licenses.
For Inkling 2 Mini, the Mei vocabulary Q4 bundle reduces serving memory
on a 32 GB M1 Max. In Mei 0.17.0, Q4 scored
20/25 on the task suite versus 22/25 for the original weights. See the
model guide for both downloads and the context override.
On a 32 GB M1 Max, repeated requests can reuse their first 1,024 tokens
with mei --model inkling-2-mini-mei-q4 --cache-mode memory. In the chat
benchmark this reduced repeated prompt processing from 12.02–12.04 to 6.30 seconds.
The Pi example below uses the original bundle.
For measured model comparisons and their hardware/runtime scope, see the
current benchmark results.
Start Mei by model name. The default, --context-cap auto, gives each request room for its formatted prompt and reply according to the model’s supported window and the Mac’s available memory. Mei counts cached history once. Use a number for repeatable runs:
mei --model groot-19b-a3b-text --context-cap 65536
curl -s http://127.0.0.1:8024/v1/mei/status | jq '{contextMode, contextCap, availableContextTokens}'contextCap is the stable server ceiling. Auto uses the supported ceiling for the model profile. On a Mac with more memory you can request a higher numeric ceiling within the model’s positional limit. Set the client's context window to that value. availableContextTokens is an estimate for a new request at the instant you check. The sum of input and output must fit the server ceiling. A 26,000-token formatted prompt at a fixed 26,624 cap leaves at most 624 tokens for output. A smaller requested reply limit still wins; when omitted, Mei uses its configured --max-tokens default.
On the qualified 32 GiB M1 Max, automatic SSD spill extends the combined window to 67,584 tokens for Groot, 49,152 for Inkling vocabulary Q4, 36,864 for original Inkling and Qwen text, and 28,672 for Qwen vision and Ornith. Mei uses RAM when it fits. Full-attention layers read their spilled history from disk during decode. See the 0.20.0 qualification for measured rates and tested configurations.
| Mac unified memory | Example fixed cap | Evidence and trade-off |
|---|---|---|
| 24 GB | 8,192 | A starting point for a model that fits alongside macOS. |
| 32 GB | 26,624 | Latency-oriented Inkling baseline on the M1 Max. Coding runs also exercised 32,768 total with up to 16,384 output. |
| 64 GB or more | 65,536 | Try a representative long prompt. Memory usage varies with attention architecture, weight size, and other apps. |
Groot, Qwen and Ornith previously allowed additional reply tokens after a full prompt. Now reserve reply space within the window or explicitly raise the cap. A full prompt receives HTTP 400. Temporary memory pressure before generation receives HTTP 503; compact the conversation, request a shorter reply or retry after memory is available. In a stream, discard unfinished output or tool calls if a terminal error frame arrives.
Pi can connect to Mei through its built-in OpenAI Chat
Completions provider. This example uses Inkling 2 Mini, a text model with
streaming tool calls and an example 26,624-token client window for prompts and replies.
Install Mei 0.16.1 or later and the hf CLI. The pinned bundle is about 19.5 GB.
See the Inkling guide.
mei pull inkling-2-mini
mei --model inkling-2-miniAdd the mei provider under providers in ~/.pi/agent/models.json, or
create the file with the following contents. The apiKey is a placeholder for
Pi's credential check. The local Mei server requires no API key.
{
"providers": {
"mei": {
"baseUrl": "http://127.0.0.1:8024/v1",
"api": "openai-completions",
"apiKey": "local",
"compat": { "maxTokensField": "max_tokens" },
"models": [
{ "id": "inkling-2-mini", "contextWindow": 26624, "maxTokens": 2048 }
]
}
}
}For a different server cap, change Pi’s contextWindow to match. Set Pi’s compaction budgets by merging this override into
the project's .pi/settings.json.
{
"compaction": {
"modelOverrides": {
"mei/inkling-2-mini": { "reserveTokens": 2048, "keepRecentTokens": 4096 }
}
}
}Check text generation from a second terminal, then start Pi in the project you want to work on.
pi --model mei/inkling-2-mini --no-tools --no-session -p "Reply with OK."
pi --model mei/inkling-2-miniFor a different model, use the ID returned by
curl -fsS http://127.0.0.1:8024/v1/models. Set Pi's contextWindow to
fit the model and Mei's configured context cap, and maxTokens to the desired
reply budget. Pi runs tools locally and sends their results back to Mei
for the next turn. Tool use depends on the model and its chat template.
See Pi's model configuration reference
and compaction settings.
Use mei --help for the full list of options. Common settings are:
| Option | Purpose |
|---|---|
--model NAME |
Model previously downloaded with mei pull |
--model-dir DIR |
Local model bundle to load |
--served-model-id ID |
Model name clients send in requests |
--port PORT |
Listen on another port; default 8024 |
--context-cap auto|TOKENS |
Choose automatic sizing or a fixed total at launch. See Choose a context limit. |
--max-tokens TOKENS |
Set the server's maximum reply length |
--kv-cache-dir DIR |
Configure an on-disk KV cache; support varies by model |
Run separate Mei processes on different ports to serve multiple models. By
default, each process executes one generation at a time with a bounded queue.
The experimental --max-active-generations 2 option allows two overlapping
generations and needs additional memory. See inference scheduling
before enabling it.
To check a running server:
curl -fsS http://127.0.0.1:8024/healthz
curl -fsS http://127.0.0.1:8024/v1/mei/statusIf a client cannot connect, check that model loading has finished and that the
host and port match. If it reports an unknown model, use the ID from
/v1/models. If loading or generation runs out of memory, free memory, choose
a smaller model, or lower the context and reply budgets.
Mei uses SwiftPM and a pinned vmlx-swift runtime. Source builds require Xcode and its Metal toolchain. See the development guide for build, test, and Metal resource setup, and the installer guide for installing a built binary.
- Models — compatible bundles, provenance, and preparation.
- API compatibility — endpoints, tool calls, and structured output 650F .
- Runtime policies — cache and memory controls.
- Architecture — inference, chunked prefill, and prefix reuse.
- Benchmarking — measurement and qualification methods.
- Changelog — release history.
Mei is named after Mei long, the “sleeping dragon” dinosaur. Licensed under MIT; see NOTICE.md for third-party notices.