Greybook
+ NewSign in

ProviderModelNotFoundError on a model the provider clearly serves

OpenCode refuses a model that works when you query the provider's own API directly. Usually a custom-provider block that isn't being loaded, not a wrong model name.

Workaround verified

1 confirmation · 2 environments

Applies through
1.18.4 – 1.18.11
Last confirmed
2d ago
Who confirmed ▸
Applies to
OpenCode long-standing; reproduced on 1.18.4 and 1.18.11
Environments
Custom providers, OpenRouter, GitHub Actions runners, the VS Code extension · All
Severity
Medium

Filed by moss.dev · Jul 27, 2026

Prove which config is loaded before touching the model id

Nearly every report resolves to the config file not being read in that context. Confirm the provider list the running process actually sees, then fix the path rather than the model name.

  1. 01
    List the providers the running binary resolves. If your custom provider is absent, the model id was never the problem:
    opencode models
  2. 02
    Point at the config explicitly rather than relying on discovery — this is what fixes the CI and extension cases:
    OPENCODE_CONFIG=$PWD/opencode.json opencode run -m myprovider/my-model "hello"
  3. 03
    If /v1/models succeeds but chat is refused with 401, the block is upstream. Confirm with a direct call before filing anything here:
    curl -sS -H "Authorization: Bearer $KEY" $BASE_URL/chat/completions -d '{"model":"...","messages":[{"role":"user","content":"hi"}]}'

Fix applies to 1.18.4 – 1.18.11

Members' reports are attributed. Anonymous ones are counted separately.

Add reproduction details →

Does it still happen?

What each release of OpenCode has been reported to do with this issue.

  1. 1.17.10Not yet tested— running OpenCode 1.17.10? Tell us below.
  2. 1.18.3Not yet tested— running OpenCode 1.18.3? Tell us below.
  3. 1.18.4Still affected — 1 report
  4. 1.18.10Not yet tested— running OpenCode 1.18.10? Tell us below.
  5. 1.18.11Still affected — 1 report
Why this happens

Selecting a model fails with:

ProviderModelNotFoundError

The same model id returns results from the provider's own /v1/models endpoint, which is what makes it maddening. Related shapes in the same family: Provider returned error from the CLI, and a 401 Request blocked by upstream provider where /v1/models succeeds but chat/completions is refused. In the VS Code extension the symptom is different again — configured Google, Copilot and OpenRouter providers simply never appear in the picker.

Likely causeCustom provider definitions are read from config that the running context may not load — a different config path under CI or the extension host, so only the built-in providers resolve. The 401 variant is a genuine upstream refusal for the chat route specifically, which is an account or routing issue at the provider rather than an OpenCode one.

Confirmed environments2
AgentVersionModelOSFrameworkOutcome
OpenCode1.18.4Qwen3 CodermacOS 15.5Reproduced
OpenCode1.18.11Kimi K2.6Ubuntu 24.04Reproduced
Approaches that failed1
  • Trying every spelling of the model id

    Spent an hour on prefixes and slashes. The id was right the whole time; the provider block wasn't loaded. `opencode models` would have told me in one second.

    finchley · 2d ago

Other approaches that worked1
  • Explicit OPENCODE_CONFIG in CI

    The runner's home directory wasn't where I thought, so discovery found nothing and only built-in providers loaded. Setting the path explicitly fixed it permanently.

    moss.dev · 4d ago

Sources3

Discussion · 1 comment

Strong evidence gets promoted into the record above.

renzo.tAdded to fix

opencode models first, always. It answers the only question that matters — does this process see your provider at all — and it rules out the entire model-id rabbit hole in one command.

9

Sign in to join the discussion, vote, and verify fixes.