How to configure a local large model #1146

Open
opened 2026-02-16 17:29:37 -05:00 by yindo · 15 comments
Owner

Originally created by @Khanviph on GitHub (Aug 7, 2025).

Originally assigned to: @thdxr on GitHub.

How to configure a local large model
1.I use Ollama
2.Model gpt-oss:120b

Originally created by @Khanviph on GitHub (Aug 7, 2025). Originally assigned to: @thdxr on GitHub. How to configure a local large model 1.I use Ollama 2.Model gpt-oss:120b
Author
Owner

@tommyboylab commented on GitHub (Aug 7, 2025):

Something like this, adjust for gpt based model:

https://opencode.ai/docs/providers/#ollama

{
"$schema": "https://opencode.ai/config.json",
"provider": {
"ollama": {
"npm": "@ai-sdk/openai-compatible",
"name": "Ollama (local)",
"options": {
"baseURL": "http://localhost:11434/v1"
},
"models": {
"qwen3-coder:30b": {
"name": "Qwen3-Coder 30B (MoE 3.3B active)"
}
}
}
},
"model": "ollama/qwen3-coder:30b"
}

@tommyboylab commented on GitHub (Aug 7, 2025): Something like this, adjust for gpt based model: https://opencode.ai/docs/providers/#ollama { "$schema": "https://opencode.ai/config.json", "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "name": "Ollama (local)", "options": { "baseURL": "http://localhost:11434/v1" }, "models": { "qwen3-coder:30b": { "name": "Qwen3-Coder 30B (MoE 3.3B active)" } } } }, "model": "ollama/qwen3-coder:30b" }
Author
Owner

@ghwiegand commented on GitHub (Aug 7, 2025):

Thank you @tommyboylab !

Ive tested it with your json and just changed the model definitions to the new gpt-oss variants and it works - not good in terms of model capability - but the communication to ollama works.

Here is how I achieved it:

  1. Installed ollama and opencode
  2. Started ollama (ollama start) and pulled the gpt-oss 20b model (ollama run gpt-oss:20b).
  3. Created a the opencode.jsonconfig file in my project folder with:
{
    "$schema": "https://opencode.ai/config.json",
    "provider": {
        "ollama": {
            "npm": "@ai-sdk/openai-compatible",
            "name": "Ollama (local)",
            "options": {
                "baseURL": "http://localhost:11434/v1"
            },
            "models": {
                "gpt-oss:20b": {
                    "name": "gpt-oss 20b local"
                }
            }
        }
    },
    "model": "ollama/gpt-oss:20b"
}
  1. Start opencode in the project directory.

I would recommend for testing to leave the terminal with the ollama start open to see the logs. There you can see if your model gets used by opencode and if its working at the moment.

Happy coding 👨‍💻

@ghwiegand commented on GitHub (Aug 7, 2025): Thank you @tommyboylab ! Ive tested it with your json and just changed the model definitions to the new gpt-oss variants and it works - not good in terms of model capability - but the communication to ollama works. Here is how I achieved it: 1. Installed ollama and opencode 2. Started ollama (`ollama start`) and pulled the gpt-oss 20b model (`ollama run gpt-oss:20b`). 3. Created a the `opencode.json`config file in my project folder with: ```json { "$schema": "https://opencode.ai/config.json", "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "name": "Ollama (local)", "options": { "baseURL": "http://localhost:11434/v1" }, "models": { "gpt-oss:20b": { "name": "gpt-oss 20b local" } } } }, "model": "ollama/gpt-oss:20b" } ``` 4. Start `opencode` in the project directory. I would recommend for testing to leave the terminal with the `ollama start` open to see the logs. There you can see if your model gets used by opencode and if its working at the moment. Happy coding 👨‍💻
Author
Owner

@Gaetner84 commented on GitHub (Aug 7, 2025):

Auto-generate opencode.json for Ollama (via Bash)

