MLX-VLM is a package based on the Apple MLX framework for inference and fine-tuning of vision-language models (VLMs) and multimodal models that support audio and video (Omni Models) on Mac.
Purpose
This project is aimed at developers who need to run and fine-tune vision-language models and multimodal models locally on Mac, providing multiple usage paths from the command line, Python scripts, to a web chat interface and server-side deployment.
Main Capabilities
- Inference and fine-tuning of vision-language models and multimodal models (including audio and video support).
- Command-line interface (CLI) generation output, supporting Thinking Budget control over the number of tokens in the thinking block.
- Speculative Decoding, supporting drafter series such as DFlash, DFlash2, DSpark, Gemma 4 MTP, Gemma 4 EAGLE-3, MiniMax M3 EAGLE-3, etc.
- Gradio chat interface.
- FastAPI server, supporting Continuous Batching, Automatic Prefix Caching (APC), KV cache quantization, 1-bit affine inference, activation quantization (CUDA).
- Multi-image conversation support, visual feature caching, TurboQuant KV cache, distributed inference.
- Decision models support, callable via CLI or server; some models support image and speech input.
- The server supports streaming responses in an OpenAI-compatible format, and exposes metrics such as throughput in timings.
- Includes an agent-skills bundle under skills/, which can be loaded into coding agents (Claude Code, Codex, Gemini).
Usage
Installation:
pip install mlx-vlm
The Gradio chat interface requires additional dependencies (not included in the base installation):
pip install "mlx-vlm[ui]"
The package name needs to be quoted to prevent shells such as zsh that expand square brackets from treating [ui] as a glob pattern.
CLI generation example:
mlx_vlm.generate ...
Server startup example:
mlx_vlm.server --model <Hugging Face repo ID 或本地路径> --port 8080
The main server parameters include:--model、--image-model、--tts-model、--stt-model、--embedding-model、--decision-model、--reranker-model、--model-dir、--adapter-path、--draft-model、--draft-kind、--draft-block-size、--host、--port、--trust-remote-code、--enable-thinking、--thinking-budget、--thinking-start-token、--thinking-end-token、--kv-bits、--kv-quant-scheme、--kv-key-bits / --kv-value-bits、--kv-key-scheme / --kv-value-scheme、--kv-group-size、--max-kv-size、--vision-cache-size、--log-progress-interval、--api-key、--log-level.
Trust remote code can also be set via an environment variable.
Python scripts can directly call this package for inference;stream_generate can be used with APCManager to use automatic prefix caching.
Decision models can run shared typed decision predictions via the CLI, using --state-file request.txt to pass UTF-8 text,--questions-file questions.json to pass a named question;mlx_vlm.decide executes the same command. Models that support image input use repeatable --image, and models that support speech use --audio(each being a path or URL). In server requests, the model can be explicitly specified; otherwise the currently loaded decision model is used; if neither is available, HTTP 400 is returned. Requests can add "images"(a list of URLs, paths, or data URIs) or "audio"(a URL, path, or base64 data URI), in which case state can be null. Decision requests are non-streaming and use the server's API-key authentication.
Applicable Scenarios
- Local inference and fine-tuning of vision-language models and multimodal models on Mac.
- Need to call VLMs via CLI, Python scripts, Gradio chat interface, or FastAPI server.
- Need performance optimization capabilities such as speculative decoding, continuous batching, automatic prefix caching, and KV cache quantization.
- Scenarios requiring multi-image conversation, visual feature caching, distributed inference, or decision model invocation.
Limitations
- Only targeted at Mac and the MLX environment.
- The Gradio chat interface requires additional installation of
[ui]Dependencies, not part of the base installation. - The server can load only one model at a time (supports dynamic loading/unloading and caching).
- DSpark decoding currently requires greedy sampling (temperature=0).
- Although the public MiniMax M3 BF16 checkpoint declares MTP metadata, it does not release mtp or nextn tensors, so the released EAGLE-3 drafter must be used.
- Speculative decoding counters such as draft_n_accepted are drafter metrics and are shared across batches when requests are concurrent.
- By default, APC persists the cache to disk when enabled, located at $MLX_VLM_CACHE_HOME/apc (or ~/.cache/mlx-vlm/apc), with a per-model namespace limit of 20 GiB.
- The materials do not provide specific pricing, billing models, or commercial use terms, so no relevant information is currently available.