Run Aider with a Local MLX Model on Mac
Since 1.0.4, Aider runs shell commands in your own shell; its isolated profile includes model metadata to avoid the unknown-model warning.
Start rapid-mlx serve qwen3.5-9b-4bit on your Mac. Run rapid-mlx agents aider --setup, paste its export lines into your shell, then start Aider.
Quick start
Needs: Aider (pip install aider-chat); start the server before sending requests (rapid-mlx serve qwen3.5-9b-4bit).
$ rapid-mlx serve qwen3.5-9b-4bit # terminal 1; keep running # terminal 2: $ rapid-mlx agents aider --setup # prints three export lines # paste them into your shell, then: $ aider --no-git --message "say hello"
A reply means aider is using your local model. Without the exported AIDER_MODEL and key, aider starts an OpenRouter sign-in instead.
/v1/chat/completions ·
Setup: env vars OPENAI_API_BASE /
OPENAI_API_KEY ·
Matrix cell:
✅ ✅ ✅ ✅
(all four families PASS — aider's plain-text edit format works
with reasoning-only models).
Re-verified 2026-08-01 — real end-to-end edit (SEARCH/REPLACE applied) on
aider 0.86.2 +
rapid-mlx 0.11.5, Qwen 3.5-9B-4bit on an M2 Pro Mac mini (32 GB) — Qwen family only; the other three families were not re-run in this pass.
Install
$ pip install aider-chat
Config
Aider is configured with env vars. rapid-mlx agents aider --setup
prints them for the model the server reports. It writes no files, so
add them to your shell profile to keep them:
$ export OPENAI_API_BASE=http://localhost:8000/v1 $ export OPENAI_API_KEY=not-needed $ export AIDER_MODEL=openai/qwen3.5-9b-4bit
Set AIDER_MODEL and a key. Without them, aider starts an
OpenRouter sign-in flow instead of using your local server (seen with aider 0.86.2).
Pass the files you want worked on (or /add them). In our
2026-10-02 harness run, aider started with --no-git and no
files answered without reading the code.
Or per-invocation flags:
$ aider \
--model openai/default \
--openai-api-base http://localhost:8000/v1 \
--openai-api-key not-needed \
main.py
Run
$ rapid-mlx serve qwen3.5-9b-4bit $ aider --openai-api-base http://localhost:8000/v1 \ --openai-api-key not-needed \ --model openai/qwen3.5-9b-4bit \ main.py
| Mac unified memory | Model choices | Download and memory guidance |
|---|---|---|
| 16 GB | qwen3.5-4b-4bit fits 16 GB per the registry; not verified live on a 16 GB Mac. | About 3 GB download. |
| 18–36 GB | qwen3.5-9b-4bit default; start with qwen3.5-4b-4bit on 18–24 GB. | About 6 GB for 9B or 3 GB for 4B. |
| 48 GB+ | qwen3.5-9b-4bit responsive default; qwen3.8-27b-4bit higher-capability option. | About 6 GB for 9B or 16 GB for 27B; 27B needs roughly 20–26 GB free unified memory. |
Download size is not runtime memory use. Leave room for the client, context and other applications; keep context short when memory is tight.
LiteLLM openai/ prefix
Aider drives LiteLLM under the hood. Without the
openai/ prefix on the model string LiteLLM tries to
pick a provider from the alias name and fails on rapid-mlx aliases
(which aren't in LiteLLM's registry). The
test_aider.sh
harness constructs LITELLM_MODEL="openai/${MODEL}"
exactly for this reason.
Integration harness (test_aider.sh)
The bash harness at
tests/integrations/test_aider.sh
seeds a scratch add.py with return a - b # BUG,
drives aider one-shot with --message, and asserts the
file was rewritten to return a + b (AST + runtime
add(2, 3) == 5 gate). The exact aider invocation:
$ HOME="$SCRATCH_HOME" \ AIDER_ANALYTICS_ASKED=1 \ AIDER_CHECK_UPDATE=false \ OPENAI_API_BASE="$BASE_URL" \ OPENAI_API_KEY="rapidmlx" \ aider \ --model openai/"$MODEL" \ --openai-api-base "$BASE_URL" \ --openai-api-key rapidmlx \ --no-git --no-analytics --no-check-update \ --no-show-model-warnings --no-pretty --no-stream \ --map-tokens 0 --yes-always \ --message "Fix the bug in add.py — this function should add, not subtract. Change the '-' operator to '+' in the return statement." \ add.py
Family × wall-time from the 2026-07-07 pilot (single aider run,
real inference): Qwen 3.5-4B-4bit 2.81 s, Gemma-4-31B-4bit 7.14 s,
DeepSeek R1-Distill-32B-4bit 22.26 s (long <think>
block before the SEARCH/REPLACE edit),
gpt-oss-20B-MXFP4-Q8 3.15 s — all four PASS with
add.py rewritten to return a + b.
Gotchas
- No function calling. Aider uses plain-text edit formats (unified diff, SEARCH/REPLACE). This is why it works with DeepSeek R1-Distill — R1 can't emit function calls but can emit the SEARCH/REPLACE format from the system prompt.
-
LiteLLM
openai/prefix is mandatory. Otherwise LiteLLM's alias-guessing fails on non-canonical rapid-mlx model names. -
Architect mode: dual model. One plans, one edits — use
--architectand pass two aliases if you want to split a strong-but-slow planner from a cheap-and-fast editor. - Best local-model support of any agent. Aider works with virtually any tool-capable model because it doesn't need function calls.