pi-free 1.0.5 → 1.0.7

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +85 -85
  2. package/LICENSE +21 -21
  3. package/README.md +289 -289
  4. package/config.ts +224 -224
  5. package/constants.ts +110 -110
  6. package/lib/logger.ts +94 -94
  7. package/lib/model-enhancer.ts +20 -20
  8. package/lib/types.ts +108 -108
  9. package/lib/util.ts +256 -256
  10. package/package.json +74 -72
  11. package/provider-factory.ts +221 -221
  12. package/provider-failover/errors.ts +275 -0
  13. package/provider-failover/hardcoded-benchmarks.ts +9911 -0
  14. package/provider-failover/index.ts +194 -0
  15. package/provider-helper.ts +336 -336
  16. package/providers/cline-auth.ts +473 -473
  17. package/providers/cline-models.ts +77 -77
  18. package/providers/cline.ts +257 -257
  19. package/providers/factory.ts +125 -125
  20. package/providers/fireworks.ts +49 -49
  21. package/providers/kilo-auth.ts +172 -172
  22. package/providers/kilo-models.ts +26 -26
  23. package/providers/kilo.ts +144 -144
  24. package/providers/mistral.ts +144 -144
  25. package/providers/model-fetcher.ts +138 -138
  26. package/providers/nvidia.ts +113 -113
  27. package/providers/ollama.ts +113 -113
  28. package/providers/openrouter.ts +175 -175
  29. package/providers/zen.ts +416 -416
  30. package/usage/commands.ts +17 -17
  31. package/usage/formatters.ts +115 -115
  32. package/usage/index.ts +46 -46
  33. package/usage/limits.ts +148 -148
  34. package/usage/metrics.ts +222 -222
  35. package/usage/store.ts +99 -99
  36. package/usage/tracking.ts +329 -329
  37. package/usage/types.ts +26 -26
  38. package/usage/widget.ts +90 -90
  39. package/widget/data.ts +113 -0
  40. package/widget/format.ts +26 -0
  41. package/widget/render.ts +117 -0
