Skip to content

How to configure a local large model #1669

Closed as not planned
Closed as not planned

Description

@Khanviph

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

Activity

  1. tommyboylab commented on Aug 7, 2025

    @tommyboylab

    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"
    }

  2. ghwiegand commented on Aug 7, 2025

    @ghwiegand

    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 👨‍💻

  3. Gaetner84 commented on Aug 7, 2025

    @Gaetner84

    ✅ 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"
    }

  4. self-assigned this
    on Aug 7, 2025
  5. thdxr commented on Aug 7, 2025

    @thdxr
    Member

    don't use ollama use LM studio

  6. Gaetner84 commented on Aug 8, 2025

    @Gaetner84

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

  7. chbornman commented on Aug 8, 2025

    @chbornman

    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

  8. nathfavour commented on Aug 20, 2025

    @nathfavour

    don't use ollama use LM studio

    Why tho

  9. rekram1-node commented on Aug 20, 2025

    @rekram1-node
    Collaborator

    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…

  10. vpereira commented on Nov 30, 2025

    @vpereira

    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.

  11. rekram1-node commented on Dec 2, 2025

    @rekram1-node
    Collaborator

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

  12. vpereira commented on Dec 4, 2025

    @vpereira

    @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"
      }
    }
    
  13. rekram1-node commented on Dec 4, 2025

    @rekram1-node
    Collaborator

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

  14. vpereira commented on Dec 5, 2025

    @vpereira

    @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.]
    
  15. vpereira commented on 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

    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

  16. Kaszanas commented on Jan 5, 2026

    @Kaszanas

    @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.

  17. github-actions commented on Mar 25, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions