The following instructions show:
How to run a local model with “llamafile”.
Configure “opencode“(the local AI agent) to use the local model.
From “ChatGPT“ and the official documents.
Run Local Model
Download “llamafile” from here, in my case it’s “llamafile-0.10.3”.
Download a model from “huggingface“, such as “Qwen3-Coder-30B-A3B-Instruct-GGUF“. In my case “Qwen3-Coder-30B-A3B-Instruct-UD-Q6_K_XL.gguf” is used.
Run the local model with the following command:
1 | # More details can be found at "https://docs.mozilla.ai/llamafile/getting-started/quickstart". |
Configure “opencode” to Use The Local Model
Install “opencode“ if you didn’t yet. In my case I used “npm i -g opencode-ai” to install.
Update the “~/.config/opencode/opencode.json” file with the following content, which tells “opencode” how to use the local running model you started:
1 | { |
Note that there’ no API key is required for the local running model. Now you can start “opencode”. If everything works, you should be able to use the local model in it.