Skip to content

opencode serve ignores model config and tries invalid model combination #12065

Closed

Description

@utensil

Description

opencode serve does not respect the model setting in opencode.json and attempts to use an invalid model combination, resulting in a ProviderModelNotFoundError.

1076 |     const info = provider.models[modelID]
1077 |     if (!info) {
1078 |       const availableModels = Object.keys(provider.models)
1079 |       const matches = fuzzysort.go(modelID, availableModels, { limit: 3, threshold: -10000 })
1080 |       const suggestions = matches.map((m) => m.target)
1081 |       throw new ModelNotFoundError({ providerID, modelID, suggestions })
                   ^
ProviderModelNotFoundError: ProviderModelNotFoundError
 data: {
  providerID: "local",
  modelID: "claude-sonnet-4.5",
  suggestions: [],
},

      at getModel (src/provider/provider.ts:1081:13)

Configuration

~/.config/opencode/opencode.json:

{
  "model": "local/deepseek-v3.2",
  "provider": {
    "local": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://my_valid_base_url"
      },
      "models": {
        "deepseek-v3.2": {}
      }
    }
  }
}

Expected Behavior

opencode serve should use local/deepseek-v3.2 as specified in the config.

Actual Behavior

Server attempts to use local/claude-sonnet-4.5 (invalid combination) and fails to respond.

Analysis

I used claude to debug opencode source, it tells me (after some long code analysis):

## Root Cause
The defaultModel() function is somehow returning {providerID: "local", modelID: "claude-sonnet-4.5"} instead of the configured {providerID: "local", modelID: "deepseek-v3.2"}
.

This suggests either:
1. cfg.model is not being loaded correctly in server context
2. The if (cfg.model) check is failing unexpectedly
3. The fallback logic is producing an invalid model combination

## Verification
- opencode debug config shows correct config with "model": "local/deepseek-v3.2"
- opencode models shows local/deepseek-v3.2 is available
- Regular opencode CLI works fine, only opencode serve fails

## Workaround
Setting OPENCODE_MODEL=local/deepseek-v3.2 opencode serve should work by bypassing the faulty config logic.

Plugins

none

OpenCode version

1.1.50

Steps to reproduce

  1. use the following config
{
  "model": "local/deepseek-v3.2",
  "provider": {
    "local": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://my_valid_base_url"
      },
      "models": {
        "deepseek-v3.2": {}
      }
    }
  }
}
  1. opencode run 'Hi' will correctly use this model
  2. opencode serve will correctly use this model for the web sessions, but not for API driven operations such as from https://github.com/ajoslin/opencode-telegram-mirror (it works fine for other providers that has claude-sonnet-4.5)

Screenshot and/or share link

No response

Operating System

macOS 15.4.1

Terminal

ghostty

Activity

  1. github-actions commented on Feb 4, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Both issues involve model configuration not being properly respected by the serve command and API. Feel free to ignore if your specific case differs from these.

  2. utensil commented on Feb 4, 2026

    @utensil
    Author

    #7099 seems to be reporting a similar issue but it has no fix or workaround, also I'm not using any plugins

  3. utensil commented on Feb 4, 2026

    @utensil
    Author
    ❯ opencode models
    opencode/big-pickle
    opencode/glm-4.7-free
    opencode/gpt-5-nano
    opencode/kimi-k2.5-free
    opencode/minimax-m2.1-free
    opencode/trinity-large-preview-free
    local/deepseek-v3.2
    

    (I intentionally logged out all other providers to avoid the confusion)

  4. github-actions commented on Apr 6, 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

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions