opencode-plugin-litellm 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -46,10 +46,26 @@ npm install opencode-plugin-litellm
46
46
  // 2. Add to opencode.json
47
47
  {
48
48
  "$schema": "https://opencode.ai/config.json",
49
- "plugin": ["opencode-plugin-litellm@latest"]
49
+ "plugin": ["opencode-plugin-litellm@latest"],
50
+ "provider": {
51
+ "litellm": {
52
+ "npm": "@ai-sdk/openai-compatible",
53
+ "options": {
54
+ "baseURL": "http://localhost:4000/v1"
55
+ },
56
+ "models": {
57
+ "_": { "name": "seed" }
58
+ }
59
+ }
60
+ }
50
61
  }
51
62
  ```
52
63
 
64
+ > **Why the `"_"` seed model?** OpenCode only activates the plugin's
65
+ > model-discovery hook when the provider already has at least one model
66
+ > entry. The seed is replaced at startup by the full list from your
67
+ > LiteLLM proxy.
68
+
53
69
  ```bash
54
70
  # 3. Start LiteLLM (if it isn't already)
55
71
  litellm --config config.yaml --port 4000
@@ -58,8 +74,6 @@ litellm --config config.yaml --port 4000
58
74
  opencode
59
75
  ```
60
76
 
61
- That's it. No provider block required.
62
-
63
77
  ## 🎯 Features
64
78
 
65
79
  | | |
@@ -79,14 +93,25 @@ That's it. No provider block required.
79
93
 
80
94
  ## ⚙️ Configuration
81
95
 
82
- ### Zero-config (recommended)
96
+ ### Minimal config (recommended)
83
97
 
84
- If LiteLLM is on `localhost:4000`, `:8000`, or `:8080`, the plugin self-configures:
98
+ Point at your LiteLLM proxy and include a seed model so OpenCode registers the provider:
85
99
 
86
- ```json
100
+ ```jsonc
87
101
  {
88
102
  "$schema": "https://opencode.ai/config.json",
89
- "plugin": ["opencode-plugin-litellm@latest"]
103
+ "plugin": ["opencode-plugin-litellm@latest"],
104
+ "provider": {
105
+ "litellm": {
106
+ "npm": "@ai-sdk/openai-compatible",
107
+ "options": {
108
+ "baseURL": "http://localhost:4000/v1"
109
+ },
110
+ "models": {
111
+ "_": { "name": "seed" }
112
+ }
113
+ }
114
+ }
90
115
  }
91
116
  ```
92
117
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "opencode-plugin-litellm",
4
- "version": "0.4.0",
4
+ "version": "0.4.2",
5
5
  "description": "OpenCode plugin for LiteLLM proxy support with auto-detection and dynamic model discovery",
6
6
  "type": "module",
7
7
  "main": "./src/index.ts",
@@ -1,32 +1,21 @@
1
- import type { Plugin, PluginInput, Config } from '@opencode-ai/plugin'
1
+ import type { Plugin, PluginInput } from '@opencode-ai/plugin'
2
2
  import { discoverBucket } from './discover'
3
3
 
4
4
  const CHAT_PROVIDER_ID = 'litellm'
5
5
  const RESPONSES_PROVIDER_ID = 'litellm-responses'
6
6
 
7
- /**
8
- * Ensure a provider entry has a `models` map so OpenCode registers it.
9
- *
10
- * OpenCode skips providers that have no models defined in the config,
11
- * which means the `provider.models` hook would never be called. By
12
- * seeding an empty `models` map we guarantee the provider is created
13
- * and the hook has a chance to populate it with discovered models.
14
- */
15
- function ensureProviderHasModels(config: Config, providerID: string): void {
16
- if (!config.provider) return
17
- const entry = config.provider[providerID]
18
- if (!entry) return
19
- if (!entry.models) {
20
- entry.models = {}
21
- }
22
- }
23
-
24
7
  /**
25
8
  * LiteLLM Plugin for OpenCode.
26
9
  *
27
10
  * Implements the `provider.models` hook so OpenCode populates the
28
11
  * `litellm` provider's model list from a live LiteLLM proxy at
29
- * startup. No models need to be hand-defined in `opencode.json`.
12
+ * startup.
13
+ *
14
+ * **Important:** OpenCode only calls `provider.models` when the
15
+ * provider has at least one model defined in `opencode.json`. You
16
+ * must include a seed model entry — it can be any model id your
17
+ * proxy exposes. The plugin will discover and add all remaining
18
+ * models automatically.
30
19
  *
31
20
  * By default, every discovered model is registered under the
32
21
  * `litellm` provider — including OpenAI reasoning-tier models like
@@ -48,6 +37,9 @@ function ensureProviderHasModels(config: Config, providerID: string): void {
48
37
  * "options": {
49
38
  * "baseURL": "http://localhost:4000/v1",
50
39
  * "apiKey": "{env:LITELLM_API_KEY}"
40
+ * },
41
+ * "models": {
42
+ * "_": { "name": "seed" }
51
43
  * }
52
44
  * }
53
45
  * }
@@ -55,9 +47,6 @@ function ensureProviderHasModels(config: Config, providerID: string): void {
55
47
  */
56
48
  export const LiteLLMPlugin: Plugin = async (_input: PluginInput) => {
57
49
  return {
58
- config: async (config: Config) => {
59
- ensureProviderHasModels(config, CHAT_PROVIDER_ID)
60
- },
61
50
  provider: {
62
51
  id: CHAT_PROVIDER_ID,
63
52
  models: async (provider) => {
@@ -108,9 +97,6 @@ export const LiteLLMPlugin: Plugin = async (_input: PluginInput) => {
108
97
  */
109
98
  export const LiteLLMResponsesPlugin: Plugin = async (_input: PluginInput) => {
110
99
  return {
111
- config: async (config: Config) => {
112
- ensureProviderHasModels(config, RESPONSES_PROVIDER_ID)
113
- },
114
100
  provider: {
115
101
  id: RESPONSES_PROVIDER_ID,
116
102
  models: async (provider) => {