feat: add plugin-litellm + provider-litellm presets (runtime model discovery) - #45
Merged
Conversation
Wire opencode to a LiteLLM proxy with runtime model discovery via the
opencode-plugin-litellm plugin, instead of a hand-maintained models list.
- plugin-litellm: appends opencode-plugin-litellm@0.5.0 to the plugin
array. At startup the plugin queries the proxy's /v1/models and injects
every model into the picker. For localhost with the key in
$LITELLM_API_KEY the plugin auto-detects the URL and creates the
provider itself, so this preset alone suffices.
- provider-litellm: for a custom/remote proxy, sets provider.litellm
(@ai-sdk/openai-compatible) with the prompted baseURL and
apiKey={env:LITELLM_API_KEY}. Declares NO models; the plugin fills them.
Plugin pinned to an exact version (repo supply-chain stance) rather than
the README's @latest. Adds README rows and parseConf tests.
trick77
force-pushed
the
feat/provider-litellm-preset
branch
from
July 23, 2026 18:55
b042fb3 to
36f7d8d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Wires opencode to a LiteLLM proxy using runtime model discovery — the model list is pulled from the proxy at startup rather than hand-maintained in
opencode.json. Two presets, matching the two config areas the plugin needs:plugin-litellm(@mode: append→plugin) — addsopencode-plugin-litellm(npmopencode-plugin-litellm, pinned@0.5.0). At startup the plugin queries the proxy's/v1/modelsand injects every model into the picker. For a proxy onlocalhost:4000/8000/8080with the key in$LITELLM_API_KEY, the plugin auto-detects the URL and creates thelitellmprovider itself — so this preset alone is enough.provider-litellm(@mode: replace→provider.litellm) — for a custom/remote proxy URL. Prompts forbaseURL, sets@ai-sdk/openai-compatiblewithapiKey: {env:LITELLM_API_KEY}, and declares no models (the plugin fills them).Resulting config for the remote case matches the plugin README's "explicit provider" block verbatim:
{ "plugin": ["opencode-plugin-litellm@0.5.0"], "provider": { "litellm": { "npm": "@ai-sdk/openai-compatible", "name": "LiteLLM (proxy)", "options": { "baseURL": "...", "apiKey": "{env:LITELLM_API_KEY}" } } } }Why this shape (not a static provider block)
LiteLLM is not in models.dev, and opencode only auto-discovers models for a few hardcoded providers (gitlab, etc.) — a plain
@ai-sdk/openai-compatibleprovider shows zero models unless each is listed by hand. Theopencode-plugin-litellmplugin is the mechanism that makes "all models available"; it reads$LITELLM_API_KEY/$LITELLM_MASTER_KEYdirectly for discovery, which is why the key is env-based and the provider key must be exactlylitellm.Usage
Restart opencode after installing a plugin preset.
Changes
presets/plugin-litellm.conf— newpresets/provider-litellm.conf— newREADME.md— two built-in-preset rowstest/builtin-presets.test.ts—parseConftests for bothVerification
npm test→ 99/99 pass (both new tests included)validate configpasses against opencode's live schema;remove plugin-litellm provider-litellmcleanly reverts./v1/modelsdiscovery (needs a live LiteLLM proxy + opencode). Correctness rests on matching the plugin's documented config exactly.Note
Plugin pinned to
@0.5.0rather than the README's@latest, per this repo's supply-chain stance. Bump inplugin-litellm.confto update.