pi-free 1.0.9 → 2.0.1

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 (63) hide show
  1. package/CHANGELOG.md +138 -0
  2. package/README.md +393 -367
  3. package/config.ts +170 -121
  4. package/constants.ts +23 -61
  5. package/index.ts +148 -0
  6. package/lib/built-in-toggle.ts +206 -0
  7. package/lib/json-persistence.ts +11 -10
  8. package/lib/logger.ts +2 -2
  9. package/lib/model-enhancer.ts +20 -20
  10. package/lib/open-browser.ts +41 -0
  11. package/lib/provider-cache.ts +106 -0
  12. package/lib/registry.ts +144 -0
  13. package/package.json +8 -23
  14. package/provider-factory.ts +25 -41
  15. package/provider-failover/benchmark-lookup.ts +247 -0
  16. package/provider-failover/benchmarks-chunk-0.ts +2010 -0
  17. package/provider-failover/benchmarks-chunk-1.ts +1988 -0
  18. package/provider-failover/benchmarks-chunk-2.ts +2010 -0
  19. package/provider-failover/benchmarks-chunk-3.ts +2010 -0
  20. package/provider-failover/benchmarks-chunk-4.ts +1969 -0
  21. package/provider-failover/hardcoded-benchmarks.ts +22 -10025
  22. package/provider-helper.ts +260 -259
  23. package/providers/{cline-auth.ts → cline/cline-auth.ts} +2 -2
  24. package/providers/cline/cline-models.ts +128 -0
  25. package/providers/{cline.ts → cline/cline.ts} +298 -257
  26. package/providers/cloudflare/cloudflare.ts +368 -0
  27. package/providers/dynamic-built-in/index.ts +432 -0
  28. package/providers/{kilo-auth.ts → kilo/kilo-auth.ts} +3 -20
  29. package/providers/{kilo-models.ts → kilo/kilo-models.ts} +2 -2
  30. package/providers/kilo/kilo.ts +235 -0
  31. package/providers/{modal.ts → modal/modal.ts} +4 -3
  32. package/providers/{nvidia.ts → nvidia/nvidia.ts} +152 -113
  33. package/providers/ollama/ollama.ts +172 -0
  34. package/providers/opencode-session.ts +34 -34
  35. package/providers/{qwen-auth.ts → qwen/qwen-auth.ts} +24 -40
  36. package/providers/{qwen-models.ts → qwen/qwen-models.ts} +101 -95
  37. package/providers/{qwen.ts → qwen/qwen.ts} +83 -13
  38. package/provider-failover/auto-switch.ts +0 -350
  39. package/provider-failover/errors.ts +0 -275
  40. package/provider-failover/index.ts +0 -238
  41. package/providers/cline-models.ts +0 -77
  42. package/providers/factory.ts +0 -125
  43. package/providers/fireworks.ts +0 -49
  44. package/providers/go.ts +0 -216
  45. package/providers/kilo.ts +0 -146
  46. package/providers/mistral.ts +0 -144
  47. package/providers/ollama.ts +0 -113
  48. package/providers/openrouter.ts +0 -175
  49. package/providers/zen.ts +0 -371
  50. package/usage/commands.ts +0 -17
  51. package/usage/cumulative.ts +0 -193
  52. package/usage/formatters.ts +0 -115
  53. package/usage/index.ts +0 -46
  54. package/usage/limits.ts +0 -148
  55. package/usage/metrics.ts +0 -222
  56. package/usage/sessions.ts +0 -355
  57. package/usage/store.ts +0 -99
  58. package/usage/tracking.ts +0 -329
  59. package/usage/types.ts +0 -26
  60. package/usage/widget.ts +0 -90
  61. package/widget/data.ts +0 -113
  62. package/widget/format.ts +0 -26
  63. package/widget/render.ts +0 -117
