opencode icon indicating copy to clipboard operation
opencode copied to clipboard

How to use apiKey with local models endpoint?

Open antonpetrovmain opened this issue 1 year ago • 4 comments

I am trying to use opencode with my local models, but my API requires an API KEY. Here is the configuration I tried:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "lmstudio": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "LMStudio",
      "options": {
        "baseURL": "https://my.domain.com/v1",
        "apiKey": "xxx-xxx-xxx-xxx-xxx"
      },
      "models": {
        "qwen3-32b": {
          "name": "Qwen3 32B"
        }
      }
    }
  }
}

But I get:

UnknownError              
AI_APICallError: Forbidden

Is this currently supported?

Thank you!

antonpetrovmain avatar Jul 07 '25 08:07 antonpetrovmain

The above config is actually working, I had the config file in the wrong place, sorry.

antonpetrovmain avatar Jul 07 '25 08:07 antonpetrovmain

@antonpetrovmain Can you also provide the correct location where the config file should be.

thetloffline avatar Jul 07 '25 11:07 thetloffline

https://opencode.ai/docs/config/

antonpetrovmain avatar Jul 07 '25 13:07 antonpetrovmain

same error. Opencode TUI totally ignores config and try to use Llama Llama-4-Scout-17B-16E-Instruct-FP8

my config: { "$schema": "https://opencode.ai/config.json", "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "http://localhost:11434/v1" }, "models": { "llama3.1": {} } } } }

suwhs avatar Jul 17 '25 09:07 suwhs