3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

opencode on GLM-4.7-Flash-4bitをMacBookで動かす

Posted at

結論

ChromeとかVSCodeいっぱい開いてるPCじゃ48GB積んでもメモリ足りなくてリークして死ぬ
メモリガン積みか、opencodeだけ開くような環境でやりましょう

使ったモデル

Requirements

opencode

いろんなモデルをclaude codeのTUIで動かすやつ

brew install opencode

uv

pythonのパッケージマネージャー

brew install uv

mlx_ml

ollamaなLLMサーバー、MacでGPU動かす時に使うMLXで高速化を図るやつ
stableだとGLM-4.7が動かないのでprerelease版を使う

uv tool install mlx-lm
uv tool install --upgrade mlx-lm --prerelease=allow

setup

mkdir -p ~/.config/opencode
~/.config/opencode/opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "mlx": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "MLX (local)",
      "options": {
        "baseURL": "http://127.0.0.1:8080/v1"
      },
      "models": {
        "mlx-community/GLM-4.7-Flash-4bit": {
          "name": "GLM-4.7 Flash"
        }
      }
    }
  }
}

usage

mlx_lm サーバーで glm-4.7を実行

mlx_lm.server --model mlx-community/GLM-4.7-Flash-4bit --port 8080

opencode起動

opencode

起動後はconnectコマンドでMLX (Local) が繋がっているか確認

/connect

modelコマンドで使用するモデルをGLM-4.7 Flash (local)に指定

/model

あとはclaude codeと似たような感じでどうぞ

デスクトップアプリもあるのでGUIが良い人はそちらでー

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?