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 — Fetch from model list from `/v1/models/` from OpenAI Compatible APIs by n1gh7e0us · Pull Request #3427 · anomalyco/opencode

Conversation

@n1gh7e0us

@n1gh7e0us n1gh7e0us commented Oct 24, 2025

Copy link
Copy Markdown

This commit introduces automatic model discovery for OpenAI-compatible providers, allowing OpenCode to dynamically fetch available models from the /v1/models endpoint instead of requiring manual model configuration.

Key changes:

  • Implement automatic fetching of models from /v1/models endpoint for custom OpenAI-compatible providers
  • Add proper API key handling from both auth.json and environment variables
  • Enable support for providers using the @ai-sdk/openai-compatible npm package
  • Include enhanced logging for debugging provider configuration
  • Ensure compatibility with existing provider configuration system

This enhancement enables OpenCode to work seamlessly with OpenAI-compatible APIs such as local LLM servers (Ollama, LocalAI), API proxies, and custom implementations without requiring manual model definitions in the configuration. The functionality addresses the need for supporting custom and local AI providers with dynamic model discovery.

Fixes the issue where OpenAI-compatible providers would show no available models unless manually configured in opencode.json.

(the PR is generated by qwen, though I have tested it out locally properly with the provider, used nano-gpt.com/api/v1 for this)

Sorry, something went wrong.

Uh oh!

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

Peng-YM, berenar, slumbi, Qard, RichardoC, and jonaspm reacted with thumbs up emoji
All reactions
  • 👍 6 reactions
Your Name added 2 commits October 24, 2025 16:42
Your Name
Add dynamic model fetching for OpenAI-compatible providers
5324486
- Implement automatic fetching of models from /v1/models endpoint for custom OpenAI-compatible providers
- Add proper API key handling from auth.json or environment variables
- Include enhanced logging for debugging provider configuration
- Enable support for providers configured with @ai-sdk/openai-compatible npm package
Your Name
ai: fixed the typecheck errors
2128872
@n1gh7e0us n1gh7e0us changed the title Fetch from models OpenAI api Fetch from model list from /v1/models/ from OpenAI Compatible APIs Oct 24, 2025
rekram1-node
rekram1-node reviewed Oct 24, 2025
View reviewed changes
Comment thread packages/opencode/src/provider/provider.ts
Comment on lines +383 to +387
// For custom config providers, we may need to get the npm field from config
const npmPackage = providerInfo?.npm || config.provider?.[providerID]?.npm;
if (npmPackage !== "@ai-sdk/openai-compatible") {
continue;
}

@rekram1-node rekram1-node Oct 24, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't gonna work for like any providers

Sorry, something went wrong.

Uh oh!

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

All reactions
rekram1-node
rekram1-node reviewed Oct 24, 2025
View reviewed changes
Comment thread packages/opencode/src/provider/provider.ts Resolved

Uh oh!

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

rekram1-node
rekram1-node reviewed Oct 24, 2025
View reviewed changes
Comment thread packages/opencode/src/provider/provider.ts
Comment on lines +447 to +451
},
limit: {
context: 4096, // Default context limit
output: 4096, // Default output limit
},

@rekram1-node rekram1-node Oct 24, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause a veryyy poor experience for a lot of people 4096 context window isn't gonna be useful for most agentic work

Sorry, something went wrong.

Uh oh!

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

All reactions

@n1gh7e0us n1gh7e0us Oct 24, 2025

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just opened the repo to search if I could get away with 4096 context window length (or by disabling /compact)

And yes, I agree it was pretty ugly. just happened to me. should have also tested out the models itself as well.

Sorry, something went wrong.

Uh oh!

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

All reactions
rekram1-node
rekram1-node reviewed Oct 24, 2025
View reviewed changes
Comment thread packages/opencode/src/provider/provider.ts
// Create a default model entry with basic information
fetchedModels[modelData.id] = {
id: modelData.id,
name: modelData.id || modelData.name || modelData.object || "Unknown Model", // Use id, name, or object from API

@rekram1-node rekram1-node Oct 24, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't model name required, i think it will always be defined

Sorry, something went wrong.

Uh oh!

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

All reactions

@n1gh7e0us n1gh7e0us Oct 24, 2025

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmmm, It is required but ig a good idea to let it stay here as well? unless I am missing out on something that you can see.

Sorry, something went wrong.

Uh oh!

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

All reactions

@rekram1-node rekram1-node Oct 24, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean name field returned from the api will always be defined modelData.name so no need for all the ORs

Sorry, something went wrong.

Uh oh!

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

All reactions
@rekram1-node

rekram1-node commented Oct 24, 2025

Copy link
Copy Markdown
Member

There is something to this for providing a good ux, I'm wondering can we restrict it to:

  • custom providers only
  • only custom providers that have the "@ai-sdk/openai-compatible" set for the provider

And then don't override any of their existing custom models for that provider

What is teh default context size for LM studio?

All reactions

Sorry, something went wrong.

Uh oh!

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

@rekram1-node

rekram1-node commented Oct 24, 2025

Copy link
Copy Markdown
Member

Also we have these style preferences I should make a style guide:

Try to keep things in one function unless composable or reusable
DO NOT do unnecessary destructuring of variables
DO NOT use else statements unless necessary
DO NOT use try/catch if it can be avoided
AVOID try/catch where possible
AVOID else statements
AVOID using any type
AVOID let statements
PREFER single word variable names where possible
All reactions

Sorry, something went wrong.

Uh oh!

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

@n1gh7e0us

n1gh7e0us commented Oct 24, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Author

default context size for LM studio
it is 4096 (reduced from 8k) but it is mostly to avoid OOM errors since LM studio is used with local LLMs most of the time. (or was built with that aspect)

custom providers only
only custom providers that have the "@ai-sdk/openai-compatible" set for the provider

This would be a good idea and what also I had in my mind. I just added the model to opencode.json and there is no particular context length window on it. (stays at 0%)
image

Which I think would be fine with people who are going towards using custom providers like nano-gpt? atleast they don't have to worry about it for a while. If they are crossing the limits then they can add the model and the num_ctx value manually?

Better than the 4096 limit atleast in my opinion... (just suffered from it lol)

Also will keep the style guide in mind, it was a pretty quick PR for something I wanted to try out with the provider cause it has way too many models to select from.

The UX factor definitely felt good after using the /v1/models path.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions
github-actions Bot force-pushed the dev branch from 772b621 to eb855e1 Compare November 10, 2025 05:42
@github-actions
github-actions Bot force-pushed the dev branch 3 times, most recently from f1dc981 to 3e15a39 Compare November 22, 2025 18:07
@thdxr
thdxr force-pushed the dev branch from 3e15a39 to a0831ea Compare November 22, 2025 18:11
@github-actions
github-actions Bot force-pushed the dev branch 3 times, most recently from f8ee907 to 6a9856d Compare November 27, 2025 01:29
@rekram1-node
rekram1-node force-pushed the dev branch from 398b39a to 5013d64 Compare December 5, 2025 05:13
This was referenced Jan 10, 2026
core: auto-discover models from OpenAI-compatible local providers #7644
Closed
feat(opencode): add auto model detection for OpenAI-compatible providers #8359
Merged
@github-actions github-actions Bot mentioned this pull request Jan 24, 2026
feat: add Maple AI provider integration #10436
Closed
@thdxr
thdxr force-pushed the dev branch from cbab81f to 2d3c7a0 Compare January 30, 2026 04:50
@opencode-agent
opencode-agent Bot force-pushed the dev branch from 00637c0 to 71e0ba2 Compare January 30, 2026 14:32
@thdxr
thdxr force-pushed the dev branch 3 times, most recently from f1ae801 to 08fa7f7 Compare January 30, 2026 14:37
@github-actions

github-actions Bot commented Feb 2, 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 Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@rekram1-node rekram1-node rekram1-node left review comments

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.

Uh oh!

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

2 participants

@n1gh7e0us @rekram1-node
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.