How to run mini-me on MLX-Serve
This guide shows how to point mm at MLX-Serve, a local model server for Apple Silicon (MLX, no Python), through its OpenAI-compatible endpoint. It assumes MLX-Serve is installed (the app, or brew install mlx-serve for the server only) and that you know how to build mm.
Steps
-
Download a model and start the server.
mlx-serve serveserves every downloaded model on0.0.0.0:11234and loads a model on the first request that names it:mlx-serve pull lmstudio-community/gemma-4-E4B-it-MLX-8bit mlx-serve serve # or open the MLX-Serve app -
Run the demo configuration from its directory:
cd demos/mlx-gemma-4-e4b ../../mm # finds .mm/agent.yaml -
Check the banner.
provider: mlxserveconfirms the provider. When the model is loaded,ctx: 101376 (/v1/models)is the window MLX-Serve serves it with. When it is not loaded yet, the window is unknown at start-up andmmlearns it before the next question, once the first answer has loaded the model.
Variants
- Another model. Set
model:to the id exactly asGET /v1/modelslists it (curl -s localhost:11234/v1/models). Check the start-up warnings: a model MLX-Serve does not have is not an error on its side — it answers with its default model under the name you asked for. The only sign is the warningmodel "…" is not downloaded — mlx-serve pull …. - Write the file with the wizard.
mm init --provider mlxservelists the server's models and reads the chosen one's family, window, chat template (/api/show) and its own sampling (gen_temperature,gen_top_p,gen_top_kin/v1/models).--checkasks the model one question. See How to create an agent. - Let mm pull the model. With
autoPull: true, mm downloads a model the server does not list at start-up, throughPOST /api/pull(Ollama's wire, which MLX-Serve speaks), and shows the progress. SeeautoPull. - Reasoning. MLX-Serve reasons when either
chat_template_kwargs.enable_thinkingorreasoning_effortsays so. To turn it off for every turn, say no to both insampling— or leave both out: Gemma 4 does not reason by default. See How to turn a model's reasoning off. - From a container or a Docker sandbox. MLX-Serve listens on all interfaces by default, so with no
baseUrlanswering,mmfalls back tohttp://host.docker.internal:11234/v1by itself. In a sandbox, allowlocalhost:11234in the network policy. - A protected MLX-Serve. A server started with
--api-key KEYchecks the key for every caller but localhost — a container or a sandbox is not localhost. Export it inMLX_SERVE_API_KEY(mm's name for it; or name another variable underapiKeyEnv). A refused key is a start-up warning naming the variable. - Free the memory.
/unloadand theunload_modeltool unload the model throughPOST /v1/unload-model. See How to free a model's memory.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|