Skip to content

[FEATURE]: Add option to disable models.dev fetch for corporate proxy environments #4959

@emvnuel

Description

@emvnuel

Feature hasn't been suggested before.

  • 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:

export async function get() {
  refresh()  // Always calls fetch to models.dev
  const file = Bun.file(filepath)
  const result = await file.json().catch(() => {})
  if (result) return result as Record<string, Provider>
  const json = await data()
  return JSON.parse(json) as Record<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.:

{
  "offline": true
}

Or more granularly:

{
  "experimental": {
    "disable_models_fetch": true
  }
}

When enabled, OpenCode would skip the models.dev fetch and rely on:

  1. Cached data at ~/.cache/opencode/models.json
  2. Bundled model data (compiled via macro)

Workaround

Currently, users can whitelist models.dev in their corporate proxy, but this isn't always possible in restricted environments.

Environment

  • OpenCode version: 1.x.x (works in 0.15.31)
  • Issue: Corporate proxy blocking/timing out on models.dev fetch

Metadata

Metadata

Assignees

Labels

discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions