Skip to content

How to use apiKey with local models endpoint? #738

Closed

Description

@antonpetrovmain

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!

Activity

  1. antonpetrovmain commented on Jul 7, 2025

    @antonpetrovmain
    Author

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

  2. thetloffline commented on Jul 7, 2025

    @thetloffline

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

  3. antonpetrovmain commented on Jul 7, 2025

    @antonpetrovmain
    Author
  4. suwhs commented on Jul 17, 2025

    @suwhs

    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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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