Repository navigation
Description
Description
Summary
Providers declared in the providers section of opencode.jsonc (with package: "aisdk:@ai-sdk/openai-compatible" and settings containing baseURL/apiKey) are never materialized into the provider registry in v2.0.15. They do not appear in context.provider.list(), nor in the plugin transform editor view (editor.get()/editor.list()), so custom providers configured purely via config are silently invisible and unusable.
Environment
- opencode version: 2.0.15
- OS: Windows_NT 10.0.19045 (win32 x64)
- Terminal: TERM=xterm-256color
- Shell: C:\WINDOWS\system32\cmd.exe
- Install/channel: latest (npm
@opencode/cli@2.0.15, also reproduced with side-by-sidenpm i --prefixinstall) - Active plugins: one local server plugin under
~/.config/opencode/plugin/(registers provider models viacontext.provider.transform)
Reproduction
-
Create
~/.config/opencode/opencode.jsoncwith a custom provider:{ "$schema": "https://opencode.ai/config.json", "providers": { "mygateway": { "package": "aisdk:@ai-sdk/openai-compatible", "name": "MyGateway", "settings": { "baseURL": "http://localhost:8080/v1", "apiKey": "<key>" }, "models": { "my-model": {} } } } } -
Run
opencode models(oropencode run -m mygateway/my-model "hi"). -
In a server plugin, call
await context.provider.list()and, insidecontext.provider.transform(editor => ...), calleditor.get("mygateway").
Expected Behavior
Per the SDK's own documentation, the registry view should include source definitions: ProviderRecord is documented as "Provider metadata and immutable source definitions, including inactive providers" (@opencode/plugin provider.d.ts). A providers entry in config is exactly such a source definition — and the config schema intentionally has no activation key, implying the server should materialize it without any user-side activation step. So mygateway should appear in both provider.list() and the transform editor view, with settings.apiKey/settings.baseURL readable.
Actual Behavior
context.provider.list()returns only the built-inopencodeprovider;mygatewayis absent.- Inside
transform,editor.get("mygateway")returnsundefinedon every invocation (verified across hundreds of transform passes, including the very first one with the config in place). opencode modelslists onlyopencode/*models.opencode run -m mygateway/my-modelfails withModelUnavailableError: Model unavailable: mygateway/my-model.- No error or warning is logged about the
providerssection — it parses cleanly (opencode debug configshows it normalized underproviders) but is silently never registered.
Additional Context
- This makes the documented v1 → v2 migration path (
provider→providers,npm→packagewithaisdk:prefix,options→settings) incomplete: the config normalizes fine but the provider never becomes usable. - Workaround we are using: a server plugin that re-declares the provider itself via
editor.add({ info: {...}, models: [...] })insidecontext.provider.transform, readingbaseURL/apiKeyfrom environment variables because the configsettingsare unreachable. This works, but defeats the purpose of declaring the provider in config. - One path we did NOT test: calling
await context.provider.reload()beforetransform— its behavior is undocumented. Ifreload()is supposed to re-materialize config-defined providers, that would be an acceptable fix; happy to test. - Possibly related:
disabled_providers: ["opencode"]in the same config also appears to have no effect (theopencodeprovider still lists its models), suggesting config-driven provider state in general may not be wired to the registry in this version.
Plugins
- opencode-agents-monitor@0.2.0-beta.0 (npm, TUI plugin via cli.json
plugins) - custom-models (local server plugin at ~/.config/opencode/plugin/custom-models.ts) — re-registers the custom provider via context.provider.transform + editor.add; this is the workaround, not the cause
OpenCode version
2.0.15
Steps to reproduce
- Add a custom provider to ~/.config/opencode/opencode.jsonc:
"providers": {
"mygateway": {
"package": "aisdk:@ai-sdk/openai-compatible",
"name": "MyGateway",
"settings": {
"baseURL": "http://localhost:8080/v1",
"apiKey": ""
},
"models": { "my-model": {} }
}
} - Run
opencode models— only opencode/* models are listed; mygateway is absent. - Run
opencode run -m mygateway/my-model "hi"— fails withModelUnavailableError: Model unavailable: mygateway/my-model. - (Optional, confirms registry-level absence) In a server plugin, call
await context.provider.list()— returns only the built-in opencode provider; insidecontext.provider.transform(editor => ...),editor.get("mygateway")returns undefined on every invocation.
Screenshot and/or share link
N/A — no screenshot. Key log evidence: zero error/warning lines about the providers section (it parses and normalizes cleanly per opencode debug config, but is silently never registered). No session share link — reproduction is config-only and does not require a session.
Operating System
Windows 10 (build 19045) — win32 x64
Terminal
PowerShell 7 (pwsh), TERM=xterm-256color
Activity
github-actions commentedon Sep 25, 2026
This issue might be a duplicate of existing issues. Please check:
Model unavailable.providersconfiguration block during provider discovery.wangjianjq commentedon Oct 1, 2026
Still reproduces on v2.0.21 stable (Windows 11 10.0.26300, x64) — so this is not fixed as of the latest
latest-channel CLI, and it is not limited to 2.0.15.Version matrix (all fail identically)
opencodeCLI 2.0.15ModelUnavailableErroropencodeCLI 2.0.20ModelUnavailableErroropencodeCLI 2.0.21ModelUnavailableErroropencode-cli.exe serve --service)opencode-ai@1.18.34(npm)UnknownError: Unexpected server errorWhat was tested (clean directory, no project config, no plugins)
Both config syntaxes fail to register, silently, with no
skipped malformednormalization warnings (so this appears distinct from #49912's capabilities/toolsskip — our config normalizes cleanly and only emitsomitted unsupported legacy settingWARNs forreasoning):v1 syntax (real gateway replaced with a placeholder endpoint):
{ "$schema": "https://opencode.ai/config.json", "provider": { "mygateway": { "npm": "@ai-sdk/openai-compatible", "name": "MyGateway", "options": { "baseURL": "https://api.example-gateway.ai/v1", "apiKey": "{env:MY_API_KEY}" }, "models": { "my-model": { "name": "My Model", "limit": { "context": 1000000, "output": 128000 } } } } } }v2 syntax (same failure):
{ "$schema": "https://opencode.ai/config.json", "providers": { "mygateway": { "name": "MyGateway", "env": ["MY_API_KEY"], "package": "@opencode/ai/providers/openai-compatible", "settings": { "baseURL": "https://api.example-gateway.ai/v1" }, "models": { "my-model": { "name": "My Model" } } } } }Observations
opencode modelslists only built-inopencode/*models (the Zen catalog); custom providers absent.opencode run -m mygateway/my-model "hi"→Error: Model unavailable: mygateway/my-model.-m, the configured default custom model is silently ignored and the session falls back to a built-inopencode/*model — easy to miss and confusing.configuration normalization diagnosticentries iterating our models), yet nothing registers. Matches the reporter's finding: parses cleanly, never materializes.MY_API_KEYis present in the server process env, and replacing{env:MY_API_KEY}with a literal key changes nothing.--standalone(private server) and against the background service; config was validated with a JSONC parser between attempts (no BOM, no syntax errors).The v1-style block above is the same shape that worked before we upgraded to the 2.0.x line, and per this issue + #42856 + #51031 it now silently no-ops across the whole stable range. The plugin
context.provider.transform+editor.add()workaround mentioned here works, but config-declared providers (and the v1→v2 migration path) remain unusable.Happy to test a fix build.
neriousy commentedon Oct 20, 2026
Thanks for the report. We're tracking this same problem with config-declared providers missing from the model catalog in #42856, so I'm closing this as a duplicate. Please follow that issue for updates.