Cursor with a Local LLM: Use a Local Model on Your Mac
Yes, Cursor can use a local LLM, but not at localhost. Cursor calls custom models from its own servers, so the setup is a key-protected server on your Mac, an HTTPS tunnel, and one command that writes Cursor's settings.
To use Cursor with a local model, serve the model on your Mac behind an API key, give it a public HTTPS address, and let Rapid-MLX write Cursor's OpenAI base URL (https://<your-tunnel>/v1):
# terminal 1: the model, behind a key (48 GB Mac; smaller picks below) export RAPID_MLX_API_KEY="$(openssl rand -hex 24)"; echo "$RAPID_MLX_API_KEY" rapid-mlx serve qwen3.6-35b-4bit # serves http://localhost:8000/v1 # terminal 2: open an HTTPS tunnel to the port serve printed (8000), then: export RAPID_MLX_API_KEY="paste-the-key-from-terminal-1" rapid-mlx launch cursor --server-url https://your-tunnel-host.example --model qwen3.6-35b-4bit
Cursor's chat and composer accept a custom OpenAI base URL, so the model behind them can be one you serve yourself with Rapid-MLX. The catch most guides skip: Cursor sends those requests from its own servers, not from the editor on your Mac. A URL like http://localhost:8000/v1 points at Cursor's machine, not yours, so it never reaches your model.
What works is a public HTTPS address that forwards to your Mac, protected by an API key. It takes about ten minutes the first time.
The whole thing
- Install Rapid-MLX and start a model with an API key.
- Open an HTTPS tunnel to port 8000 on your Mac.
rapid-mlx launch cursorwrites Cursor's settings for that tunnel.
1 · Install Rapid-MLX
curl -fsSL https://rapidmlx.com/install.sh | bash
Prefer Homebrew? brew install rapid-mlx (it's in homebrew/core).
2 · Serve a model behind an API key
Your server is about to be reachable from the internet, so it needs a key. serve reads it from RAPID_MLX_API_KEY. Create one and print it, because step 4 runs in a second terminal that needs the same key:
export RAPID_MLX_API_KEY="$(openssl rand -hex 24)" echo "$RAPID_MLX_API_KEY" rapid-mlx serve qwen3.6-35b-4bit
serve keeps this terminal busy; leave it running.
Not sure which model fits your Mac? rapid-mlx recipe reads your memory and prints the engine's pick with the command to run it. The "most capable that fits" pick for each memory size:
| Your Mac | Engine pick | Serve it |
|---|---|---|
| 8 GB | LFM2.5 2.6B | rapid-mlx serve lfm2.5-2.6b-4bit |
| 16 GB | Qwen3.5 4B | rapid-mlx serve qwen3.5-4b-4bit |
| 18 GB | Qwen3.5 9B | rapid-mlx serve qwen3.5-9b-4bit |
| 24 GB | Bonsai 27B (2-bit) | rapid-mlx serve bonsai-27b-2bit |
| 32 GB and up | Qwen3.8 27B | rapid-mlx serve qwen3.8-27b-4bit |
| 48 GB and up, for speed | Qwen3.6 35B (MoE) | rapid-mlx serve qwen3.6-35b-4bit |
Hardware tiers has measured memory and speed for every pick.
3 · Open an HTTPS tunnel to port 8000
Any tunnel that gives you a public https:// address forwarding to http://localhost:8000 will do, for example Cloudflare Tunnel or ngrok. Note the hostname it prints.
Only expose a server that was started with RAPID_MLX_API_KEY set. Anyone who has the tunnel URL and the key can use your model, so keep both private and stop the tunnel when you're done.
4 · Point Cursor at it
In a second terminal, set the same key, your tunnel's address, and the model you served:
export RAPID_MLX_API_KEY="paste-the-key-from-step-2" TUNNEL="https://your-tunnel-host.example" rapid-mlx launch cursor --server-url "$TUNNEL" --model qwen3.6-35b-4bit --dry-run rapid-mlx launch cursor --server-url "$TUNNEL" --model qwen3.6-35b-4bit
The first command previews the change; the second writes it. Pass --model with the alias you served: without it, launch picks its own default. This writes the base URL (with /v1 appended), your API key and the model into Cursor's user settings.json, keeps your other settings, and backs up the old file first. It refuses localhost, private network addresses and plain http:// before writing anything, because Cursor's servers can't reach those.
Then open Cursor, pick the model in the model dropdown, and send a chat message. A reply means the whole chain works. If the dropdown hides the alias, pick default: it always resolves to whatever the server booted.
What this covers, and what it doesn't
Chat and composer use your endpoint. Cursor's agent and CLI paths go through Cursor's own backend and can't be pointed at a custom endpoint. For a coding agent that talks to your Mac directly and keeps prompts local, use Claude Code or Codex CLI. Rapid-MLX's anonymous usage stats can be turned off.
Privacy, honestly. The model runs on your Mac, but each request travels through Cursor's servers and the tunnel on its way there, so this setup is not offline and your prompts are not only on your machine. What you gain is no per-token bill for those requests and a model you choose. If keeping code on the Mac is the point, a terminal agent on localhost is the better fit.
Expectations. A model on your Mac isn't a frontier cloud model. It's good for explain-and-refactor, small features and quick edits. You can switch Cursor back to its own models at any time.
Frequently asked questions
Can Cursor use a local LLM?
Yes, for chat and composer. Cursor calls custom models from its own servers, so the model on your Mac has to be reachable at a public HTTPS address: serve it with an API key, open a tunnel to port 8000, and run rapid-mlx launch cursor with the tunnel's address and the model you served.
How do I add a local model to Cursor?
Run rapid-mlx launch cursor --server-url <your HTTPS tunnel> --model <alias> with RAPID_MLX_API_KEY exported. It writes the OpenAI base URL (your tunnel address plus /v1), the API key and the model into Cursor's settings. Then pick the model in Cursor's model dropdown. If you'd rather enter it by hand, Cursor's Models settings take the same three values: an OpenAI API key, an overridden OpenAI base URL, and a custom model name.
Why doesn't http://localhost:8000 work in Cursor?
Cursor sends custom-model requests from its backend, not from the editor. To Cursor's servers, localhost is their own machine, so the request never reaches your Mac. A tunnel gives your server an address they can reach.
Is my code private when Cursor uses a local model?
Not fully. Inference happens on your Mac, but requests pass through Cursor's servers and your tunnel. For code that must stay on the machine, use a terminal agent such as Claude Code or Codex CLI pointed at localhost.
What's the best local model to use with Cursor?
Run rapid-mlx recipe: it prints the engine's pick for your Mac's memory. On 48 GB or more, qwen3.6-35b-4bit is the fast mixture-of-experts choice for interactive editing.
Where to go next
- Cursor reference: the exact settings
launch cursorwrites, and its checks. - Claude Code on a local model: a coding agent that stays on
localhost. - Agent guides: every agent Rapid-MLX configures.
- OpenAI-compatible server: the port, base URL, API key and endpoints behind the tunnel.
- Install Rapid-MLX: one curl or Homebrew. Apache 2.0.
rapid-mlx serve <alias> serves any model on
localhost:8000/v1.
curl -fsSL https://rapidmlx.com/install.sh | bash
New models and speedups, in your inbox
A short note whenever Rapid-MLX gets faster or adds models worth running on your Mac. No spam — unsubscribe anytime.