{
  "slug": "mlx-lm",
  "name": "MLX LM",
  "category": "Runtimes / Inference",
  "tagline": "Apple's MLX-native way to generate, chat, fine-tune and serve LLMs on Apple silicon.",
  "kit_says": "This is home turf for me. MLX was built for the exact chip in the Mac Studio, so if anything can squeeze a 128GB machine, it starts here.",
  "homepage": "https://github.com/ml-explore/mlx-lm",
  "repo": "https://github.com/ml-explore/mlx-lm",
  "docs": "https://github.com/ml-explore/mlx-lm/blob/main/mlx_lm/SERVER.md",
  "license": "MIT",
  "platforms": [
    "macos-apple-silicon"
  ],
  "mac_studio_fit": "Primary",
  "what_it_is": "A Python package (mlx-lm) for running and fine-tuning large language models with Apple's MLX framework. Ships CLIs for generate, chat, convert/quantize, and an OpenAI-like HTTP server.",
  "gap_role": "Raw local inference speed and memory efficiency on Apple silicon; quantization (mlx_lm.convert -q) and KV-cache quantization (--kv-bits) let bigger models fit in unified memory.",
  "prerequisites": [
    "Apple silicon Mac",
    "Python 3 with pip (a virtualenv is recommended)",
    "Some features (e.g. wired-memory tuning) require macOS 15+ per the README"
  ],
  "install": {
    "macos-apple-silicon": [
      {
        "run": "python3 -m venv ~/.venvs/mlx && source ~/.venvs/mlx/bin/activate",
        "note": "isolated environment (recommended, not required)"
      },
      {
        "run": "pip install mlx-lm"
      },
      {
        "run": "# or with conda: conda install -c conda-forge mlx-lm"
      }
    ]
  },
  "configure": [
    {
      "run": "mlx_lm.server --model mlx-community/Mistral-7B-Instruct-v0.3-4bit",
      "note": "starts an OpenAI-like server on localhost:8080; model downloads from Hugging Face on first run"
    },
    {
      "run": "mlx_lm.server --model <hf_repo_or_path> --kv-bits 4 --prefill-step-size 512",
      "note": "quantized KV cache for long contexts"
    }
  ],
  "verify": [
    {
      "run": "mlx_lm.generate --model mlx-community/Mistral-7B-Instruct-v0.3-4bit --prompt \"hello\"",
      "expect": "prints generated text and tokens-per-second stats"
    },
    {
      "run": "curl -s http://localhost:8080/v1/chat/completions -H 'Content-Type: application/json' -d '{\"messages\":[{\"role\":\"user\",\"content\":\"Say hi\"}]}'",
      "expect": "JSON response with a choices[0].message.content field (server must be running)"
    }
  ],
  "rollback": [
    {
      "run": "pip uninstall -y mlx-lm"
    },
    {
      "run": "rm -rf ~/.venvs/mlx",
      "note": "only if you created this venv"
    },
    {
      "run": "# downloaded models live in the Hugging Face cache (~/.cache/huggingface/hub); delete specific model folders to free space"
    }
  ],
  "caveats": [
    "mlx_lm.server is documented as not recommended for production (basic security checks only).",
    "Port 8080 is also the default for llama.cpp's server and Open WebUI's pip install; run them on different ports."
  ],
  "works_with": [
    "open-webui",
    "litellm",
    "aider"
  ],
  "sources": [
    "https://github.com/ml-explore/mlx-lm",
    "https://github.com/ml-explore/mlx-lm/blob/main/mlx_lm/SERVER.md"
  ],
  "sponsored": false,
  "verified_on": "2026-10-15",
  "gap_score": {
    "value": null,
    "status": "pending test on Mac Studio",
    "baseline": "frontier reference (see /about#gap-score)"
  },
  "benchmarks": {
    "status": "pending test on Mac Studio",
    "rig": "Mac Studio, Apple Silicon, 128GB unified memory",
    "results": []
  },
  "hardware_tested": [],
  "repo_meta": {
    "stars": 7310,
    "stars_as_of": "2026-10-15",
    "last_push": "2026-10-10",
    "archived": false,
    "license_spdx": "MIT"
  },
  "stack_layer": "runtime",
  "summary": {
    "what": "Runs LLMs natively on Apple silicon.",
    "why": "Built for the chip in your Mac, so you get more model per GB."
  }
}