Improve documentation for self-hosted LLMs #480

Open
opened 2026-02-16 17:27:01 -05:00 by yindo · 9 comments
Owner

Originally created by @dcieslak19973 on GitHub (Jul 3, 2025).

Originally assigned to: @thdxr on GitHub.

Unclear how to configure opencode when using a self-hosted (through LiteLLM Proxy for example) OpenAI-compatible provider.

Originally created by @dcieslak19973 on GitHub (Jul 3, 2025). Originally assigned to: @thdxr on GitHub. Unclear how to configure `opencode` when using a self-hosted (through LiteLLM Proxy for example) OpenAI-compatible provider.
Author
Owner

@jayair commented on GitHub (Jul 3, 2025):

We have this currently, https://opencode.ai/docs/models/#local

What else would you want to see here?

@jayair commented on GitHub (Jul 3, 2025): We have this currently, https://opencode.ai/docs/models/#local What else would you want to see here?
Author
Owner

@dcieslak19973 commented on GitHub (Jul 3, 2025):

Sorry, it wasn't totally clear to me where to put things initially. Perhaps a more flushed out config such as:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "litellm": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://your.url.here/v1",
        "apiKey": "YourKeyHere"
      },
      "models": {
        "gpt-4o": {
          "name": "GPT-4o",
          "attachment": true,
          "reasoning": false,
          "temperature": true,
          "tool_call": true,
          "cost": {
            "input": 0.0025,
            "output": 0.01
          },
          "limit": {
            "context": 128000,
            "output": 4096
          }
        },
        "gpt-4o-mini": {
          "name": "GPT-4o Mini",
          "attachment": true,
          "reasoning": false,
          "temperature": true,
          "tool_call": true,
          "cost": {
            "input": 0.00015,
            "output": 0.0006
          },
          "limit": {
            "context": 128000,
            "output": 16384
          }
        },
        "claude-3-5-sonnet-20241022": {
          "name": "Claude 3.5 Sonnet",
          "attachment": true,
          "reasoning": false,
          "temperature": true,
          "tool_call": true,
          "cost": {
            "input": 0.003,
            "output": 0.015
          },
          "limit": {
            "context": 200000,
            "output": 8192
          }
        }
      }
    }
  },
  "model": "litellm/gpt-4o",
  "autoshare": false,
  "autoupdate": true,
  "theme": "default"
}
@dcieslak19973 commented on GitHub (Jul 3, 2025): Sorry, it wasn't totally clear to me where to put things initially. Perhaps a more flushed out config such as: ```json { "$schema": "https://opencode.ai/config.json", "provider": { "litellm": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "https://your.url.here/v1", "apiKey": "YourKeyHere" }, "models": { "gpt-4o": { "name": "GPT-4o", "attachment": true, "reasoning": false, "temperature": true, "tool_call": true, "cost": { "input": 0.0025, "output": 0.01 }, "limit": { "context": 128000, "output": 4096 } }, "gpt-4o-mini": { "name": "GPT-4o Mini", "attachment": true, "reasoning": false, "temperature": true, "tool_call": true, "cost": { "input": 0.00015, "output": 0.0006 }, "limit": { "context": 128000, "output": 16384 } }, "claude-3-5-sonnet-20241022": { "name": "Claude 3.5 Sonnet", "attachment": true, "reasoning": false, "temperature": true, "tool_call": true, "cost": { "input": 0.003, "output": 0.015 }, "limit": { "context": 200000, "output": 8192 } } } } }, "model": "litellm/gpt-4o", "autoshare": false, "autoupdate": true, "theme": "default" } ```
Author
Owner

@StevenUS commented on GitHub (Jul 7, 2025):

I'm lost at how to use a local model as well. I'm running models via Ollama. I've read through all of the documentation. I attempted to copy the config above into /Users/myuser/.config/opencode/opencode.json

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "http://localhost:11434"
      },
      "models": {
        "gemma3:4b": {
          "name": "Gemma 3 4B",
          "attachment": true,
          "reasoning": false,
          "temperature": true,
          "tool_call": false,
          "cost": {
            "input": 0,
            "output": 0
          },
          "limit": {
            "context": 8192,
            "output": 2048
          }
        }
      }
    }
  },
  "model": "ollama/gemma3:4b",
  "autoshare": false,
  "autoupdate": true,
  "theme": "default"
}

The error I get when I try opencode run

ERROR 2025-07-07T17:28:46 +2ms service=default name=Error message=no providers found fatal

When I try opencode models, the list is blank.

I've installed @ai-sdk/openai-compatible globally using npm.

There is no information on auth for local models. My Ollama server doesn't require auth.

@StevenUS commented on GitHub (Jul 7, 2025): I'm lost at how to use a local model as well. I'm running models via Ollama. I've read through all of the documentation. I attempted to copy the config above into `/Users/myuser/.config/opencode/opencode.json` ```json { "$schema": "https://opencode.ai/config.json", "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "http://localhost:11434" }, "models": { "gemma3:4b": { "name": "Gemma 3 4B", "attachment": true, "reasoning": false, "temperature": true, "tool_call": false, "cost": { "input": 0, "output": 0 }, "limit": { "context": 8192, "output": 2048 } } } } }, "model": "ollama/gemma3:4b", "autoshare": false, "autoupdate": true, "theme": "default" } ``` The error I get when I try `opencode run` ``` ERROR 2025-07-07T17:28:46 +2ms service=default name=Error message=no providers found fatal ``` When I try `opencode models`, the list is blank. I've installed `@ai-sdk/openai-compatible` globally using npm. There is no information on auth for local models. My Ollama server doesn't require auth.
Author
Owner

