The problem and the fix

In game development there are times you will want to automate a task with AI for example ChatGPT or Claude but they have limits then they charge you for more credits and because of the rammagedon barely anyone has 32 GB of ram which is enough to run a 14B model. Now if you were to switch to opencode you get models like big pickle but they also have credits and limits that reset monthly however you can actualy leverage opencode to your own advantage with local AI depending on your ram specs.

Steps

  1. download opencode for terminal at Opencode Website

This next step is not numbered due to the length:

Next you will want to download a local model like qwen 2.5 coder with a preferrable download filetype being a .llamafile, However 7B isnt always accessible, it depends on your ram:

If you have 8 GB of ram(Like the macbook neo) a good to the thumb are in the 3B to 4B range.

12-16 GB of ram(A macbook air or pro) should have a model in the 7B to 8B range

32 GB of ram(The 2013 trashcan mac pro with 4 8 GB sticks or 2 16 GB sticks) is optimal for a model in 7 to 27B models using 4-bit quantization or more.

64 GB of ram(A highly efficient computer) the optimal is 27-35B

If you have 128 GB or more RAM the optimal is 35B+

Booting the AI

  1. Download Visual Studio Code at Microsoft Visual Studio code

1A. You can also instead download Visual Studio Codium at Visual Studio Codium

  1. Open your terminal and run code ~/.config/opencode/opencode.json

2A. If you are using codium run codium ~/.config/opencode/opencode.json

  1. Add your model into the .json an example is
{ "provider": { "local-llamafile": { "npm": "@ai-sdk/openai-compatible", "name": "Local Llamafile Server", "options": { "baseURL": "http://localhost:8080/v1", "apiKey": "not-needed" }, "models": { "qwen2.5-coder-14b": { "name": "Qwen 2.5 Coder 7B", "limit": { "context": 32768, "output": 4096 } } } } }, "model": "local-llamafile/qwen2.5-coder-7b", "small_model": "local-llamafile/qwen2.5-coder-7b", } 
  1. Hook your MCP server to opencode via
"mcp": { "servers": { "mcp-name": { "type": "PLACEHOLDER", "command": ["/path-to-mcp"] } } } 
  1. Check if opencode has your model with opencode models if that fails run opencode models --standalone

  2. Once you find your model run opencode in your terminal to open the interface

  3. If your model is not selected in opencode type in the interface /models to switch.

  4. Give it a prompt(MAKE SURE OPENCODE IS RUNNING ON THE SAME PORT THE SERVER IS RUNNING ON)

Error Handling

You may encounter errors when running it in opencode, A common one is ECONNREFUSED.

Check if your opencode port matches the one your server is running on otherwise it will throw an ECONNREFUSED and rmeember to doublecheck if you downloaded the html instead of the actual AI brain.

Comparison

lemonade.gg gives you 4 free prompts than 20/mo for 100 prompts.

forgegui has 4 different plans each one cositng more but gives more credits.

zeroscript does not work when you are banned from an Ai service and it iwll most likely get you banned from the AI service you use.

Local AI has none of that.