package/README.md CHANGED
@@ -1,289 +1,289 @@
1
- # pi-free-providers
2
-
3
- Free AI model providers for [Pi](https://pi.dev). Access **free models** from multiple providers in one install.
4
-
5
- ---
6
-
7
- ## What does pi-free do
8
-
9
- **pi-free is a Pi extension that unlocks free AI models from 8 different providers.**
10
-
11
- When you install pi-free, it:
12
-
13
- 1. **Registers 7 AI providers** with Pi's model picker — OpenCode Zen, Kilo, OpenRouter, NVIDIA NIM, Cline, Mistral, and Ollama Cloud
14
-
15
- 2. **Filters to show only free models by default** — You see only the models that cost $0 to use, no API key required for some providers
16
-
17
- 3. **Provides a toggle command** — Run `/{provider}-toggle` (e.g., `/zen-toggle`, `/kilo-toggle`) to switch between free-only mode and showing all models including paid ones
18
-
19
- 4. **Handles authentication for you** — OAuth flows (Kilo, Cline) open your browser automatically; API keys are read from `~/.pi/free.json` or environment variables
20
-
21
- 5. **Adds Coding Index scores** — Model names include a coding benchmark score (CI: 45.2) to help you pick capable coding models at a glance
22
-
23
- 6. **Persists your preferences** — Your toggle choices (free vs all models) are saved to `~/.pi/free.json` and remembered across Pi restarts
24
-
25
- ---
26
-
27
- ## How to use
28
-
29
- ### 1. Install the extension
30
-
31
- ```bash
32
- pi install git:github.com/apmantza/pi-free
33
- ```
34
-
35
- ### 2. Open the model picker
36
-
37
- Start Pi and press `Ctrl+L` to open the model picker.
38
-
39
- Free models are shown by default — look for the provider prefixes:
40
- - `zen/` — OpenCode Zen models (no setup required)
41
- - `kilo/` — Kilo models (free models available immediately, more after `/login kilo`)
42
- - `openrouter/` — OpenRouter models (free account required)
43
- - `nvidia/` — NVIDIA NIM models (free API key required)
44
- - `cline/` — Cline models (run `/login cline` to use)
45
- - `mistral/` — Mistral models (API key required)
46
- - `ollama/` — Ollama Cloud models (API key required)
47
-
48
- ### 3. Toggle between free and paid models
49
-
50
- Want to see paid models too? Run the toggle command for your provider:
51
-
52
- ```
53
- /zen-toggle # Toggle Zen free/paid models
54
- /kilo-toggle # Toggle Kilo free/paid models
55
- /openrouter-toggle # Toggle OpenRouter free/paid models
56
- /nvidia-toggle # Toggle NVIDIA zero-cost/credit-costing models
57
- /cline-toggle # Toggle Cline free/paid models
58
- /mistral-toggle # Toggle Mistral free/paid models
59
- /ollama-toggle # Toggle Ollama models (requires SHOW_PAID=true)
60
- ```
61
-
62
- You'll see a notification like: `zen: showing free models` or `zen: showing all models (including paid)`
63
-
64
- ### 4. Add API keys for more providers (optional)
65
-
66
- Some providers require a free account or API key.
67
-
68
- **The first time you run Pi after installing this extension, a config file is automatically created:**
69
- - **Linux/Mac:** `~/.pi/free.json`
70
- - **Windows:** `%USERPROFILE%\.pi\free.json`
71
-
72
- Add your API keys to this file:
73
-
74
- ```json
75
- {
76
- "openrouter_api_key": "sk-or-v1-...",
77
- "nvidia_api_key": "nvapi-...",
78
- "ollama_api_key": "...",
79
- "fireworks_api_key": "...",
80
- "mistral_api_key": "..."
81
- }
82
- ```
83
-
84
- Or set environment variables instead (same names, uppercase: `OPENROUTER_API_KEY`, `NVIDIA_API_KEY`, etc.)
85
-
86
- See the [Providers That Need Authentication](#providers-that-need-authentication) section below for detailed setup instructions per provider.
87
-
88
- ### 5. Quick commands reference
89
-
90
- | Command | What it does |
91
- |---------|-------------|
92
- | `/{provider}-toggle` | Switch between free-only and all models for that provider |
93
- | `/login kilo` | Start OAuth flow for Kilo |
94
- | `/login cline` | Start OAuth flow for Cline |
95
- | `/logout kilo` | Clear Kilo OAuth credentials |
96
- | `/logout cline` | Clear Cline OAuth credentials |
97
-
98
- ---
99
-
100
- ## Using Free Models (No Setup Required)
101
-
102
- ### OpenCode Zen — Easiest Start
103
-
104
- Works immediately with zero setup:
105
-
106
- 1. Press `Ctrl+L`
107
- 2. Search for `zen/`
108
- 3. Pick any model (e.g., `zen/mimo-v2-omni-free`)
109
- 4. Start chatting
110
-
111
- No account, no API key, no OAuth.
112
-
113
- ### Ollama Cloud
114
-
115
- Get an API key from [ollama.com/settings/keys](https://ollama.com/settings/keys), then:
116
-
117
- **Option A: Environment variable**
118
- ```bash
119
- export OLLAMA_API_KEY="..."
120
- export OLLAMA_SHOW_PAID=true
121
- ```
122
-
123
- **Option B: Config file** (`~/.pi/free.json`)
124
- ```json
125
- {
126
- "ollama_api_key": "YOUR_KEY",
127
- "ollama_show_paid": true
128
- }
129
- ```
130
-
131
- **Note:** Ollama requires `OLLAMA_SHOW_PAID=true` because they have usage limits on their cloud API.
132
-
133
- Free tier resets every 5 hours + 7 days.
134
-
135
- ---
136
-
137
- ## Providers That Need Authentication
138
-
139
- Some providers require free accounts or OAuth to access their free tiers:
140
-
141
- ### Kilo (free models, more after login)
142
-
143
- Kilo shows free models immediately. To unlock all models, authenticate with Kilo's free OAuth:
144
-
145
- ```
146
- /login kilo
147
- ```
148
-
149
- This command will:
150
- 1. Open your browser to Kilo's authorization page
151
- 2. Show a device code in Pi's UI
152
- 3. Wait for you to authorize in the browser
153
- 4. Automatically complete login once approved
154
-
155
- - No credit card required
156
- - Free tier: 200 requests/hour
157
- - After login, run `/kilo-toggle` to switch between free-only and all models
158
-
159
- ### OpenRouter (free models available)
160
-
161
- Get a free API key at [openrouter.ai/keys](https://openrouter.ai/keys), then either:
162
-
163
- **Option A: Environment variable**
164
- ```bash
165
- export OPENROUTER_API_KEY="sk-or-v1-..."
166
- ```
167
-
168
- **Option B: Config file** (`~/.pi/free.json`)
169
- ```json
170
- {
171
- "openrouter_api_key": "sk-or-v1-..."
172
- }
173
- ```
174
-
175
- Then in Pi:
176
- ```
177
- /openrouter-all # Show all models (free + paid)
178
- ```
179
-
180
- ### NVIDIA NIM (Free Credits System)
181
-
182
- NVIDIA provides **free monthly credits** (1000 requests/month) at [build.nvidia.com](https://build.nvidia.com).
183
-
184
- **Important:** Models have different "costs" per token:
185
- - **Zero-cost models**: Don't consume your credit balance (shown by default)
186
- - **Credit-costing models**: Consume credits faster (hidden by default)
187
-
188
- Get your API key and optionally enable all models:
189
-
190
- **Option A: Show only free models (default)**
191
- ```bash
192
- export NVIDIA_API_KEY="nvapi-..."
193
- ```
194
- Uses only zero-cost models → your 1000 credits last the full month
195
-
196
- **Option B: Show all models (uses credits faster)**
197
- ```bash
198
- export NVIDIA_API_KEY="nvapi-..."
199
- export NVIDIA_SHOW_PAID=true
200
- ```
201
-
202
- Or in `~/.pi/free.json`:
203
- ```json
204
- {
205
- "nvidia_api_key": "nvapi-...",
206
- "nvidia_show_paid": true
207
- }
208
- ```
209
-
210
- Toggle anytime with `/nvidia-toggle`
211
-
212
- ### Cline
213
-
214
- Cline models appear immediately in the model picker. To use them, authenticate with Cline's free account:
215
-
216
- ```
217
- /login cline
218
- ```
219
-
220
- This command will:
221
- 1. Open your browser to Cline's sign-in page
222
- 2. Wait for you to complete sign-in
223
- 3. Automatically complete login once approved
224
-
225
- - Free account required (no credit card)
226
- - Uses local ports 48801-48811 for OAuth callback
227
-
228
- ### Mistral
229
-
230
- Add API key to `~/.pi/free.json` or environment variables:
231
-
232
- ```bash
233
- export MISTRAL_API_KEY="..."
234
- ```
235
-
236
- ---
237
-
238
- ## Slash Commands
239
-
240
- Each provider has toggle commands to switch between free and all models:
241
-
242
- | Command | Action |
243
- |---------|--------|
244
- | `/zen-toggle` | Toggle between free/all Zen models |
245
- | `/kilo-toggle` | Toggle between free/all Kilo models |
246
- | `/openrouter-toggle` | Toggle between free/all OpenRouter models |
247
- | `/nvidia-toggle` | Toggle between free/all NVIDIA models |
248
- | `/cline-toggle` | Toggle between free/all Cline models |
249
- | `/mistral-toggle` | Toggle between free/all Mistral models |
250
- | `/ollama-toggle` | Toggle between free/all Ollama models |
251
-
252
- **The toggle command:**
253
- - Switches between showing only free models vs. all available models
254
- - **Persists your preference** to `~/.pi/free.json` for next startup
255
- - Shows a notification: "zen: showing free models" or "zen: showing all models (including paid)"
256
-
257
- ---
258
-
259
- ## Configuration
260
-
261
- Create `~/.pi/free.json` in your home directory:
262
-
263
- ```json
264
- {
265
- "openrouter_api_key": "YOUR_OPENROUTER_KEY",
266
- "nvidia_api_key": "YOUR_NVIDIA_KEY",
267
- "fireworks_api_key": "YOUR_FIREWORKS_KEY",
268
- "mistral_api_key": "YOUR_MISTRAL_KEY",
269
- "opencode_api_key": "YOUR_ZEN_KEY",
270
- "ollama_api_key": "YOUR_OLLAMA_KEY",
271
- "ollama_show_paid": true,
272
- "hidden_models": ["model-id-to-hide"]
273
- }
274
- ```
275
-
276
- Or use environment variables (same names, uppercase):
277
-
278
- ```bash
279
- export OPENROUTER_API_KEY="..."
280
- export NVIDIA_API_KEY="..."
281
- ```
282
-
283
- ---
284
-
285
- ## License
286
-
287
- MIT — See [LICENSE](LICENSE)
288
-
289
- **Questions?** [Open an issue](https://github.com/apmantza/pi-free/issues)
1
+ # pi-free-providers
2
+
3
+ Free AI model providers for [Pi](https://pi.dev). Access **free models** from multiple providers in one install.
4
+
5
+ ---
6
+
7
+ ## What does pi-free do
8
+
9
+ **pi-free is a Pi extension that unlocks free AI models from 8 different providers.**
10
+
11
+ When you install pi-free, it:
12
+
13
+ 1. **Registers 7 AI providers** with Pi's model picker — OpenCode Zen, Kilo, OpenRouter, NVIDIA NIM, Cline, Mistral, and Ollama Cloud
14
+
15
+ 2. **Filters to show only free models by default** — You see only the models that cost $0 to use, no API key required for some providers
16
+
17
+ 3. **Provides a toggle command** — Run `/{provider}-toggle` (e.g., `/zen-toggle`, `/kilo-toggle`) to switch between free-only mode and showing all models including paid ones
18
+
19
+ 4. **Handles authentication for you** — OAuth flows (Kilo, Cline) open your browser automatically; API keys are read from `~/.pi/free.json` or environment variables
20
+
21
+ 5. **Adds Coding Index scores** — Model names include a coding benchmark score (CI: 45.2) to help you pick capable coding models at a glance
22
+
23
+ 6. **Persists your preferences** — Your toggle choices (free vs all models) are saved to `~/.pi/free.json` and remembered across Pi restarts
24
+
25
+ ---
26
+
27
+ ## How to use
28
+
29
+ ### 1. Install the extension
30
+
31
+ ```bash
32
+ pi install git:github.com/apmantza/pi-free
33
+ ```
34
+
35
+ ### 2. Open the model picker
36
+
37
+ Start Pi and press `Ctrl+L` to open the model picker.
38
+
39
+ Free models are shown by default — look for the provider prefixes:
40
+ - `zen/` — OpenCode Zen models (no setup required)
41
+ - `kilo/` — Kilo models (free models available immediately, more after `/login kilo`)
42
+ - `openrouter/` — OpenRouter models (free account required)
43
+ - `nvidia/` — NVIDIA NIM models (free API key required)
44
+ - `cline/` — Cline models (run `/login cline` to use)
45
+ - `mistral/` — Mistral models (API key required)
46
+ - `ollama/` — Ollama Cloud models (API key required)
47
+
48
+ ### 3. Toggle between free and paid models
49
+
50
+ Want to see paid models too? Run the toggle command for your provider:
51
+
52
+ ```
53
+ /zen-toggle # Toggle Zen free/paid models
54
+ /kilo-toggle # Toggle Kilo free/paid models
55
+ /openrouter-toggle # Toggle OpenRouter free/paid models
56
+ /nvidia-toggle # Toggle NVIDIA zero-cost/credit-costing models
57
+ /cline-toggle # Toggle Cline free/paid models
58
+ /mistral-toggle # Toggle Mistral free/paid models
59
+ /ollama-toggle # Toggle Ollama models (requires SHOW_PAID=true)
60
+ ```
61
+
62
+ You'll see a notification like: `zen: showing free models` or `zen: showing all models (including paid)`
63
+
64
+ ### 4. Add API keys for more providers (optional)
65
+
66
+ Some providers require a free account or API key.
67
+
68
+ **The first time you run Pi after installing this extension, a config file is automatically created:**
69
+ - **Linux/Mac:** `~/.pi/free.json`
70
+ - **Windows:** `%USERPROFILE%\.pi\free.json`
71
+
72
+ Add your API keys to this file:
73
+
74
+ ```json
75
+ {
76
+ "openrouter_api_key": "sk-or-v1-...",
77
+ "nvidia_api_key": "nvapi-...",
78
+ "ollama_api_key": "...",
79
+ "fireworks_api_key": "...",
80
+ "mistral_api_key": "..."
81
+ }
82
+ ```
83
+
84
+ Or set environment variables instead (same names, uppercase: `OPENROUTER_API_KEY`, `NVIDIA_API_KEY`, etc.)
85
+
86
+ See the [Providers That Need Authentication](#providers-that-need-authentication) section below for detailed setup instructions per provider.
87
+
88
+ ### 5. Quick commands reference
89
+
90
+ | Command | What it does |
91
+ |---------|-------------|
92
+ | `/{provider}-toggle` | Switch between free-only and all models for that provider |
93
+ | `/login kilo` | Start OAuth flow for Kilo |
94
+ | `/login cline` | Start OAuth flow for Cline |
95
+ | `/logout kilo` | Clear Kilo OAuth credentials |
96
+ | `/logout cline` | Clear Cline OAuth credentials |
97
+
98
+ ---
99
+
100
+ ## Using Free Models (No Setup Required)
101
+
102
+ ### OpenCode Zen — Easiest Start
103
+
104
+ Works immediately with zero setup:
105
+
106
+ 1. Press `Ctrl+L`
107
+ 2. Search for `zen/`
108
+ 3. Pick any model (e.g., `zen/mimo-v2-omni-free`)
109
+ 4. Start chatting
110
+
111
+ No account, no API key, no OAuth.
112
+
113
+ ### Ollama Cloud
114
+
115
+ Get an API key from [ollama.com/settings/keys](https://ollama.com/settings/keys), then:
116
+
117
+ **Option A: Environment variable**
118
+ ```bash
119
+ export OLLAMA_API_KEY="..."
120
+ export OLLAMA_SHOW_PAID=true
121
+ ```
122
+
123
+ **Option B: Config file** (`~/.pi/free.json`)
124
+ ```json
125
+ {
126
+ "ollama_api_key": "YOUR_KEY",
127
+ "ollama_show_paid": true
128
+ }
129
+ ```
130
+
131
+ **Note:** Ollama requires `OLLAMA_SHOW_PAID=true` because they have usage limits on their cloud API.
132
+
133
+ Free tier resets every 5 hours + 7 days.
134
+
135
+ ---
136
+
137
+ ## Providers That Need Authentication
138
+
139
+ Some providers require free accounts or OAuth to access their free tiers:
140
+
141
+ ### Kilo (free models, more after login)
142
+
143
+ Kilo shows free models immediately. To unlock all models, authenticate with Kilo's free OAuth:
144
+
145
+ ```
146
+ /login kilo
147
+ ```
148
+
149
+ This command will:
150
+ 1. Open your browser to Kilo's authorization page
151
+ 2. Show a device code in Pi's UI
152
+ 3. Wait for you to authorize in the browser
153
+ 4. Automatically complete login once approved
154
+
155
+ - No credit card required
156
+ - Free tier: 200 requests/hour
157
+ - After login, run `/kilo-toggle` to switch between free-only and all models
158
+
159
+ ### OpenRouter (free models available)
160
+
161
+ Get a free API key at [openrouter.ai/keys](https://openrouter.ai/keys), then either:
162
+
163
+ **Option A: Environment variable**
164
+ ```bash
165
+ export OPENROUTER_API_KEY="sk-or-v1-..."
166
+ ```
167
+
168
+ **Option B: Config file** (`~/.pi/free.json`)
169
+ ```json
170
+ {
171
+ "openrouter_api_key": "sk-or-v1-..."
172
+ }
173
+ ```
174
+
175
+ Then in Pi:
176
+ ```
177
+ /openrouter-all # Show all models (free + paid)
178
+ ```
179
+
180
+ ### NVIDIA NIM (Free Credits System)
181
+
182
+ NVIDIA provides **free monthly credits** (1000 requests/month) at [build.nvidia.com](https://build.nvidia.com).
183
+
184
+ **Important:** Models have different "costs" per token:
185
+ - **Zero-cost models**: Don't consume your credit balance (shown by default)
186
+ - **Credit-costing models**: Consume credits faster (hidden by default)
187
+
188
+ Get your API key and optionally enable all models:
189
+
190
+ **Option A: Show only free models (default)**
191
+ ```bash
192
+ export NVIDIA_API_KEY="nvapi-..."
193
+ ```
194
+ Uses only zero-cost models → your 1000 credits last the full month
195
+
196
+ **Option B: Show all models (uses credits faster)**
197
+ ```bash
198
+ export NVIDIA_API_KEY="nvapi-..."
199
+ export NVIDIA_SHOW_PAID=true
200
+ ```
201
+
202
+ Or in `~/.pi/free.json`:
203
+ ```json
204
+ {
205
+ "nvidia_api_key": "nvapi-...",
206
+ "nvidia_show_paid": true
207
+ }
208
+ ```
209
+
210
+ Toggle anytime with `/nvidia-toggle`
211
+
212
+ ### Cline
213
+
214
+ Cline models appear immediately in the model picker. To use them, authenticate with Cline's free account:
215
+
216
+ ```
217
+ /login cline
218
+ ```
219
+
220
+ This command will:
221
+ 1. Open your browser to Cline's sign-in page
222
+ 2. Wait for you to complete sign-in
223
+ 3. Automatically complete login once approved
224
+
225
+ - Free account required (no credit card)
226
+ - Uses local ports 48801-48811 for OAuth callback
227
+
228
+ ### Mistral
229
+
230
+ Add API key to `~/.pi/free.json` or environment variables:
231
+
232
+ ```bash
233
+ export MISTRAL_API_KEY="..."
234
+ ```
235
+
236
+ ---
237
+
238
+ ## Slash Commands
239
+
240
+ Each provider has toggle commands to switch between free and all models:
241
+
242
+ | Command | Action |
243
+ |---------|--------|
244
+ | `/zen-toggle` | Toggle between free/all Zen models |
245
+ | `/kilo-toggle` | Toggle between free/all Kilo models |
246
+ | `/openrouter-toggle` | Toggle between free/all OpenRouter models |
247
+ | `/nvidia-toggle` | Toggle between free/all NVIDIA models |
248
+ | `/cline-toggle` | Toggle between free/all Cline models |
249
+ | `/mistral-toggle` | Toggle between free/all Mistral models |
250
+ | `/ollama-toggle` | Toggle between free/all Ollama models |
251
+
252
+ **The toggle command:**
253
+ - Switches between showing only free models vs. all available models
254
+ - **Persists your preference** to `~/.pi/free.json` for next startup
255
+ - Shows a notification: "zen: showing free models" or "zen: showing all models (including paid)"
256
+
257
+ ---
258
+
259
+ ## Configuration
260
+
261
+ Create `~/.pi/free.json` in your home directory:
262
+
263
+ ```json
264
+ {
265
+ "openrouter_api_key": "YOUR_OPENROUTER_KEY",
266
+ "nvidia_api_key": "YOUR_NVIDIA_KEY",
267
+ "fireworks_api_key": "YOUR_FIREWORKS_KEY",
268
+ "mistral_api_key": "YOUR_MISTRAL_KEY",
269
+ "opencode_api_key": "YOUR_ZEN_KEY",
270
+ "ollama_api_key": "YOUR_OLLAMA_KEY",
271
+ "ollama_show_paid": true,
272
+ "hidden_models": ["model-id-to-hide"]
273
+ }
274
+ ```
275
+
276
+ Or use environment variables (same names, uppercase):
277
+
278
+ ```bash
279
+ export OPENROUTER_API_KEY="..."
280
+ export NVIDIA_API_KEY="..."
281
+ ```
282
+
283
+ ---
284
+
285
+ ## License
286
+
287
+ MIT — See [LICENSE](LICENSE)
288
+
289
+ **Questions?** [Open an issue](https://github.com/apmantza/pi-free/issues)