You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE]: Add option to disable models.dev fetch for corporate proxy environments #4959
I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Problem
Users behind corporate proxies experience issues with OpenCode 1.x.x versions due to a network call made on startup to https://models.dev/api.json. This call happens unconditionally and does not respect HTTP_PROXY/HTTPS_PROXY environment variables since Bun's native fetch() doesn't automatically handle proxy configuration.
Version 0.15.31 worked fine because this fetch behavior was either not present or handled differently.
Current Behavior
In packages/opencode/src/provider/models.ts, the get() function always calls refresh() which makes a network request:
exportasyncfunctionget(){refresh()// Always calls fetch to models.devconstfile=Bun.file(filepath)constresult=awaitfile.json().catch(()=>{})if(result)returnresultasRecord<string,Provider>constjson=awaitdata()returnJSON.parse(json)asRecord<string,Provider>}
The code does have fallback mechanisms (local cache + bundled data), but the fetch is attempted regardless.
Proposed Solution
Add a configuration option to disable network calls, e.g.:
I think experimental.skip_models_fetch would be a better name. After all, we're not trying to disable the ability to fetch updated model lists (opencode models --refresh should keep working), we're just trying to skip the automatic fetching of the updated list.
We might be able to achieve this simply by not enabling the 60 minute model refresh timer when experimental.skip_models_fetch == true? Need to look into how viable that is, but it sounds like it could work.
I looked into this and found out why OPENCODE_DISABLE_MODELS_FETCH doesn't work - I think it's basically broken by design?
The problem
In models.ts, the get() function does this:
exportasyncfunctionget(){refresh()// flag stops this from fetchingconstresult=awaitfile.json().catch(()=>{})if(result)returnresult// but it still reads the cache...if(typeofdata==="function"){returnJSON.parse(awaitdata())// ...or falls back to baked-in data}// last resort: fetch}
So even if you:
Set the flag
Delete the cache file
...it still loads models from a Bun macro that embeds models.dev at build time. The data is literally compiled into the binary. There's no escaping it.
Proposed fixes
Option A: Make the env var actually work (easy fix)
Just return empty when the flag is set:
You might consider trying the OpenCode Sentinel project—it cuts all network access except to your LLM, so it works flawlessly in network-restricted environments👍👍.
I stumbled upon this issue with my own use case: I'm trying to sandbox opencode restricting it to only localhost Ollama for projects with personal data, but it fails because of the mandatory models.dev download. It would be nice to make it optional, or to skip it if the user provides a specific model to use.
Activity
github-actions commentedon Dec 1, 2025
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
thdxr commentedon Dec 2, 2025
yep this is a good idea i was toying around with it
ariane-emory commentedon Dec 2, 2025
I think
experimental.skip_models_fetchwould be a better name. After all, we're not trying to disable the ability to fetch updated model lists (opencode models --refreshshould keep working), we're just trying to skip the automatic fetching of the updated list.ariane-emory commentedon Dec 4, 2025
We might be able to achieve this simply by not enabling the 60 minute model refresh timer when
experimental.skip_models_fetch == true? Need to look into how viable that is, but it sounds like it could work.BAMSHK commentedon Jan 16, 2026
b3nw commentedon Jan 17, 2026
I looked into this and found out why
OPENCODE_DISABLE_MODELS_FETCHdoesn't work - I think it's basically broken by design?The problem
In
models.ts, theget()function does this:So even if you:
...it still loads models from a Bun macro that embeds models.dev at build time. The data is literally compiled into the binary. There's no escaping it.
Proposed fixes
Option A: Make the env var actually work (easy fix)
Just return empty when the flag is set:
Should I submit a PR to fix this? or is this intentional and a different solution should be added?
junmediatek commentedon Jan 18, 2026
@thdxr @rekram1-node
Could you help to check this issue?
shuv1337#307
OneOfLzx commentedon Jan 22, 2026
You might consider trying the OpenCode Sentinel project—it cuts all network access except to your LLM, so it works flawlessly in network-restricted environments👍👍.
Repo: https://github.com/oneoflzx/opencode-sentinel
haplo commentedon Feb 3, 2026
I stumbled upon this issue with my own use case: I'm trying to sandbox opencode restricting it to only localhost Ollama for projects with personal data, but it fails because of the mandatory models.dev download. It would be nice to make it optional, or to skip it if the user provides a specific model to use.
jaepang commentedon Feb 24, 2026
Checking for solution details
emvnuel commentedon Mar 25, 2026
OPENCODE_DISABLE_MODELS_FETCH flag solves this issue
fish: disable models.dev fetch in opencode-ollama