Agent guide · rapid-mlx 1.1.1 · ← Back to README

Run Codex CLI with local models on Mac

Run rapid-mlx launch codex to use Codex CLI with a local model on your Apple Silicon Mac. Rapid-MLX saves a private agent profile and starts a local model when needed.

One command to launch Codex CLI

First install Rapid-MLX and install Codex CLI. If you used the install script, restart Terminal or run export PATH="$HOME/.local/bin:$PATH" first. Then run:

$ rapid-mlx launch codex

Tomorrow: Run rapid-mlx launch codex again. Rapid reuses the saved profile, model, loopback key and port. It does not change your existing Codex CLI configuration. To remove only Rapid's private profile, run rapid-mlx launch codex --remove.

Mac unified memoryModel choicesDownload and memory guidance
16 GBqwen3.5-4b-4bit fits 16 GB per the registry; not verified live on a 16 GB Mac.About 3 GB download.
18–36 GBqwen3.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.

First reply: The first reply can take longer than later turns: an uncached model must download, the server must load it, and the agent may send a long prompt that takes time to prefill. Wait for the model to become ready; there is no fixed first-reply time. A warm, cached model is usually quicker.

Quick answer

How do I use Codex CLI with a local model on Mac? Install Rapid-MLX, then run rapid-mlx launch codex. The same command reconnects on another day; --remove removes Rapid's private profile.

The agent hub covers the other supported agents. The alternative three-step setup below edits your regular agent configuration; launch uses Rapid’s private profile.

Alternative: local setup in 3 steps (edits your regular config)

# 1. Install
brew install rapid-mlx
brew install codex
# 2. Terminal 1: start the model; leave running
rapid-mlx serve qwen3.5-9b-4bit
# 3. Terminal 2: configure and send a request
rapid-mlx agents codex --setup
codex exec --skip-git-repo-check "say hello"

Wait for the server to be ready before step 3. Setup merges your regular agent settings and writes them without a confirmation prompt. Add --dry-run to describe the planned write without changing files. A text reply confirms the connection; it does not prove a coding task will succeed. Choose a model that fits your Mac.

TIER-1 AGENT   Wire: /v1/responses · Setup: rapid-mlx agents codex --setup · Matrix cell: ✅ ✅ ✅ ✅ (Qwen 3.6 / Gemma 4 / DeepSeek / gpt-oss on 2026-07-07 pilot).
Re-verified 2026-08-01 — a /v1/responses wire smoke, on 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

Homebrew or npm — Codex CLI is upstream OpenAI, install the vendor binary:

$ brew install codex
# or
$ npm install -g @openai/codex

Config

rapid-mlx agents codex --setup writes ~/.codex/config.toml (or $CODEX_HOME/config.toml). It also writes rapid-mlx-model-catalog.json next to it, a local model catalog. This stops Codex from using its flagship fallback metadata on the first turn, before its remote catalog request completes. An existing config.toml is merged: your other keys (approval_policy, [mcp_servers.*], [projects.*] …) are kept, but TOML comments are not, and no backup is made. Setup uses the server when reachable. If it is not running, setup can finish with a known model and prints the matching start command; a config that is already current is left untouched. --dry-run previews without writing.

Setup then prints a Saved Codex defaults report, read back from the files it wrote: model, provider, endpoint and catalog. The catalog must contain the saved model's exact id. A passed connection check means the server answered its health and model-list checks, not that a coding task has run. Project settings, profiles and codex --model / --config can override these defaults; if Codex reports an unknown model or generic model metadata, compare its model id with the one setup printed. A full Hugging Face repo name and its short alias are different catalog ids even for the same weights, so to use another id rerun setup with --model set to it.

# ~/.codex/config.toml
model = "qwen3.5-9b-4bit"
model_provider = "rapid-mlx"
model_context_window = 262144
model_catalog_json = "/Users/you/.codex/rapid-mlx-model-catalog.json"
sandbox_mode = "workspace-write"

[model_providers.rapid-mlx]
name = "Rapid-MLX (local)"
base_url = "http://localhost:8000/v1"

model and model_context_window come from the running server. The values above are for qwen3.5-9b-4bit. The generated base_url includes /v1. With --base-url http://127.0.0.1:8899, setup and test accept the server root and setup appends /v1. An explicit API path, including a reverse-proxy prefix ending in /v1, is preserved. URLs with a query or fragment are rejected; use RAPID_MLX_API_KEY for authentication. sandbox_mode = "workspace-write" lets codex exec edit files in the workspace; if your config already sets sandbox_mode, setup keeps your value.

Auth. A bare rapid-mlx serve needs no key. If the server has one (--api-key, RAPID_MLX_API_KEY, or the Rapid-MLX desktop app, which mints a key on every launch), export RAPID_MLX_API_KEY before running setup: setup then adds env_key = "RAPID_MLX_API_KEY" to the provider block (the key itself is not written to the file). Keep it exported in the shell you run Codex from — Codex errors out if env_key names a variable that isn't set. Re-running setup without the variable against an unkeyed server removes that line again.

Run

$ rapid-mlx serve qwen3.5-9b-4bit
# in another shell:
$ codex
# headless one-shot (outside a trusted git repo, add --skip-git-repo-check):
$ codex exec --skip-git-repo-check "read main.py and summarize what it does"

Use the coding model table above to choose another model for your Mac.

Gotchas

Empirical

The codex-cli row of the integration matrix is ✅ across all four Tier-1 families (Qwen 3.6, Gemma 4, DeepSeek R1-Distill, gpt-oss) on the 2026-07-07 pilot. The matrix cell posts a minimal /v1/responses envelope, verifies the SSE-shaped output body is non-empty, and asserts no <think> or <|channel|>analysis leak in the emitted text. Source of truth for this page: tests/integrations/test_agents_matrix.py::TestCodexCLI and the CLI output of rapid-mlx agents codex.

See also

Build on the same local server

Write a script with the OpenAI SDK, compare Claude Code, or inspect the measured Mac inference-server comparison. For tool-use results and model-specific limits, use the integration matrix.