pi-openrouter-realtime 0.2.0 → 0.2.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
@@ -4,6 +4,8 @@
4
4
 
5
5
  Pi extension for OpenRouter that loads the latest models from OpenRouter in real time, keeps the default model list simple, and lets you enrich a specific model with provider and quantization variants.
6
6
 
7
+ Once the extension is installed and your OpenRouter credential is configured in pi, each new pi session automatically fetches the latest OpenRouter model list.
8
+
7
9
  Npm package:
8
10
 
9
11
  - `pi-openrouter-realtime`
@@ -19,19 +21,74 @@ Npm package:
19
21
 
20
22
  ## Install
21
23
 
22
- ### From npm
24
+ ### 1) Install the extension
25
+
26
+ From npm:
23
27
 
24
28
  ```bash
25
29
  pi install npm:pi-openrouter-realtime
26
30
  ```
27
31
 
28
- ### From GitHub
32
+ From GitHub:
29
33
 
30
34
  ```bash
31
35
  pi install git:github.com/olixis/pi-openrouter-plus
32
36
  ```
33
37
 
34
- ### Try without installing
38
+ ### 2) Connect pi to OpenRouter
39
+
40
+ #### Recommended: use `pi-connect` to set up OpenRouter
41
+
42
+ The `git:github.com/hk-vk/pi-connect` package makes provider setup much easier and gives you a simple `/connect` flow inside pi.
43
+
44
+ Install it:
45
+
46
+ ```bash
47
+ pi install git:github.com/hk-vk/pi-connect
48
+ ```
49
+
50
+ Then open pi and connect OpenRouter:
51
+
52
+ ```bash
53
+ pi
54
+ /connect openrouter
55
+ ```
56
+
57
+ When prompted:
58
+
59
+ 1. Paste your OpenRouter API key
60
+ 2. Confirm/save it
61
+ 3. Start a new pi session, or restart the current one
62
+
63
+ `pi-connect` stores the credential in `~/.pi/agent/auth.json`, and this extension will then automatically fetch the latest models from OpenRouter when pi starts.
64
+
65
+ #### Official pi ways to connect OpenRouter
66
+
67
+ Pi supports OpenRouter via either an environment variable or `~/.pi/agent/auth.json`.
68
+
69
+ Using an environment variable:
70
+
71
+ ```bash
72
+ export OPENROUTER_API_KEY=sk-or-...
73
+ pi
74
+ ```
75
+
76
+ Using `~/.pi/agent/auth.json`:
77
+
78
+ ```json
79
+ {
80
+ "openrouter": { "type": "api_key", "key": "sk-or-..." }
81
+ }
82
+ ```
83
+
84
+ Pi's official provider docs use:
85
+
86
+ - Environment variable: `OPENROUTER_API_KEY`
87
+ - `auth.json` key: `openrouter`
88
+
89
+ After the key is available, this extension automatically syncs the latest plain OpenRouter model list at session start.
90
+
91
+ ### 3) Try without installing
35
92
 
36
93
  ```bash
37
94
  pi -e npm:pi-openrouter-realtime
@@ -56,16 +113,16 @@ pi -e git:github.com/olixis/pi-openrouter-plus
56
113
 
57
114
  This keeps the normal OpenRouter catalog and adds variants like:
58
115
 
59
- - `Kwaipilot: KAT-Coder-Pro V2 (StreamLake)`
60
- - `Kwaipilot: KAT-Coder-Pro V2 (AtlasCloud · fp8)`
116
+ - `StreamLake — Kwaipilot: KAT-Coder-Pro V2`
117
+ - `AtlasCloud · fp8 — Kwaipilot: KAT-Coder-Pro V2`
61
118
 
62
119
  ## Behavior
63
120
 
64
- - On startup, the extension syncs the latest plain OpenRouter model list from OpenRouter
121
+ - After the extension is installed and OpenRouter auth is configured, each new pi session syncs the latest plain OpenRouter model list from OpenRouter automatically
65
122
  - Enrichment is manual and targeted to one model at a time
66
123
  - Quantization variants are exposed as separate model choices when available
67
124
  - Enriched variants are translated into OpenRouter provider routing fields at request time
68
- - If you want to go back to the default list, run `/openrouter-sync`
125
+ - If you want to refresh manually or go back to the default list, run `/openrouter-sync`
69
126
 
70
127
  ## Development
71
128
 
@@ -11,7 +11,7 @@ const OPENROUTER_MODELS_URL = "https://openrouter.ai/api/v1/models";
11
11
  const OPENROUTER_BASE_URL = "https://openrouter.ai/api/v1";
12
12
  const PROVIDER_NAME = "openrouter";
13
13
  const CACHE_TTL_MS = 30 * 60 * 1000; // 30 minutes
14
- const ENRICHED_MODEL_PREFIX = "openrouter-route:";
14
+ const ENRICHED_MODEL_PREFIX = "@or:";
15
15
 
16
16
  type InputType = "text" | "image";
17
17
  type SyncMode = "plain" | "enriched";
@@ -163,14 +163,16 @@ function toProviderModel(m: OpenRouterModel): ProviderModelConfig {
163
163
  }
164
164
 
165
165
  function createVariantId(baseModelId: string, providerSlug: string, quantization?: string): string {
166
- const q = quantization || "default";
167
- return `${ENRICHED_MODEL_PREFIX}${baseModelId}::${providerSlug}::${q}`;
166
+ const routeLabel = quantization ? `${providerSlug}:${quantization}` : providerSlug;
167
+ // Keep provider/quantization first so truncated picker/footer labels still show
168
+ // the routing info that makes enriched variants useful.
169
+ return `${ENRICHED_MODEL_PREFIX}${routeLabel}:${baseModelId}`;
168
170
  }
169
171
 
170
172
  function createVariantName(baseName: string, providerName: string, quantization?: string): string {
171
173
  return quantization
172
- ? `${baseName} (${providerName} · ${quantization})`
173
- : `${baseName} (${providerName})`;
174
+ ? `${providerName} · ${quantization} ${baseName}`
175
+ : `${providerName} ${baseName}`;
174
176
  }
175
177
 
176
178
  function resetCaches() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-openrouter-realtime",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "OpenRouter extension for pi that loads the latest models from OpenRouter in real time and adds optional provider and quantization enrichment per model",
5
5
  "license": "MIT",
6
6
  "type": "module",