mlx-optiq
Integration · OpenCode

OpenCode

OpenCode is an open-source AI coding agent that reads, edits, and runs code in your project. It speaks the OpenAI Chat Completions API, which optiq serve exposes by default.

1. Install OpenCode

terminalbash
# macOS / Linux:
$ curl -fsSL https://opencode.ai/install | bash

# or via Homebrew:
$ brew install sst/tap/opencode

# or, project-local via npm (handy for CI / pinned versions):
$ npm install opencode-ai

2. Start optiq serve

terminalbash
$ optiq serve \
    --model mlx-community/Qwen3.5-9B-OptiQ-4bit \
    --mtp --mtp-depth 2 \
    --port 8080

3. Configure OpenCode

OpenCode reads custom providers from opencode.jsonc — global at ~/.config/opencode/opencode.jsonc, or per-project in the workspace root (overrides global). Drop in:

opencode.jsoncjson
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "optiq": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "OptIQ Local",
      "options": {
        "baseURL": "http://localhost:8080/v1",
        "apiKey": "sk-optiq-local"
      },
      "models": {
        "qwen-9b": {
          "name": "Qwen3.5-9B (OptIQ)"
        }
      }
    }
  },
  "model": "optiq/qwen-9b"
}

The key under models (here qwen-9b) becomes the model id OpenCode sends in the request body. optiq serve ignores the body's model field and serves whichever model you started it with, so any short alias works. Do not put an absolute filesystem path in the model key (OpenCode would treat it as a literal directory and try to read files relative to it).

Launch OpenCode in your project and start chatting:

terminalbash
# interactive TUI:
$ opencode

# or one-shot non-interactive:
$ opencode run --model optiq/qwen-9b "list the python files here and tell me what main.py does"

Notes

  • Tool use: OpenCode uses function calling for file edits and shell commands. Qwen3.5-9B-OptiQ and up handle this reliably; smaller models will chat but call tools unreliably.
  • Streaming: works.
  • MTP works transparently: OpenCode sees a normal OpenAI endpoint; the speculation happens server-side.
  • Verified: tested against opencode 1.15.4 on macOS (Apple Silicon).