Repository navigation
Conversation
|
The following comment was made by an LLM, it may be inaccurate: |
There was a problem hiding this comment.
This works as described. I ran a fake OpenAI-compatible gateway with a litellm provider defined in config, then compared opencode models against a server started from each checkout. On the base, no litellm models are listed. With this PR, the chat and responses models appear and the mode: "embedding" entry is skipped. The /models request carried the configured key as a Bearer token and the provider headers. The new tests and the whole packages/core test/plugin suite pass (426 tests), and so does typecheck.
Public API: no new config keys, schema changes, endpoints or events. It adds an internal plugin, opencode.provider.openai-compatible, which users can turn off via plugins. The behaviour change is that every config-defined OpenAI-compatible provider (except ollama, lmstudio and vllm) now gets GET {baseURL}/models with its key and headers at startup, every 5 minutes, and after config or credential changes. This is backwards compatible: existing configs only gain models.
Things worth settling before merge:
- Overlap with other open PRs: #53713 (opt-in gateway discovery via
settings.modelDiscovery), #54398 (context limits from the same/modelsendpoint) and #54558 (a built-inlitellmprovider) all work from the same/modelsdata. This PR turns discovery on by default for every such provider, while #53713 makes it opt-in. Maintainers will likely want one approach, so a provider isn't fetched twice and the opt-in question has one answer. - Entries without
mode: these are treated as chat models. LiteLLM's/v1/modelsoften leavesmodeout (see the example in #48938), so embedding or image models with nomodewill still show up in the model list with default capabilities.
|
Entries without |
Extend the discovery lifecycle from anomalyco#57161 so native proxy endpoints do not inherit unsupported models from the shared catalog. Preserve catalog metadata and explicit configuration, without coupling availability to routing or request-budget changes. Based on anomalyco#57161; availability and effective-connection handling informed by anomalyco#53713 and anomalyco#54398. Co-authored-by: Gr33nbl00d <G_Rehm@ich-habe-fertig.com> Co-authored-by: J.H.S. Schlepers <lucht_piloot@gmx.net> Co-authored-by: Lance Woodson <65194841+woodsonl@users.noreply.github.com>
Extend the discovery lifecycle from anomalyco#57161 so native proxy endpoints do not inherit unsupported models from the shared catalog. Preserve catalog metadata and explicit configuration, without coupling availability to routing or request-budget changes. Based on anomalyco#57161; availability and effective-connection handling informed by anomalyco#53713 and anomalyco#54398. Co-authored-by: Gr33nbl00d <G_Rehm@ich-habe-fertig.com> Co-authored-by: J.H.S. Schlepers <lucht_piloot@gmx.net> Co-authored-by: Lance Woodson <65194841+woodsonl@users.noreply.github.com>
Extend the discovery lifecycle from anomalyco#57161 so native proxy endpoints do not inherit unsupported models from the shared catalog. Preserve catalog metadata and explicit configuration, without coupling availability to routing or request-budget changes. Based on anomalyco#57161; availability and effective-connection handling informed by anomalyco#53713 and anomalyco#54398. Co-authored-by: Gr33nbl00d <G_Rehm@ich-habe-fertig.com> Co-authored-by: J.H.S. Schlepers <lucht_piloot@gmx.net> Co-authored-by: Lance Woodson <65194841+woodsonl@users.noreply.github.com>
|
Thanks for this PR — exactly what custom OpenAI-compatible setups need. One gap worth considering while this is in review: discovered models get the default capabilities fallback ( Some OpenAI-compatible endpoints already expose richer metadata in Repro from a hosted OpenAI-compatible endpoint that exposes modalities in |
Extend the discovery lifecycle from anomalyco#57161 so native proxy endpoints do not inherit unsupported models from the shared catalog. Preserve catalog metadata and explicit configuration, without coupling availability to routing or request-budget changes. Based on anomalyco#57161; availability and effective-connection handling informed by anomalyco#53713 and anomalyco#54398. Co-authored-by: Gr33nbl00d <G_Rehm@ich-habe-fertig.com> Co-authored-by: J.H.S. Schlepers <lucht_piloot@gmx.net> Co-authored-by: Lance Woodson <65194841+woodsonl@users.noreply.github.com>
Custom OpenAI-compatible providers such as LiteLLM need every model listed
by hand. Read GET {baseURL}/models and add the missing chat models, keeping
configured models untouched. Ollama, LM Studio, and vLLM keep their own
discovery.
Discovered models accept text and can call tools unless the endpoint
reports modalities or supported parameters, so an image in the history
cannot break every later request to a text-only model.
6003faa to
92e5d7c
Compare
|
@KarataevDmitry Good catch, thanks! Discovered models are now text-only unless the endpoint says otherwise, so an image in the history is turned into a "this model does not support image input" note instead of breaking the session. If |
There was a problem hiding this comment.
The new commits work as described. I served a fake /models endpoint and listed models from a server built from this PR, via the CLI and the SDK client. An entry with no metadata comes back as text-only with tools. An entry with architecture.input_modalities including image gets image input. An entry whose supported_parameters lacks tools has tools off. The embedding entry is skipped. The new tests and the whole packages/core test/plugin suite pass. typecheck:tsc passes; the typecheck script calls bun check, which the installed Bun doesn't have, so I couldn't run it.
My earlier point about LiteLLM entries with no mode is addressed: the docs now say they count as chat models and can be hidden with "disabled": true under models, and a test covers that. The public API impact is unchanged since the last review. The overlap with #53713, #54398 and #54558 is still a decision for maintainers. Nothing new to raise.
Issue for this PR
Closes #48938
Type of change
What does this PR do?
Custom OpenAI-compatible providers (LiteLLM and other gateways) need every model listed in config by hand. This adds a plugin that reads
GET {baseURL}/modelsfor providers configured with an OpenAI-compatible package and adds the missing chat models. Configured models stay untouched, and non-chat entries (mode: "embedding"etc.) are skipped.It authenticates the same way requests do: saved key,
envvariable, orsettings.apiKey, plus the provider headers. It also matches configs migrated from V1 (aisdk:@ai-sdk/openai-compatible). Ollama, LM Studio and vLLM are skipped because they have their own discovery. The list refreshes every 5 minutes and after config or credential changes, and survives outages. Discovered models accept text and can call tools unless/modelsreportsinput_modalities/output_modalitiesorsupported_parameters(top level or underarchitecture), so an image in the history can't break every later request to a text-only model.How did you verify your code works?
Tests against a local server for: config provider plus discovery in production order, stored/env/config keys, a V1 config through
ConfigNormalize, outage retention, and endpoint changes. Core typecheck, oxlint, and the config test suite pass.Visual
Animated SVG for the What's new dialog
Screenshots / recordings
No UI changes.
Checklist
Added by the opencode bot (AI-generated).
Related: #40524, #55354, #53235
Public API: adds the internal plugin
opencode.provider.openai-compatible, which callsGET {baseURL}/modelsfor config-defined OpenAI-compatible providers by default (no config or schema changes; backwards compatible)