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

OpenCode MLX setup on Mac

Run rapid-mlx launch opencode to use OpenCode 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 OpenCode

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

$ rapid-mlx launch opencode

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

Choose a model for your Mac

Rapid-MLX serves local models on Apple Silicon through an OpenAI-compatible API. Choose by unified memory and the memory available after other applications have loaded:

Mac unified memoryModel choicesDownload and memory guidance
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. Only 32 GB was verified in this tier; 18–24 GB remains unverified.
48+ GBqwen3.5-9b-4bit responsive default; qwen3.8-27b-4bit higher-capability option.About 6 GB for 9B or 16 GB for 27B. The 27B option was verified on 48 GB and needs roughly 20–26 GB free unified memory; long-context cold prefill is slow.

Download size is not runtime memory use. Leave room for the client, context and other applications; keep context short when memory is tight.

Verification coverage: all listed aliases passed OpenCode tool-call loops on Rapid-MLX 1.1.0 with OpenCode 1.19.6; qwen3.5-9b-4bit additionally passed the same loop on OpenCode 2.3.2 using the 2.x configuration below exactly as written. These small read/edit/shell fixtures do not establish general coding quality or success on every tool workflow.

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 OpenCode with a local model on Mac? Install Rapid-MLX, then run rapid-mlx launch opencode. The same command reconnects on another day; --remove removes Rapid's private profile.

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

Install, serve and check readiness

Install OpenCode separately, then install Rapid-MLX and leave the server running in one terminal:

$ curl -fsSL https://rapidmlx.com/install.sh | bash
$ rapid-mlx serve qwen3.5-9b-4bit --port 8000

The installer must run under bash. After installation, restart your terminal if rapid-mlx is not on your PATH. The first launch downloads the selected model if it is not cached.

In another terminal, check that the model is available:

$ curl http://127.0.0.1:8000/v1/models

Alternatively, use rapid-mlx ps. A model listing confirms readiness to accept requests; a text reply alone does not demonstrate tool use.

Configure OpenCode

With the server ready, the setup shortcut merges settings into your regular OpenCode configuration:

$ rapid-mlx agents opencode --setup --model qwen3.5-9b-4bit --base-url http://127.0.0.1:8000/v1

Use --dry-run to preview the merge. This regular-config setup is separate from the private profile used by rapid-mlx launch opencode. Re-run setup after changing OpenCode major versions; add the timeout settings below for long prompts.

For manual setup on OpenCode 2.x, use this opencode.jsonc:

{
  "$schema": "https://opencode.ai/config.json",
  "model": "rapid-mlx/qwen3.5-9b-4bit",
  "providers": {
    "rapid-mlx": {
      "name": "Rapid-MLX",
      "package": "@opencode/ai/providers/openai-compatible",
      "settings": {
        "baseURL": "http://127.0.0.1:8000/v1",
        "headerTimeout": 1200000,
        "chunkTimeout": 1200000
      },
      "models": {
        "qwen3.5-9b-4bit": {
          "capabilities": {
            "tools": true,
            "input": ["text"],
            "output": ["text"]
          },
          "limit": {
            "context": 65536,
            "output": 4096
          }
        }
      }
    }
  }
}

Then run opencode in that project. When changing aliases, update the serve command, provider model key and selected model together, and use limits appropriate to the served model. If the endpoint requires authentication, add "apiKey": "{env:RAPID_MLX_API_KEY}" to settings and set that environment variable.

OpenCode 1.x uses singular provider, npm: "@ai-sdk/openai-compatible" and options; OpenCode 2.x uses providers, package: "@opencode/ai/providers/openai-compatible" and settings. Both were run live: the 1.x entry used name and limit without capabilities; the 2.x configuration above passed the same read/edit/test loop on OpenCode 2.3.2. Do not paste the 2.x configuration or its timeout fields into 1.x; use the setup shortcut for the installed major version.

Long prompts and timeouts

Cold prefill at 24k–48k tokens can take minutes on dense models, especially 27B. Keep sessions compact and reuse cached prefixes where possible. Allow a client timeout of at least 300 seconds, and increase it further for long-context 27B requests.

OpenCode 2.x takes settings.headerTimeout and settings.chunkTimeout in milliseconds. The example allows 20 minutes for response headers and between response chunks. A whole-request settings.timeout, if configured, must also allow enough time for prefill and generation. See the OpenCode timeout reference.

Troubleshooting

Schema references: current local-model configuration, provider timeout settings, and OpenCode 1.19.6 configuration.

Gotchas

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.