@rnusser commented on GitHub (Jul 8, 2025):

For Ollama models simply add an apiKey field and it works. For example this complete config works:

 {
  "$schema": "https://opencode.ai/config.json",
  "theme": "opencode",
  "autoshare": false,
  "autoupdate": true,
  "model": "ollama/starcoder",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Ollama",
      "options": {
        "baseURL": "http://localhost:11434/v1",
        "apiKey": "AnythingHere"
      },
      "models": {
        "qwen3:14b": {
          "name": "Qwen3 14B"
        }
      }
    }
  }
}
@rnusser commented on GitHub (Jul 8, 2025): For Ollama models simply add an `apiKey` field and it works. For example this complete config works: ``` { "$schema": "https://opencode.ai/config.json", "theme": "opencode", "autoshare": false, "autoupdate": true, "model": "ollama/starcoder", "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "name": "Ollama", "options": { "baseURL": "http://localhost:11434/v1", "apiKey": "AnythingHere" }, "models": { "qwen3:14b": { "name": "Qwen3 14B" } } } } } ```
Author
Owner

@StevenUS commented on GitHub (Jul 8, 2025):

Thanks, I got it working with a config similar to what @rnusser shared.
My issue was that I used the wrong name for my global config file
/Users/myuser/.config/opencode/opencode.json should have been /Users/myuser/.config/opencode/config.json

This confusion was due to the documentation for models showing the file name of a local config opencode.json rather than the global config file name which is explained in the config section of the documentation.

@StevenUS commented on GitHub (Jul 8, 2025): Thanks, I got it working with a config similar to what @rnusser shared. My issue was that I used the wrong name for my global config file `/Users/myuser/.config/opencode/opencode.json` should have been `/Users/myuser/.config/opencode/config.json` This confusion was due to the documentation for models showing the file name of a local config `opencode.json` rather than the global config file name which is explained in the config section of the documentation.
Author
Owner

@marad commented on GitHub (Jul 10, 2025):

I cannot - for the life of mine - configure the Ollama provider.
I've placed the config.json into ~/.config/opencode/config.json:

{
  "$schema": "https://opencode.ai/config.json",
  "autoshare": false,
  "autoupdate": true,
  "theme": "default",
  "model": "ollama/qwen2.5-coder",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Ollama @ Radon",
      "options": {
        "baseURL": "http://192.168.1.157:11434/v1",
        "apiKey": "ollama"
      },
      "models": {
        "qwen2.5-coder": {
          "name": "qwen2.5 coder"
        },
        "gemma3": {
          "name": "gemma3"
        },
        "codellama": {
          "name": "codellama"
        }
      }
    }
  }
}

And opencode doesn't pick that up. It doesn't even change the theme, like opencode was never reading this file at all.

I'm on the v0.0.55 - am I missing something here?

@marad commented on GitHub (Jul 10, 2025): I cannot - for the life of mine - configure the Ollama provider. I've placed the config.json into `~/.config/opencode/config.json`: ```json { "$schema": "https://opencode.ai/config.json", "autoshare": false, "autoupdate": true, "theme": "default", "model": "ollama/qwen2.5-coder", "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "name": "Ollama @ Radon", "options": { "baseURL": "http://192.168.1.157:11434/v1", "apiKey": "ollama" }, "models": { "qwen2.5-coder": { "name": "qwen2.5 coder" }, "gemma3": { "name": "gemma3" }, "codellama": { "name": "codellama" } } } } } ``` And opencode doesn't pick that up. It doesn't even change the theme, like opencode was never reading this file at all. I'm on the `v0.0.55` - am I missing something here?
Author
Owner

@deadcoder0904 commented on GitHub (Jul 14, 2025):

Same same but different. I can't figure out Cerebras. I think it is related. https://github.com/sst/opencode/issues/976

@deadcoder0904 commented on GitHub (Jul 14, 2025): Same same but different. I can't figure out Cerebras. I think it is related. https://github.com/sst/opencode/issues/976
Author
Owner

@madflow commented on GitHub (Jul 18, 2025):

@marad ~/.config/opencode/opencode.json maybe? At least that is what the docs say .

@madflow commented on GitHub (Jul 18, 2025): @marad `~/.config/opencode/opencode.json` maybe? At least that is what the [docs say ](https://opencode.ai/docs/config/#global).
Author
Owner

@gergob commented on GitHub (Nov 27, 2025):

In my case, I get an error of Error: Was there a typo in the url or port? but the URL is correct for Ollama server.

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Ollama (server)",
      "options": {
        "baseURL": "http://192.168.0.243:11434/v1",
      },
      "models": {
        "gpt-oss:latest": {
          "id": "gpt-oss:latest"
        }
      }
    }
  }
}

What is interesting if I use http://localhost:11434/v1 as URL it works well, it also works with LM Studio. The network settings are OK because I can curl the server and I get the models back.

Any hints on this one, is this a bug in opencode ?

@gergob commented on GitHub (Nov 27, 2025): In my case, I get an error of `Error: Was there a typo in the url or port?` but the URL is correct for Ollama server. ```json { "$schema": "https://opencode.ai/config.json", "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "name": "Ollama (server)", "options": { "baseURL": "http://192.168.0.243:11434/v1", }, "models": { "gpt-oss:latest": { "id": "gpt-oss:latest" } } } } } ``` What is interesting if I use `http://localhost:11434/v1` as URL it works well, it also works with LM Studio. The network settings are OK because I can curl the server and I get the models back. Any hints on this one, is this a bug in opencode ?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#480