Skip to content

Drop-in for mlx-lm

If you run mlx_lm.server today, you can stop it and start mlx-bun serve — same port, same host, same endpoints, same request fields. Your existing curl commands and client configs keep working, and the logits are bit-exact to mlx-lm’s on the supported models (that’s the project’s correctness oracle).

Terminal window
# before
mlx_lm.server --model mlx-community/Llama-3.2-1B-Instruct-4bit
# after — same clients, no Python
mlx-bun serve Llama-3.2-1B
SurfaceParity
POST /v1/chat/completionsStreaming + non-streaming, same fields
POST /v1/completionsRaw text completion, stream + non-stream
GET /healthByte-exact body
GET /v1/modelsLists your downloaded models (+ /v1/models/<id>)
DefaultsPort 8080, loopback-only host (--host 0.0.0.0 = LAN opt-in)
Sampling fieldsmin_p, xtc_probability/xtc_threshold, logit_bias, presence_penalty/frequency_penalty (+ *_context_size windows) — L1-faithful ports of mlx-lm’s sample_utils.py
logprobs / top_logprobsmlx-lm’s exact semantics: same distribution, same response shape, same [0,11] validation
Flags--temp alias, --max-tokens, --adapter <dir> (--adapter-path accepted), --decode-concurrency accepted as an alias for --batch

Under the --l1 tier the decode route is bit-for-bit identical to mlx-lm (bf16 KV, unfused) — not “compatible,” identical logits.

The mlx-lm workflow tools have native counterparts (v0.0.9), flag names matching the Python spellings:

  • mlx-bun fuse — fold a LoRA adapter into the base weights (mlx-lm math; untouched modules bit-identical).
  • mlx-bun convert — quantize an HF model, including mixed-precision --target-bpw (the mlx-bun differentiator).
  • mlx-bun perplexitymlx_lm.perplexity methodology exactly, over a local file.
  • mlx-bun upload — native push-to-hub, no Python.

See the CLI reference for each.

Honest gaps, so you can decide before switching:

  • role_mapping — unreachable in practice; every supported model ships a chat template.
  • mlx_lm.cache_prompt and mlx_lm.evaluate — not yet (an lm-eval shim is planned).
  • --draft-model speculative decoding.
  • awq / dwq / gptq quantization modes (convert supports affine + the mixed-precision --target-bpw path).

Each unported flag errors out explicitly rather than silently guessing.

Beyond compatibility: one signed binary with no Python or venv, 2–5× faster server startup and TTFT, the Anthropic Messages and OpenAI Responses protocols on the same port, a byte-capped prompt cache, LoRA hot-swap, and memory admission control.