package/README.md CHANGED
@@ -1,367 +1,393 @@
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 10 different providers.**
10
-
11
- When you install pi-free, it:
12
-
13
- 1. **Registers 9 AI providers** with Pi's model picker — OpenCode Zen, Kilo, OpenRouter, NVIDIA NIM, Cline, Mistral, Ollama Cloud, Qwen, and Modal
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
- - `qwen/` — Qwen Coder (run `/login qwen` to use, 1,000 free requests/day)
48
- - `modal/` — GLM-5.1 FP8 via Modal (API key required, free promotional period until April 30, 2026)
49
-
50
- ### 3. Toggle between free and paid models
51
-
52
- Want to see paid models too? Run the toggle command for your provider:
53
-
54
- ```
55
- /zen-toggle # Toggle Zen free/paid models
56
- /kilo-toggle # Toggle Kilo free/paid models
57
- /openrouter-toggle # Toggle OpenRouter free/paid models
58
- /nvidia-toggle # Toggle NVIDIA zero-cost/credit-costing models
59
- /cline-toggle # Toggle Cline free/paid models
60
- /mistral-toggle # Toggle Mistral free/paid models
61
- /ollama-toggle # Toggle Ollama models (requires SHOW_PAID=true)
62
- ```
63
-
64
- You'll see a notification like: `zen: showing free models` or `zen: showing all models (including paid)`
65
-
66
- ### 4. Add API keys for more providers (optional)
67
-
68
- Some providers require a free account or API key.
69
-
70
- **The first time you run Pi after installing this extension, a config file is automatically created:**
71
- - **Linux/Mac:** `~/.pi/free.json`
72
- - **Windows:** `%USERPROFILE%\.pi\free.json`
73
-
74
- Add your API keys to this file:
75
-
76
- ```json
77
- {
78
- "openrouter_api_key": "sk-or-v1-...",
79
- "nvidia_api_key": "nvapi-...",
80
- "ollama_api_key": "...",
81
- "fireworks_api_key": "...",
82
- "mistral_api_key": "...",
83
- "modal_api_key": "sk-modal-..."
84
- }
85
- ```
86
-
87
- Or set environment variables instead (same names, uppercase: `OPENROUTER_API_KEY`, `NVIDIA_API_KEY`, etc.)
88
-
89
- See the [Providers That Need Authentication](#providers-that-need-authentication) section below for detailed setup instructions per provider.
90
-
91
- ### 5. Quick commands reference
92
-
93
- | Command | What it does |
94
- |---------|-------------|
95
- | `/{provider}-toggle` | Switch between free-only and all models for that provider |
96
- | `/login kilo` | Start OAuth flow for Kilo |
97
- | `/login cline` | Start OAuth flow for Cline |
98
- | `/login qwen` | Start OAuth flow for Qwen |
99
- | `/logout kilo` | Clear Kilo OAuth credentials |
100
- | `/logout cline` | Clear Cline OAuth credentials |
101
- | `/logout qwen` | Clear Qwen OAuth credentials |
102
-
103
- ---
104
-
105
- ## Using Free Models (No Setup Required)
106
-
107
- ### OpenCode Zen — Easiest Start
108
-
109
- Works immediately with zero setup:
110
-
111
- 1. Press `Ctrl+L`
112
- 2. Search for `zen/`
113
- 3. Pick any model (e.g., `zen/mimo-v2-omni-free`)
114
- 4. Start chatting
115
-
116
- No account, no API key, no OAuth.
117
-
118
- ### Ollama Cloud
119
-
120
- Get an API key from [ollama.com/settings/keys](https://ollama.com/settings/keys), then:
121
-
122
- **Option A: Environment variable**
123
- ```bash
124
- export OLLAMA_API_KEY="..."
125
- export OLLAMA_SHOW_PAID=true
126
- ```
127
-
128
- **Option B: Config file** (`~/.pi/free.json`)
129
- ```json
130
- {
131
- "ollama_api_key": "YOUR_KEY",
132
- "ollama_show_paid": true
133
- }
134
- ```
135
-
136
- **Note:** Ollama requires `OLLAMA_SHOW_PAID=true` because they have usage limits on their cloud API.
137
-
138
- Free tier resets every 5 hours + 7 days.
139
-
140
- ---
141
-
142
- ## Providers That Need Authentication
143
-
144
- Some providers require free accounts or OAuth to access their free tiers:
145
-
146
- ### Kilo (free models, more after login)
147
-
148
- Kilo shows free models immediately. To unlock all models, authenticate with Kilo's free OAuth:
149
-
150
- ```
151
- /login kilo
152
- ```
153
-
154
- This command will:
155
- 1. Open your browser to Kilo's authorization page
156
- 2. Show a device code in Pi's UI
157
- 3. Wait for you to authorize in the browser
158
- 4. Automatically complete login once approved
159
-
160
- - No credit card required
161
- - Free tier: 200 requests/hour
162
- - After login, run `/kilo-toggle` to switch between free-only and all models
163
-
164
- ### OpenRouter (free models available)
165
-
166
- Get a free API key at [openrouter.ai/keys](https://openrouter.ai/keys), then either:
167
-
168
- **Option A: Environment variable**
169
- ```bash
170
- export OPENROUTER_API_KEY="sk-or-v1-..."
171
- ```
172
-
173
- **Option B: Config file** (`~/.pi/free.json`)
174
- ```json
175
- {
176
- "openrouter_api_key": "sk-or-v1-..."
177
- }
178
- ```
179
-
180
- Then in Pi:
181
- ```
182
- /openrouter-all # Show all models (free + paid)
183
- ```
184
-
185
- ### NVIDIA NIM (Free Credits System)
186
-
187
- NVIDIA provides **free monthly credits** (1000 requests/month) at [build.nvidia.com](https://build.nvidia.com).
188
-
189
- **Important:** Models have different "costs" per token:
190
- - **Zero-cost models**: Don't consume your credit balance (shown by default)
191
- - **Credit-costing models**: Consume credits faster (hidden by default)
192
-
193
- Get your API key and optionally enable all models:
194
-
195
- **Option A: Show only free models (default)**
196
- ```bash
197
- export NVIDIA_API_KEY="nvapi-..."
198
- ```
199
- Uses only zero-cost models your 1000 credits last the full month
200
-
201
- **Option B: Show all models (uses credits faster)**
202
- ```bash
203
- export NVIDIA_API_KEY="nvapi-..."
204
- export NVIDIA_SHOW_PAID=true
205
- ```
206
-
207
- Or in `~/.pi/free.json`:
208
- ```json
209
- {
210
- "nvidia_api_key": "nvapi-...",
211
- "nvidia_show_paid": true
212
- }
213
- ```
214
-
215
- Toggle anytime with `/nvidia-toggle`
216
-
217
- ### Cline
218
-
219
- Cline models appear immediately in the model picker. To use them, authenticate with Cline's free account:
220
-
221
- ```
222
- /login cline
223
- ```
224
-
225
- This command will:
226
- 1. Open your browser to Cline's sign-in page
227
- 2. Wait for you to complete sign-in
228
- 3. Automatically complete login once approved
229
-
230
- - Free account required (no credit card)
231
- - Uses local ports 48801-48811 for OAuth callback
232
-
233
- ### Modal (GLM-5.1 FP8 free until April 30, 2026)
234
-
235
- Modal hosts GLM-5.1 FP8 with a free promotional period. Get an API key at [modal.com](https://modal.com), then:
236
-
237
- **Option A: Environment variable**
238
- ```bash
239
- export MODAL_API_KEY="sk-modal-..."
240
- ```
241
-
242
- **Option B: Config file** (`~/.pi/free.json`)
243
- ```json
244
- {
245
- "modal_api_key": "sk-modal-..."
246
- }
247
- ```
248
-
249
- Then select a `modal/` model in the model picker.
250
-
251
- **Details:**
252
- - Free promotional period until April 30, 2026
253
- - Model: GLM-5.1 FP8 (128k context, 16k max output)
254
- - No credit card required during the promotional period
255
-
256
- ### Mistral
257
-
258
- Add API key to `~/.pi/free.json` or environment variables:
259
-
260
- ```bash
261
- export MISTRAL_API_KEY="..."
262
- ```
263
-
264
- ### Qwen (1,000 free requests/day)
265
-
266
- Qwen provides free access to **Qwen Coder** (Qwen3.6-Plus) via OAuth device flow — no API key or credit card needed.
267
-
268
- ```
269
- /login qwen
270
- ```
271
-
272
- This command will:
273
- 1. Open your browser to Qwen Studio's authorization page
274
- 2. Display a device code (enter it if the browser doesn't pre-fill it)
275
- 3. Wait for you to authorize in the browser
276
- 4. Automatically complete login once approved
277
-
278
- Then select a `qwen/` model in the model picker.
279
-
280
- **Details:**
281
- - Free tier: 1,000 requests/day
282
- - Model: Qwen Coder (131k context, 16k max output)
283
- - No credit card required — just a free [Qwen Studio](https://chat.qwen.ai) account
284
- - To re-authenticate: `/logout qwen` then `/login qwen`
285
-
286
- ---
287
-
288
- ## Slash Commands
289
-
290
- Each provider has toggle commands to switch between free and all models:
291
-
292
- | Command | Action |
293
- |---------|--------|
294
- | `/zen-toggle` | Toggle between free/all Zen models |
295
- | `/kilo-toggle` | Toggle between free/all Kilo models |
296
- | `/openrouter-toggle` | Toggle between free/all OpenRouter models |
297
- | `/nvidia-toggle` | Toggle between free/all NVIDIA models |
298
- | `/cline-toggle` | Toggle between free/all Cline models |
299
- | `/mistral-toggle` | Toggle between free/all Mistral models |
300
- | `/ollama-toggle` | Toggle between free/all Ollama models |
301
- | `/login qwen` | Authenticate with Qwen Studio (OAuth) |
302
- | `/logout qwen` | Clear Qwen credentials |
303
-
304
- **The toggle command:**
305
- - Switches between showing only free models vs. all available models
306
- - **Persists your preference** to `~/.pi/free.json` for next startup
307
- - Shows a notification: "zen: showing free models" or "zen: showing all models (including paid)"
308
-
309
- ---
310
-
311
- ## Configuration
312
-
313
- Create `~/.pi/free.json` in your home directory:
314
-
315
- ```json
316
- {
317
- "openrouter_api_key": "YOUR_OPENROUTER_KEY",
318
- "nvidia_api_key": "YOUR_NVIDIA_KEY",
319
- "fireworks_api_key": "YOUR_FIREWORKS_KEY",
320
- "mistral_api_key": "YOUR_MISTRAL_KEY",
321
- "opencode_api_key": "YOUR_ZEN_KEY",
322
- "ollama_api_key": "YOUR_OLLAMA_KEY",
323
- "ollama_show_paid": true,
324
- "modal_api_key": "YOUR_MODAL_KEY",
325
- "hidden_models": ["model-id-to-hide"]
326
- }
327
- ```
328
-
329
- Or use environment variables (same names, uppercase):
330
-
331
- ```bash
332
- export OPENROUTER_API_KEY="..."
333
- export NVIDIA_API_KEY="..."
334
- ```
335
-
336
- ---
337
-
338
- ## Logging & Debugging
339
-
340
- pi-free now writes extension logs to:
341
-
342
- - **Windows:** `%USERPROFILE%\.pi\free.log`
343
- - **Linux/macOS:** `~/.pi/free.log`
344
-
345
- Useful env vars:
346
-
347
- ```bash
348
- # Console log verbosity (default: error)
349
- LOG_LEVEL=debug
350
-
351
- # File log verbosity (default: debug)
352
- PI_FREE_LOG_LEVEL=debug
353
-
354
- # Custom log path (optional)
355
- PI_FREE_LOG_PATH=/tmp/pi-free.log
356
-
357
- # Disable file logging
358
- PI_FREE_FILE_LOG=false
359
- ```
360
-
361
- ---
362
-
363
- ## License
364
-
365
- MIT — See [LICENSE](LICENSE)
366
-
367
- **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 multiple providers.**
10
+
11
+ When you install pi-free, it:
12
+
13
+ 1. **Registers free-tier providers** with Pi's model picker — Kilo, Cline, NVIDIA, Cloudflare, Modal, Ollama Cloud, and more
14
+
15
+ 2. **Fetches models dynamically** for Pi's built-in providers when API keys are configured Mistral, Groq, Cerebras, xAI, Hugging Face, OpenRouter
16
+
17
+ 3. **Filters to show only free models by default** for providers that expose pricing You see only the models that cost $0 to use. Paid models are hidden until you explicitly toggle them on.
18
+
19
+ 4. **Provides per-provider toggle commands** — Run `/toggle-{provider}` (e.g., `/toggle-kilo`, `/toggle-opencode`) to switch between free-only mode and showing all models including paid ones
20
+
21
+ 5. **Handles authentication for you** — OAuth flows (Kilo, Cline) open your browser automatically; API keys are read from `~/.pi/free.json` or environment variables
22
+
23
+ 6. **Adds Coding Index scores** — Model names include a coding benchmark score (CI: 45.2) to help you pick capable coding models at a glance
24
+
25
+ 7. **Persists your preferences** — Your toggle choices (free vs all models) are saved to `~/.pi/free.json` and remembered across Pi restarts
26
+
27
+ ---
28
+
29
+ ## How to use
30
+
31
+ ### 1. Install the extension
32
+
33
+ ```bash
34
+ pi install git:github.com/apmantza/pi-free
35
+ ```
36
+
37
+ ### 2. Open the model picker
38
+
39
+ Start Pi and press `Ctrl+L` to open the model picker.
40
+
41
+ Free models are shown by default look for the provider prefixes:
42
+
43
+ **✅ Offers Free Models (no usage limits, no payment required):**
44
+ - `opencode/` — OpenCode models (no setup required; toggle with `/toggle-opencode`)
45
+ - `kilo/` — Kilo models (free models available immediately, more after `/login kilo`)
46
+ - `openrouter/` — OpenRouter models (free account required)
47
+ - `cline/` — Cline models (run `/login cline` to use)
48
+
49
+ **🔄 Freemium (free tier with limits, then paid):**
50
+ - `nvidia/` NVIDIA NIM models (1,000 free requests/month, then credits)
51
+ - `cloudflare/` — Cloudflare Workers AI (10K Neurons/day free tier, then $0.011/1K Neurons)
52
+ - `modal/` GLM-5.1 FP8 via Modal (free promotional period until April 30, 2026)
53
+ - `ollama-cloud/` — Ollama Cloud models (usage-based free tier, resets every 5 hours + 7 days)
54
+
55
+ **🔧 Dynamic API Providers (fetched when API key configured):**
56
+ - `mistral/` Mistral models (when `MISTRAL_API_KEY` set)
57
+ - `groq/` Groq models (when `GROQ_API_KEY` set)
58
+ - `cerebras/` Cerebras models (when `CEREBRAS_API_KEY` set)
59
+ - `xai/` xAI models (when `XAI_API_KEY` set)
60
+ - `huggingface/` Hugging Face models (when `HF_TOKEN` set)
61
+
62
+ **Note:** Fireworks is now a [built-in Pi provider](https://github.com/badlogic/pi-mono/blob/main/packages/coding-agent/CHANGELOG.md#0681---2026-04-22) — no extension needed. Set `FIREWORKS_API_KEY` to use it directly.
63
+
64
+ ### 3. Toggle between free and paid models
65
+
66
+ Want to see paid models too? Run the toggle command for your provider:
67
+
68
+ ```
69
+ /toggle-opencode # Toggle OpenCode (✅ offers free models)
70
+ /toggle-kilo # Toggle Kilo (✅ offers free models)
71
+ /toggle-openrouter # Toggle OpenRouter (✅ offers free models)
72
+ /toggle-cline # Toggle Cline (✅ offers free models)
73
+ /toggle-nvidia # Toggle NVIDIA (🔄 freemium)
74
+ /toggle-cloudflare # Toggle Cloudflare (🔄 freemium)
75
+ /toggle-ollama # Toggle Ollama Cloud (🔄 freemium)
76
+ /toggle-mistral # Toggle Mistral (🔧 dynamic - needs API key)
77
+ /toggle-groq # Toggle Groq (🔧 dynamic - needs API key)
78
+ /toggle-cerebras # Toggle Cerebras (🔧 dynamic - needs API key)
79
+ ```
80
+
81
+ **Notes:**
82
+ - **Toggle commands are mainly for ✅ and 🔄 providers** — to switch between "free models only" vs "show paid models too"
83
+ - **🔧 Dynamic providers** show all fetched models by default — the toggle filters the list when you have an API key configured
84
+ - **Freemium providers** show all models by default; you manage your usage limits via their dashboards
85
+
86
+ You'll see a notification like: `opencode: showing free models` or `opencode: showing all models`
87
+
88
+ ### 4. Add API keys for more providers (optional)
89
+
90
+ Some providers require a free account or API key.
91
+
92
+ **The first time you run Pi after installing this extension, a config file is automatically created:**
93
+ - **Linux/Mac:** `~/.pi/free.json`
94
+ - **Windows:** `%USERPROFILE%\.pi\free.json`
95
+
96
+ Add your API keys to this file:
97
+
98
+ ```json
99
+ {
100
+ "openrouter_api_key": "sk-or-v1-...",
101
+ "nvidia_api_key": "nvapi-...",
102
+ "cloudflare_api_token": "...",
103
+ "ollama_api_key": "...",
104
+ "mistral_api_key": "...",
105
+ "modal_api_key": "sk-modal-..."
106
+ }
107
+ ```
108
+
109
+ Or set environment variables instead (same names, uppercase: `OPENROUTER_API_KEY`, `NVIDIA_API_KEY`, etc.)
110
+
111
+ See the [Providers That Need Authentication](#providers-that-need-authentication) section below for detailed setup instructions per provider.
112
+
113
+ ### 5. Quick commands reference
114
+
115
+ | Command | What it does |
116
+ |---------|-------------|
117
+ | `/toggle-{provider}` | Switch between free-only and all models for that provider |
118
+ | `/free-providers` | Show free/paid model counts for all providers |
119
+ | `/login kilo` | Start OAuth flow for Kilo |
120
+ | `/login cline` | Start OAuth flow for Cline |
121
+ | `/logout kilo` | Clear Kilo OAuth credentials |
122
+ | `/logout cline` | Clear Cline OAuth credentials |
123
+
124
+ ---
125
+
126
+ ## Using Free Models (No Setup Required)
127
+
128
+ ### OpenCode
129
+
130
+ Works immediately with zero setup:
131
+
132
+ 1. Press `Ctrl+L`
133
+ 2. Search for `opencode/`
134
+ 3. Pick any model (e.g., `opencode/big-pickle`)
135
+ 4. Start chatting
136
+
137
+ No account, no API key, no OAuth. Run `/toggle-opencode` to switch between free and paid OpenCode models.
138
+
139
+ ### Kilo (free models, more after login)
140
+
141
+ Kilo shows free models immediately. To unlock all models, authenticate with Kilo's free OAuth:
142
+
143
+ ```
144
+ /login kilo
145
+ ```
146
+
147
+ This command will:
148
+ 1. Open your browser to Kilo's authorization page
149
+ 2. Show a device code in Pi's UI
150
+ 3. Wait for you to authorize in the browser
151
+ 4. Automatically complete login once approved
152
+
153
+ - No credit card required
154
+ - Free tier: 200 requests/hour
155
+ - After login, run `/toggle-kilo` to switch between free-only and all models
156
+
157
+ ### Cline (free account)
158
+
159
+ Cline models appear immediately in the model picker. To use them, authenticate with Cline's free account:
160
+
161
+ ```
162
+ /login cline
163
+ ```
164
+
165
+ This command will:
166
+ 1. Open your browser to Cline's sign-in page
167
+ 2. Wait for you to complete sign-in
168
+ 3. Automatically complete login once approved
169
+
170
+ - Free account required (no credit card)
171
+ - Uses local ports 48801-48811 for OAuth callback
172
+
173
+ ---
174
+
175
+ ## Providers That Need Authentication
176
+
177
+ Some providers require a free account or API key to access their free tiers.
178
+
179
+ ---
180
+
181
+ ### 🆓 Free Providers
182
+
183
+ ### OpenRouter (free models available)
184
+
185
+ Get a free API key at [openrouter.ai/keys](https://openrouter.ai/keys), then either:
186
+
187
+ **Option A: Environment variable**
188
+ ```bash
189
+ export OPENROUTER_API_KEY="sk-or-v1-..."
190
+ ```
191
+
192
+ **Option B: Config file** (`~/.pi/free.json`)
193
+ ```json
194
+ {
195
+ "openrouter_api_key": "sk-or-v1-..."
196
+ }
197
+ ```
198
+
199
+ Then use `/toggle-openrouter` to switch between free-only and all models.
200
+
201
+ ### NVIDIA NIM (Free Credits System)
202
+
203
+ NVIDIA provides **free monthly credits** (1000 requests/month) at [build.nvidia.com](https://build.nvidia.com).
204
+
205
+ **Important:** Models have different "costs" per token:
206
+ - **Zero-cost models**: Don't consume your credit balance (shown by default)
207
+ - **Credit-costing models**: Consume credits faster (hidden by default)
208
+
209
+ Get your API key and optionally enable all models:
210
+
211
+ **Option A: Show only free models (default)**
212
+ ```bash
213
+ export NVIDIA_API_KEY="nvapi-..."
214
+ ```
215
+ Uses only zero-cost models → your 1000 credits last the full month
216
+
217
+ **Option B: Show all models (uses credits faster)**
218
+ ```bash
219
+ export NVIDIA_API_KEY="nvapi-..."
220
+ export NVIDIA_SHOW_PAID=true
221
+ ```
222
+
223
+ Or in `~/.pi/free.json`:
224
+ ```json
225
+ {
226
+ "nvidia_api_key": "nvapi-...",
227
+ "nvidia_show_paid": true
228
+ }
229
+ ```
230
+
231
+ Toggle anytime with `/toggle-nvidia`
232
+
233
+ ### Cloudflare Workers AI (10K Neurons/day Free Tier)
234
+
235
+ Cloudflare provides **50+ open-source AI models** with a generous free tier:
236
+ - **10,000 Neurons per day FREE** (resets daily at 00:00 UTC)
237
+ - **$0.011 per 1,000 Neurons** beyond the free allocation
238
+
239
+ Get your API token at [dash.cloudflare.com/profile/api-tokens](https://dash.cloudflare.com/profile/api-tokens):
240
+ 1. Create a token with "Cloudflare AI" → "Read" permission
241
+ 2. Or use "My Account" → "Read" for broader access
242
+
243
+ **Setup:**
244
+ ```bash
245
+ export CLOUDFLARE_API_TOKEN="your_token_here"
246
+ ```
247
+
248
+ The account ID is automatically derived from your token. Optionally, you can also set:
249
+ ```bash
250
+ export CLOUDFLARE_ACCOUNT_ID="your_account_id" # Optional
251
+ ```
252
+
253
+ **Models available:** Llama 4, Mistral Small 3.1, DeepSeek R1, Gemma 4, Kimi K2.5/2.6, and more.
254
+
255
+ Toggle with `/toggle-cloudflare`
256
+
257
+ ### Modal (GLM-5.1 FP8 — free promotional period until April 30, 2026)
258
+
259
+ Modal hosts GLM-5.1 FP8 with a free promotional period. Get an API key at [modal.com](https://modal.com), then:
260
+
261
+ **Option A: Environment variable**
262
+ ```bash
263
+ export MODAL_API_KEY="sk-modal-..."
264
+ ```
265
+
266
+ **Option B: Config file** (`~/.pi/free.json`)
267
+ ```json
268
+ {
269
+ "modal_api_key": "sk-modal-..."
270
+ }
271
+ ```
272
+
273
+ Then select a `modal/` model in the model picker.
274
+
275
+ **Details:**
276
+ - Free promotional period until April 30, 2026
277
+ - Model: GLM-5.1 FP8 (128k context, 16k max output)
278
+ - No credit card required during the promotional period
279
+
280
+ ### Ollama Cloud
281
+
282
+ Get an API key from [ollama.com/settings/keys](https://ollama.com/settings/keys), then:
283
+
284
+ **Option A: Environment variable**
285
+ ```bash
286
+ export OLLAMA_API_KEY="..."
287
+ export OLLAMA_SHOW_PAID=true
288
+ ```
289
+
290
+ **Option B: Config file** (`~/.pi/free.json`)
291
+ ```json
292
+ {
293
+ "ollama_api_key": "YOUR_KEY",
294
+ "ollama_show_paid": true
295
+ }
296
+ ```
297
+
298
+ **Note:** Ollama requires `OLLAMA_SHOW_PAID=true` because they have usage limits on their cloud API.
299
+
300
+ Free tier resets every 5 hours + 7 days.
301
+
302
+ ### Mistral (free API key)
303
+
304
+ Add API key to `~/.pi/free.json` or environment variables:
305
+
306
+ ```bash
307
+ export MISTRAL_API_KEY="..."
308
+ ```
309
+
310
+ ---
311
+
312
+ ## Slash Commands
313
+
314
+ Each provider has toggle commands to switch between free and all models:
315
+
316
+ | Command | Action |
317
+ |---------|--------|
318
+ | `/toggle-opencode` | Toggle between free/all OpenCode models |
319
+ | `/toggle-kilo` | Toggle between free/all Kilo models |
320
+ | `/toggle-openrouter` | Toggle between free/all OpenRouter models |
321
+ | `/toggle-cline` | Toggle between free/all Cline models |
322
+ | `/toggle-nvidia` | Toggle between free/all NVIDIA models |
323
+ | `/toggle-cloudflare` | Toggle between free/all Cloudflare models |
324
+ | `/toggle-ollama` | Toggle between free/all Ollama Cloud models |
325
+ | `/toggle-mistral` | Toggle between free/all Mistral models (🔧 dynamic) |
326
+ | `/toggle-groq` | Toggle between free/all Groq models (🔧 dynamic) |
327
+ | `/toggle-cerebras` | Toggle between free/all Cerebras models (🔧 dynamic) |
328
+
329
+ **The toggle command:**
330
+ - **For ✅ free providers**: Switches between showing only free models vs. all available models (including paid)
331
+ - **For 🔄 freemium providers**: Shows all models by default; toggle switches between filtered and full list
332
+ - **For 🔧 dynamic API providers**: Filters the model list when you have an API key configured
333
+ - **Persists your preference** to `~/.pi/free.json` for next startup
334
+ - Shows a notification: "opencode: showing free models" or "opencode: showing all models"
335
+
336
+ ---
337
+
338
+ ## Configuration
339
+
340
+ Create `~/.pi/free.json` in your home directory:
341
+
342
+ ```json
343
+ {
344
+ "openrouter_api_key": "YOUR_OPENROUTER_KEY",
345
+ "nvidia_api_key": "YOUR_NVIDIA_KEY",
346
+ "mistral_api_key": "YOUR_MISTRAL_KEY",
347
+ "opencode_api_key": "YOUR_OPENCODE_KEY",
348
+ "ollama_api_key": "YOUR_OLLAMA_KEY",
349
+ "ollama_show_paid": true,
350
+ "modal_api_key": "YOUR_MODAL_KEY",
351
+ "hidden_models": ["model-id-to-hide"]
352
+ }
353
+ ```
354
+
355
+ Or use environment variables (same names, uppercase):
356
+
357
+ ```bash
358
+ export OPENROUTER_API_KEY="..."
359
+ export NVIDIA_API_KEY="..."
360
+ ```
361
+
362
+ ---
363
+
364
+ ## Logging & Debugging
365
+
366
+ pi-free now writes extension logs to:
367
+
368
+ - **Windows:** `%USERPROFILE%\.pi\free.log`
369
+ - **Linux/macOS:** `~/.pi/free.log`
370
+
371
+ Useful env vars:
372
+
373
+ ```bash
374
+ # Console log verbosity (default: error)
375
+ LOG_LEVEL=debug
376
+
377
+ # File log verbosity (default: debug)
378
+ PI_FREE_LOG_LEVEL=debug
379
+
380
+ # Custom log path (optional)
381
+ PI_FREE_LOG_PATH=/tmp/pi-free.log
382
+
383
+ # Disable file logging
384
+ PI_FREE_FILE_LOG=false
385
+ ```
386
+
387
+ ---
388
+
389
+ ## License
390
+
391
+ MIT — See [LICENSE](LICENSE)
392
+
393
+ **Questions?** [Open an issue](https://github.com/apmantza/pi-free/issues)