This script allows you to automatically create a valid opencode.json configuration for [OpenCode](https://opencode.ai), based on the models currently available in your local [Ollama](https://ollama.com) instance.

🧠 What it does

  • Connects to your local Ollama server (IP or localhost)
  • Retrieves available model names via API
  • Lets you select a model using fzf
  • Writes a proper opencode.json file in the required format

📜 The Bash Script

#!/bin/bash

# OLLAMA Host/IP (adjust if needed)
OLLAMA_HOST="http://localhost:11434"

# Get list of available models
MODELS=$(curl -s "$OLLAMA_HOST/api/tags" | jq -r '.models[].name')

# Select model using fuzzy finder (fzf)
SELECTED=$(echo "$MODELS" | fzf --prompt="Choose a model > ")

# Exit if no model is selected
if [ -z "$SELECTED" ]; then
  echo "❌ No model selected – aborting."
  exit 1
fi

# Write opencode.json
cat > opencode.json <<EOF
{
  "\$schema": "https://opencode.ai/config.json",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Ollama (local)",
      "options": {
        "baseURL": "$OLLAMA_HOST/v1"
      },
      "models": {
        "$SELECTED": {
          "name": "$SELECTED"
        }
      }
    }
  },
  "model": "ollama/$SELECTED"
}
EOF

echo "✅ opencode.json created with model: $SELECTED"

⚙️ Requirements

Make sure the following tools are installed:


🧪 How to use

  1. Save the script as generate-opencode.sh

  2. Make it executable:

    chmod +x generate-opencode.sh
    
  3. Run it:

    ./generate-opencode.sh
    

After running, you'll have a valid opencode.json that points to the exact Ollama model you selected.

You can now launch OpenCode and it will use that model directly.


🧩 Example opencode.json Output

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Ollama (local)",
      "options": {
        "baseURL": "http://localhost:11434/v1"
      },
      "models": {
        "llama3:8b": {
          "name": "llama3:8b"
        }
      }
    }
  },
  "model": "ollama/llama3:8b"
}

@Gaetner84 commented on GitHub (Aug 7, 2025): ## ✅ Auto-generate `opencode.json` for Ollama (via Bash) This script allows you to **automatically create a valid `opencode.json` configuration** for [[OpenCode](https://opencode.ai/)](https://opencode.ai), based on the models currently available in your local [[Ollama](https://ollama.com/)](https://ollama.com) instance. ### 🧠 What it does * Connects to your local Ollama server (IP or localhost) * Retrieves available model names via API * Lets you select a model using `fzf` * Writes a proper `opencode.json` file in the required format --- ### 📜 The Bash Script ```bash #!/bin/bash # OLLAMA Host/IP (adjust if needed) OLLAMA_HOST="http://localhost:11434" # Get list of available models MODELS=$(curl -s "$OLLAMA_HOST/api/tags" | jq -r '.models[].name') # Select model using fuzzy finder (fzf) SELECTED=$(echo "$MODELS" | fzf --prompt="Choose a model > ") # Exit if no model is selected if [ -z "$SELECTED" ]; then echo "❌ No model selected – aborting." exit 1 fi # Write opencode.json cat > opencode.json <<EOF { "\$schema": "https://opencode.ai/config.json", "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "name": "Ollama (local)", "options": { "baseURL": "$OLLAMA_HOST/v1" }, "models": { "$SELECTED": { "name": "$SELECTED" } } } }, "model": "ollama/$SELECTED" } EOF echo "✅ opencode.json created with model: $SELECTED" ``` --- ### ⚙️ Requirements Make sure the following tools are installed: * [`[jq](https://stedolan.github.io/jq/)`](https://stedolan.github.io/jq/) – for JSON parsing * [`[fzf](https://github.com/junegunn/fzf)`](https://github.com/junegunn/fzf) – for model selection * `curl`, `bash` * Ollama running (`ollama start`) --- ### 🧪 How to use 1. Save the script as `generate-opencode.sh` 2. Make it executable: ```bash chmod +x generate-opencode.sh ``` 3. Run it: ```bash ./generate-opencode.sh ``` After running, you'll have a valid `opencode.json` that points to the exact Ollama model you selected. You can now launch OpenCode and it will use that model directly. --- ### 🧩 Example `opencode.json` Output ```json { "$schema": "https://opencode.ai/config.json", "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "name": "Ollama (local)", "options": { "baseURL": "http://localhost:11434/v1" }, "models": { "llama3:8b": { "name": "llama3:8b" } } } }, "model": "ollama/llama3:8b" } ``` ---
Author
Owner

