CLI & server flags

September 9, 2026 · View on GitHub

Ollama-style commands

mlx-serve run gemma4        # downloads Gemma 4 E4B (4-bit), serves it, chats right in your terminal
mlx-serve pull qwen3.6:27b  # just download (resumable, straight from Hugging Face)
mlx-serve list              # what's on disk
mlx-serve serve             # serve everything you've pulled — models load on demand by name
mlx-serve launch claude     # configure + launch a coding agent CLI against the local server

launch supports claude, pi, omp, opencode, opencode2, codex, hermes, and aider. It reads the running server's model list and real context window, writes the agent's config into a dedicated ~/.mlx-serve/<agent>/ folder (never your real agent config), and starts the agent. If the server is down it starts the MLX Core app first. --model <id> picks a model, --print shows the launch script instead of running, and anything after -- goes to the agent (mlx-serve launch codex -- resume). opencode2 also installs the mlx-serve monitor plugin, which needs the server started with --metrics. Full per-agent detail in integrations.md.

Short names, org/repo HuggingFace ids, and name:tag all work. Models land in a shared ~/.mlx-serve/models store the MLX Core app uses too.

Driving the server directly

What you want for scripts, launchd, or a headless Mac:

# one model, pinned for the life of the process
mlx-serve --model ~/.mlx-serve/models/mlx-community/gemma-4-e4b-it-4bit --serve --port 11234

# a whole folder, every model loaded on demand by name
# (this is exactly what `mlx-serve serve` and the app do)
mlx-serve --serve --model-dir ~/.mlx-serve/models

# GGUF takes the same flags; the server detects it and routes to the embedded llama.cpp
mlx-serve --model ~/models/Qwen3.5-4B-Q4_K_M.gguf --serve

mlx-serve --help lists every flag. Defaults are --host 0.0.0.0 --port 11234.

One-shot, without a server

mlx-serve --model /path/to/model --prompt "What is 2+2?"

CLI options

FlagDefaultDescription
--model PATHrequiredPath to the model directory or a .gguf file
--serveoffStart the HTTP server
--host ADDR0.0.0.0Bind address (all interfaces — set 127.0.0.1 for strictly local)
--port N11234Port for the HTTP server
--prompt TEXT"Hello"Prompt for interactive mode
--max-tokens N100Maximum tokens to generate
--temp F0.0Sampling temperature (0 = greedy)
--ctx-size NautoContext window size (auto = computed from GPU memory)
--embedding-max-length NautoPer-input token ceiling for /v1/embeddings (auto = the model's declared window; over-limit inputs get a 400, never silent truncation)
--timeout N300Stall timeout — seconds without a new token (a request that keeps producing never times out)
--reasoning-budget N-1Thinking token budget (-1 = unlimited, 0 = no thinking)
--no-visionoffDisable vision encoder even if model supports it
--pld / --no-pldonPrompt Lookup Decoding (model-agnostic spec-decode)
--pld-draft-len N5Max draft tokens per PLD step
--pld-key-len N3N-gram match key length for PLD
--drafter DIRnoneSpeculative-decoding drafter checkpoint: a Gemma 4 assistant or a DFlash draft companion. Models that ship a drafter/ subdir (Muse-Glimmer builds) load theirs automatically
--no-drafteroffNever load a drafter, including one shipped inside the checkpoint
--draft-block-size NautoDrafts per round for the drafter (auto-sized to what this Mac's verify path can use)
--no-mtp / --mtpon when sidecar presentDisable / force the native MTP head (MoE trunks default off)
--mtp-depth N3Max tokens drafted per MTP round (adaptive controller tunes within [1, N])
--mtp-history-window N0 (full)Prompts past 16K tokens only build MTP head history for the last N tokens (windowing costs acceptance on stock Qwen heads)
--dsparkoffDeepSeek V4's own block-parallel draft stages (~11 GB on top of the model)
--ssd-streamingoffds4 / DeepSeek-V4-Flash GGUF only: stream expert weights from SSD instead of holding the whole model in RAM
--prefill-chunk N8192Max tokens forwarded per prefill chunk (auto-capped further per model); lower it to cut prefill peak memory
--no-decode-attn-quantonDisable the decode-only requant of dense bf16 attention weights (the "Fast decode for bf16-attention models" toggle)
--kv-quant {off,4,8,turbo2,turbo4}offKV-cache quantization scheme (MLX path)
--kv-attn-mode {auto,dense,fused}autoDecode read path for quantized KV: fused reads the packed cache in place, auto engages it from 8K prompt tokens (only at --kv-quant 4/8; per-request kv_attn_mode overrides)
--llama-kv-quant {off,q8,q4}offKV-cache quantization for GGUF (llama.cpp path)
--llama-cache-entries N4Multi-session LRU for llama.cpp (warm multi-doc agents)
--tokenize-cache-entries N4Chat-template + tokenize cache size
--max-concurrent N1Continuous-batch decode parallelism
--prefix-cache-entries NautoShared-prefix KV cache entry cap
--prefix-cache-mem N{KB,MB,GB}2 GBShared-prefix KV cache memory cap
--prefix-cache-disk N{MB,GB}offSSD tier: prefixes survive restarts (11K-token restart TTFT 5.9 s → 0.7 s)
--metricsoffPrometheus /metrics + live dashboard panel on /
--api-key KEYnoneRequire a key for non-localhost requests (localhost stays open)
--lan-share <all|id,...>offShare the listed models (or all) with your local network over Bonjour — only inference is exposed, model management stays host-local
--lan-discoveroffDiscover models other Macs share: they appear in /v1/models as model@peer and requests proxy to that Mac
--lan-name NAMEhostnameThe Bonjour name other Macs see
--model-dir PATHnoneDiscover and serve every model in a folder (LRU resident set). Repeatable — folders merge first-wins
--max-resident-mem N{MB,GB}autoSummed memory cap across loaded models; decides whether a model may load at all (auto = 80% of the MLX wired limit, 0 disables)
--max-resident-models N3How many models stay loaded at once (LRU-evicted)
--idle-evict-secs NoffUnload models nobody is using after this many idle seconds
--no-warmup-eageroffSkip the eager warmup at boot (benchmarking / minimal-footprint deployments)
--skip-mem-preflightoffSkip the free-RAM pre-flight on load (the cap above is checked first, and still applies)
--no-tool-autocorrectoffTurn off schema-driven repair of model-emitted tool arguments
--log-levelinfoLog level (error, warn, info, debug)
--log-file PATH~/.mlx-serve/logs/Where the server log goes