GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(opencode): add dynamic model fetching for OpenAI-compatible provider by shivamashtikar · Pull Request #14277 · anomalyco/opencode

Conversation

@shivamashtikar

@shivamashtikar shivamashtikar commented Feb 19, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Issue for this PR

Closes #12814
Closes #10633

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds a shouldFetchModels config option that dynamically fetches available models from the provider's OpenAI-compatible API at startup. This eliminates the need to manually list every model in opencode.json for custom providers.

Comparison with PR #13896:
PR #13896 implements LiteLLM-specific model loading. This PR provides a generic implementation supporting any OpenAI-compatible provider (LiteLLM, Ollama, vLLM, custom proxies, etc.). Both try /model/info first, but this PR adds proper fallback to the standard /models endpoint.

How it works:

  • When a custom provider has baseURL configured, models are fetched in the background (unless shouldFetchModels: false)
  • First tries /model/info for rich metadata (limits, costs, capabilities)
  • Falls back to /models endpoint if /model/info unavailable
  • Manual config models always override fetched ones
  • Non-blocking - startup proceeds immediately, models merged when response arrives

Example:

{
  "provider": {
    "my-proxy": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://my-proxy.com/v1",
        "apiKey": "{env:API_KEY}"
      }
    }
  }
}

To disable:

{
  "provider": {
    "my-proxy": {
      "shouldFetchModels": false,
      "options": { "baseURL": "https://my-proxy.com/v1" }
    }
  }
}

How did you verify your code works?

  • bun test test/provider/fetch-models.test.ts - 4 tests pass
  • bun test test/session/llm.test.ts - 10 tests pass (no regressions)
  • Built standalone executable with --single flag and verified it works

Screenshots / recordings

N/A - no UI changes

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

NourEldin-Osama, scratchmex, and cycle2zhou reacted with eyes emoji
All reactions
  • 👀 3 reactions
@github-actions

github-actions Bot commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Found a potential duplicate:

PR #13896 - feat(opencode): add auto loading models for litellm providers

  • feat(opencode): add auto loading models for litellm providers #13896

Why it's related: This PR appears to implement very similar functionality - automatic model loading for LiteLLM providers. Given that PR #14277 also adds dynamic model fetching for OpenAI-compatible providers (including LiteLLM), these PRs may be addressing the same or overlapping feature requests. You should verify whether PR #13896 was already merged or closed and check if #14277 extends/improves upon it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@shivamashtikar

shivamashtikar commented Feb 19, 2026

Copy link
Copy Markdown
Author

this PR provides compatibility with any open-ai compatible endpoints along with litellm as opposed to #13896 which only handles for litellm

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PratikNarola1

PratikNarola1 commented Feb 19, 2026

Copy link
Copy Markdown

LGTM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@8x22b

8x22b commented Feb 19, 2026

Copy link
Copy Markdown

PLEASE MERGE IT

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Mushoz Mushoz mentioned this pull request Feb 19, 2026
feat(opencode): add auto loading models for litellm providers #13896
Closed
2 tasks done
@espetro

espetro commented Feb 20, 2026

Copy link
Copy Markdown

up! we're looking forward to it!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@balcsida balcsida mentioned this pull request Feb 20, 2026
feat(opencode): add LiteLLM provider with auto model discovery #14468
Closed
3 of 6 tasks
@shivamashtikar
shivamashtikar force-pushed the feat/dynamic-model-fetch branch 2 times, most recently from 6210e12 to 91ef011 Compare February 24, 2026 09:47
@shivamashtikar

shivamashtikar commented Feb 25, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Author

Hi @alexyaroshuk @adamdotdevin could you please check this PR and let me know if it can be merged or if you need any more changes in it

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alexyaroshuk

alexyaroshuk commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Hi @alexyaroshuk @adamdotdevin could you please check this PR and let me know if it can be merged or if you need any more changes in it

unit tests failing:

4 tests failed:
(fail) session.llm.stream > sends temperature, tokens, and reasoning options for openai-compatible models [31.00ms]
(fail) session.llm.stream > sends responses API payload for OpenAI models [63.00ms]
(fail) session.llm.stream > sends messages API payload for Anthropic models [94.00ms]
(fail) session.llm.stream > sends Google API payload for Gemini models [109.00ms]

I checked with upstream and confirmed that upstream does not have these failing. Your PR has these failing. You can verify by running bun test from packages/opencode

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

shivamashtikar added 3 commits March 3, 2026 04:13
@shivamashtikar
feat(opencode): add dynamic model fetching for OpenAI-compatible prov…
927c675
…iders

Add fetchModels config option that fetches available models from a
provider's API at startup. Tries LiteLLM /model/info first for rich
metadata (limits, costs, capabilities), falls back to standard /models
endpoint. Manually configured models override fetched ones.
@shivamashtikar
refactor(opencode): make fetchModels non-blocking to avoid impacting …
fe8e5ab
…startup

Move dynamic model fetching to a fire-and-forget background task within
state(). Models are merged into the providers object asynchronously
after state initialization completes, so startup is not delayed by
network requests.
@shivamashtikar
refactor(opencode): rename fetchModels to shouldFetchModels, default …
765aa51
…to true

Rename config field to shouldFetchModels for clarity. Default to true
so custom providers with a baseURL automatically discover models
without explicit opt-in. Update PR docs accordingly.
@shivamashtikar
shivamashtikar force-pushed the feat/dynamic-model-fetch branch from 584e91e to 66329b2 Compare March 2, 2026 22:50
@shivamashtikar
feat(opencode): add dynamic model fetching for OpenAI-compatible prov…
b1b97d6
…iders

- Add shouldFetchModels option to provider config (defaults to true)
- Update tests to disable model fetching in test fixtures
@shivamashtikar
shivamashtikar force-pushed the feat/dynamic-model-fetch branch from 66329b2 to b1b97d6 Compare March 2, 2026 22:54
@shivamashtikar
test(opencode): add tests for shouldFetchModels feature
e3d8e0a
- Test shouldFetchModels: false prevents API calls
- Test manual models work when fetching is disabled
- Test blacklist/whitelist filtering with manual models
@shivamashtikar

shivamashtikar commented Mar 2, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Author

Hi @alexyaroshuk , apologies i missed those. I've fixed the test cases and and also added new test cases related to my change, can you please review and merge if everything seems fine

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Mar 2, 2026
@github-actions

github-actions Bot commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Mar 3, 2026
📊 AI CLI 工具社区动态日报 2026-03-03 duanyytop/agents-radar#45
Closed
@alexyaroshuk

alexyaroshuk commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

Hi @alexyaroshuk , apologies i missed those. I've fixed the test cases and and also added new test cases related to my change, can you please review and merge if everything seems fine

i cannot merge, i simply try to help with review. Looks like the test issue is fixed, but merging is up to Adam

shivamashtikar reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@shivamashtikar

shivamashtikar commented Mar 3, 2026

Copy link
Copy Markdown
Author

Sure @alexyaroshuk please help with the review

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Mar 3, 2026
docs(providers): document Responses API support for custom providers #15847
Closed
feat: Ollama implementation #16681
Closed
@github-actions github-actions Bot mentioned this pull request Mar 18, 2026
feat: auto discover models from custom providers #18110
Closed
3 of 6 tasks
@opencode-agent
opencode-agent Bot force-pushed the dev branch from 2f2ed11 to 9f201d6 Compare April 16, 2026 21:55
@github-actions

github-actions Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot closed this May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Dynamic model switching Can I let the opencode to select and switch different local models automatically?

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@shivamashtikar @PratikNarola1 @8x22b @espetro @alexyaroshuk
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.