@thdxr commented on GitHub (Aug 7, 2025):

don't use ollama use LM studio

@thdxr commented on GitHub (Aug 7, 2025): don't use ollama use LM studio
Author
Owner

@Gaetner84 commented on GitHub (Aug 8, 2025):

no i use ollama it is better on server and works perfect!

@Gaetner84 commented on GitHub (Aug 8, 2025): no i use ollama it is better on server and works perfect!
Author
Owner

@chbornman commented on GitHub (Aug 8, 2025):

This clearly works, so probably just close the issue?

Any suggestions on how to get opencode to work better with local models? I've only ever had good performance using opencode with Anthropic models

@chbornman commented on GitHub (Aug 8, 2025): This clearly works, so probably just close the issue? Any suggestions on how to get opencode to work better with local models? I've only ever had good performance using opencode with Anthropic models
Author
Owner

@nathfavour commented on GitHub (Aug 20, 2025):

don't use ollama use LM studio

Why tho

@nathfavour commented on GitHub (Aug 20, 2025): > don't use ollama use LM studio Why tho
Author
Owner

@rekram1-node commented on GitHub (Aug 20, 2025):

LM studio seems much more reliable, I consistently see people having ollama issues because they arent handling certain models correctly, like they had some issue with qwen models (or some other one) were they didnt parse out tool calls properly and it was an issue for a while…

@rekram1-node commented on GitHub (Aug 20, 2025): LM studio seems much more reliable, I consistently see people having ollama issues because they arent handling certain models correctly, like they had some issue with qwen models (or some other one) were they didnt parse out tool calls properly and it was an issue for a while…
Author
Owner

@vpereira commented on GitHub (Nov 30, 2025):

if i have a webui as frontend to ollama. My gpt-oss keeps returning "max_tokens must be at least 1, got -1928." even though I can connect it with my zed or even via cli.

@vpereira commented on GitHub (Nov 30, 2025): if i have a webui as frontend to ollama. My gpt-oss keeps returning "max_tokens must be at least 1, got -1928." even though I can connect it with my zed or even via cli.
Author
Owner

@rekram1-node commented on GitHub (Dec 2, 2025):

@vpereira can you send me output of: opencode debug config

@rekram1-node commented on GitHub (Dec 2, 2025): @vpereira can you send me output of: `opencode debug config`
Author
Owner

@vpereira commented on GitHub (Dec 4, 2025):

@vpereira can you send me output of: opencode debug config

sure, here it is:

➜ opencode debug config
{
  "$schema": "https://opencode.ai/config.json",
  "model": "openwebui/qwen3-coder:30b",
  "provider": {
    "openwebui": {
      "name": "Remote DeepSeek Coder",
      "npm": "@ai-sdk/openai-compatible",
      "models": {
        "deepseek-coder-v2:16b": {
          "name": "deepseek-coder-v2:16b (remote)",
          "limit": {
            "context": 32000,
            "output": 4000
          }
        },
        "gpt-oss": {
          "name": "gpt-oss",
          "limit": {
            "context": 8192,
            "output": 1024
          }
        },
        "qwen3-coder:30b": {
          "name": "qwen3-coder:30b"
        }
      },
      "options": {
        "baseURL": "https://ollama.myhome.xyz/api"
      }
    }
  },
  "agent": {},
  "mode": {},
  "plugin": [],
  "command": {},
  "username": "kimura",
  "keybinds": {
    "leader": "ctrl+x",
    "app_exit": "ctrl+c,ctrl+d,<leader>q",
    "editor_open": "<leader>e",
    "theme_list": "<leader>t",
    "sidebar_toggle": "<leader>b",
    "status_view": "<leader>s",
    "session_export": "<leader>x",
    "session_new": "<leader>n",
    "session_list": "<leader>l",
    "session_timeline": "<leader>g",
    "session_share": "none",
    "session_unshare": "none",
    "session_interrupt": "escape",
    "session_compact": "<leader>c",
    "messages_page_up": "pageup",
    "messages_page_down": "pagedown",
    "messages_half_page_up": "ctrl+alt+u",
    "messages_half_page_down": "ctrl+alt+d",
    "messages_first": "ctrl+g,home",
    "messages_last": "ctrl+alt+g,end",
    "messages_copy": "<leader>y",
    "messages_undo": "<leader>u",
    "messages_redo": "<leader>r",
    "messages_toggle_conceal": "<leader>h",
    "model_list": "<leader>m",
    "model_cycle_recent": "f2",
    "model_cycle_recent_reverse": "shift+f2",
    "command_list": "ctrl+p",
    "agent_list": "<leader>a",
    "agent_cycle": "tab",
    "agent_cycle_reverse": "shift+tab",
    "input_clear": "ctrl+c",
    "input_forward_delete": "ctrl+d",
    "input_paste": "ctrl+v",
    "input_submit": "return",
    "input_newline": "shift+return,ctrl+j",
    "history_previous": "up",
    "history_next": "down",
    "session_child_cycle": "<leader>right",
    "session_child_cycle_reverse": "<leader>left",
    "terminal_suspend": "ctrl+z"
  }
}
@vpereira commented on GitHub (Dec 4, 2025): > [@vpereira](https://github.com/vpereira) can you send me output of: `opencode debug config` sure, here it is: ``` ➜ opencode debug config { "$schema": "https://opencode.ai/config.json", "model": "openwebui/qwen3-coder:30b", "provider": { "openwebui": { "name": "Remote DeepSeek Coder", "npm": "@ai-sdk/openai-compatible", "models": { "deepseek-coder-v2:16b": { "name": "deepseek-coder-v2:16b (remote)", "limit": { "context": 32000, "output": 4000 } }, "gpt-oss": { "name": "gpt-oss", "limit": { "context": 8192, "output": 1024 } }, "qwen3-coder:30b": { "name": "qwen3-coder:30b" } }, "options": { "baseURL": "https://ollama.myhome.xyz/api" } } }, "agent": {}, "mode": {}, "plugin": [], "command": {}, "username": "kimura", "keybinds": { "leader": "ctrl+x", "app_exit": "ctrl+c,ctrl+d,<leader>q", "editor_open": "<leader>e", "theme_list": "<leader>t", "sidebar_toggle": "<leader>b", "status_view": "<leader>s", "session_export": "<leader>x", "session_new": "<leader>n", "session_list": "<leader>l", "session_timeline": "<leader>g", "session_share": "none", "session_unshare": "none", "session_interrupt": "escape", "session_compact": "<leader>c", "messages_page_up": "pageup", "messages_page_down": "pagedown", "messages_half_page_up": "ctrl+alt+u", "messages_half_page_down": "ctrl+alt+d", "messages_first": "ctrl+g,home", "messages_last": "ctrl+alt+g,end", "messages_copy": "<leader>y", "messages_undo": "<leader>u", "messages_redo": "<leader>r", "messages_toggle_conceal": "<leader>h", "model_list": "<leader>m", "model_cycle_recent": "f2", "model_cycle_recent_reverse": "shift+f2", "command_list": "ctrl+p", "agent_list": "<leader>a", "agent_cycle": "tab", "agent_cycle_reverse": "shift+tab", "input_clear": "ctrl+c", "input_forward_delete": "ctrl+d", "input_paste": "ctrl+v", "input_submit": "return", "input_newline": "shift+return,ctrl+j", "history_previous": "up", "history_next": "down", "session_child_cycle": "<leader>right", "session_child_cycle_reverse": "<leader>left", "terminal_suspend": "ctrl+z" } } ```
Author
Owner

@rekram1-node commented on GitHub (Dec 4, 2025):

@vpereira im guessing u had the error w/ qwen3-coder:30b? I think that's because there is no limit set there

@rekram1-node commented on GitHub (Dec 4, 2025): @vpereira im guessing u had the error w/ `qwen3-coder:30b`? I think that's because there is no limit set there
Author
Owner

@vpereira commented on GitHub (Dec 5, 2025):

@vpereira im guessing u had the error w/ qwen3-coder:30b? I think that's because there is no limit set there

Hi @rekram1-node

No unfortunately, i get the following error:

My Prompt was: "Please analyse my code base"

I'll help you analyze your codebase. To do this properly, I'll need to explore your project structure and files. Let me start by examining what files and directories you have.
⚙ invalid [tool=todolist, error=Model tried to call unavailable tool 'todolist'. Available tools: invalid, bash, read, glob, grep, list, edit, write, task, webfetch, todowrite, todoread.]
@vpereira commented on GitHub (Dec 5, 2025): > [@vpereira](https://github.com/vpereira) im guessing u had the error w/ `qwen3-coder:30b`? I think that's because there is no limit set there Hi @rekram1-node No unfortunately, i get the following error: My Prompt was: "Please analyse my code base" ``` I'll help you analyze your codebase. To do this properly, I'll need to explore your project structure and files. Let me start by examining what files and directories you have. ⚙ invalid [tool=todolist, error=Model tried to call unavailable tool 'todolist'. Available tools: invalid, bash, read, glob, grep, list, edit, write, task, webfetch, todowrite, todoread.] ```
Author
Owner

@vpereira commented on GitHub (Dec 5, 2025):

im guessing u had the error w/ qwen3-coder:30b? I think that's because there is no limit set there

with the model gpt-oss, i get the error "max_tokens must be at least 1, got -2490."

OpenCode version 1.0.133

With aider I am able to use the model and interact with my file system

@vpereira commented on GitHub (Dec 5, 2025): > im guessing u had the error w/ `qwen3-coder:30b`? I think that's because there is no limit set there with the model `gpt-oss`, i get the error "max_tokens must be at least 1, got -2490." OpenCode version 1.0.133 With aider I am able to use the model and interact with my file system
Author
Owner

@Kaszanas commented on GitHub (Jan 5, 2026):

@vpereira im guessing u had the error w/ qwen3-coder:30b? I think that's because there is no limit set there

Hi @rekram1-node

No unfortunately, i get the following error:

My Prompt was: "Please analyse my code base"

I'll help you analyze your codebase. To do this properly, I'll need to explore your project structure and files. Let me start by examining what files and directories you have.
⚙ invalid [tool=todolist, error=Model tried to call unavailable tool 'todolist'. Available tools: invalid, bash, read, glob, grep, list, edit, write, task, webfetch, todowrite, todoread.]

I have the same issue.

@Kaszanas commented on GitHub (Jan 5, 2026): > > [@vpereira](https://github.com/vpereira) im guessing u had the error w/ `qwen3-coder:30b`? I think that's because there is no limit set there > > Hi [@rekram1-node](https://github.com/rekram1-node) > > No unfortunately, i get the following error: > > My Prompt was: "Please analyse my code base" > > ``` > I'll help you analyze your codebase. To do this properly, I'll need to explore your project structure and files. Let me start by examining what files and directories you have. > ⚙ invalid [tool=todolist, error=Model tried to call unavailable tool 'todolist'. Available tools: invalid, bash, read, glob, grep, list, edit, write, task, webfetch, todowrite, todoread.] > ``` I have the same issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1146