How to use apiKey with local models endpoint? #534

Closed
opened 2026-02-16 17:27:12 -05:00 by yindo · 4 comments
Owner

Originally created by @antonpetrovmain on GitHub (Jul 7, 2025).

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!

Originally created by @antonpetrovmain on GitHub (Jul 7, 2025). I am trying to use opencode with my local models, but my API requires an API KEY. Here is the configuration I tried: ```json { "$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!
yindo closed this issue 2026-02-16 17:27:12 -05:00
Author
Owner

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

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

@antonpetrovmain commented on GitHub (Jul 7, 2025): The above config is actually working, I had the config file in the wrong place, sorry.
Author
Owner

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

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

@thetloffline commented on GitHub (Jul 7, 2025): @antonpetrovmain Can you also provide the correct location where the config file should be.
Author
Owner

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

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

@antonpetrovmain commented on GitHub (Jul 7, 2025): https://opencode.ai/docs/config/
Author
Owner

@suwhs commented on GitHub (Jul 17, 2025):

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 commented on GitHub (Jul 17, 2025): 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": {} } } } }
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#534