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

Qwen Code

Since 1.0.4, Qwen Code starts with a valid empty settings file in its isolated home.

QwenLM/qwen-code is Alibaba's coding CLI, tuned for the Qwen 3 tool format. It speaks the plain OpenAI wire through an openai entry in the modelProviders block of its settings file.

Quick start

Needs: Qwen Code (npm install -g @qwen-code/qwen-code@latest); start the server before sending requests (rapid-mlx serve qwen3.5-9b-4bit).

$ rapid-mlx agents qwen-code --setup
$ qwen -p "say hello"               # a reply = it works

A reply confirms the local connection. For coding tasks, check the requested tool ran and inspect its output. Setup keeps your other OpenAI-compatible providers in ~/.qwen/settings.json and adds or updates the served model entry.

Wire: /v1/chat/completions · Setup: rapid-mlx agents qwen-code --setup · Matrix cell: ✅ ✅ XFAIL(arch) ✅ (DeepSeek R1-Distill — see XFAIL arch).

Install

$ npm install -g @qwen-code/qwen-code@latest

Config

Run setup before or after starting the server: rapid-mlx agents qwen-code --setup writes ~/.qwen/settings.json, filling in the model and context window the server reports. It shows the exact diff, asks before writing (--yes in scripts) and backs up an existing file. Your other keys are kept, and in the modelProviders.openai list only the entry with rapid-mlx's model id is added or updated; other providers stay as they are, including their keys, which the preview redacts. Setup sets env.RAPID_MLX_API_KEY in the file to the template's placeholder. A file that is not valid JSON is refused, not overwritten. --dry-run previews without writing. The template:

// ~/.qwen/settings.json
{
  "modelProviders": {
    "openai": [
      {
        "id": "qwen3.5-9b-4bit",
        "name": "qwen3.5-9b-4bit (Rapid-MLX)",
        "envKey": "RAPID_MLX_API_KEY",
        "baseUrl": "http://localhost:8000/v1",
        "generationConfig": {
          "timeout": 300000,
          "maxRetries": 1,
          "contextWindowSize": 262144,
          "samplingParams": {"max_tokens": 8192}
        }
      }
    ]
  },
  "env": {"RAPID_MLX_API_KEY": "not-needed"},
  "security": {"auth": {"selectedType": "openai"}},
  "model": {"name": "qwen3.5-9b-4bit"}
}

Run

$ rapid-mlx serve qwen3.5-9b-4bit
$ qwen                                   # interactive
$ qwen -p "explain what main.py does"       # headless one-shot
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.

Gotchas

Empirical

The qwen-code row of the integration matrix is ✅ on Qwen 3.6, Gemma 4, and gpt-oss; DeepSeek R1-Distill XFAIL(arch). Source of truth for this page: TestQwenCode + rapid-mlx agents qwen-code.

See also