@billjr99/pi-openai-compat 1.1.16 → 1.1.18

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 (3) hide show
  1. package/README.md +4 -25
  2. package/index.ts +3 -37
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -59,24 +59,6 @@ If pi is already running when you install, type `/reload` first.
59
59
  | **llmproxy** | `http://localhost:8080/v1` (editable) | Keyless by default; bearer token if your instance requires one |
60
60
  | **Custom** | Any URL you supply | Optional bearer token |
61
61
 
62
- > **llmproxy and the `__` model-id rewrite.**
63
- > [llmproxy](https://github.com/BillJr99/llmproxy) advertises model ids in the
64
- > `provider__model` form (e.g. `openrouter__gpt-4`) and exposes virtual models
65
- > such as `llmproxy__free` and `llmproxy__loadbalanced`. pi rejects model ids that
66
- > contain `__`, so without special handling **every llmproxy model is silently
67
- > dropped from `/model`**. The llmproxy template therefore sets
68
- > `rewriteDoubleUnderscore: true`: the extension rewrites the first `__` of each id
69
- > to `/` (e.g. `openrouter__gpt-4` → `openrouter/gpt-4`, `llmproxy__free` →
70
- > `llmproxy/free`) before registering with pi. llmproxy canonicalizes that slash
71
- > form back to `__` on each request, so routing still works.
72
- >
73
- > The flag is a per-provider config field (`rewriteDoubleUnderscore`, default
74
- > **false**) and is enabled automatically only for the llmproxy template — other
75
- > providers are unaffected. If you added llmproxy as a **Custom** endpoint instead
76
- > of via the llmproxy template, set `"rewriteDoubleUnderscore": true` on that
77
- > provider in `~/.config/pi-openai-compat/config.json` (or re-run `/compat-login`
78
- > and pick **llmproxy (local)**).
79
-
80
62
  > **Providers whose model catalog lives at a non-standard `/models` path (as of June 2026)**
81
63
  > Some providers don't return models at `<base_url>/models`. The extension
82
64
  > handles them in one of two ways:
@@ -347,13 +329,10 @@ For OpenRouter: some keys are restricted to free-tier models only.
347
329
  For NIM: confirm your account has inference access enabled.
348
330
 
349
331
  **`/compat-login` reports N models but far fewer appear in `/model`**
350
- This is the classic llmproxy symptom: pi drops every model id containing `__`, so
351
- llmproxy's `provider__model` ids (and `llmproxy__free` / `llmproxy__loadbalanced`)
352
- never show. Make sure you logged in via the **llmproxy (local)** template (it sets
353
- `rewriteDoubleUnderscore: true` automatically). If you used **Custom**, add
354
- `"rewriteDoubleUnderscore": true` to that provider in
355
- `~/.config/pi-openai-compat/config.json` and re-run `/compat-refresh`. After the
356
- fix the ids appear in slash form (`openrouter/gpt-4`, `llmproxy/free`).
332
+ The usual cause is a **scoped or restricted API key/account** the catalog
333
+ endpoint advertises the full model list, but your credentials are only entitled
334
+ to a subset, so pi only surfaces the ones you can actually use. Check whether your
335
+ key is limited to specific models or a free tier on the provider's dashboard.
357
336
 
358
337
  **Models appear in `/model` but requests fail**
359
338
  Check `/compat-login` ran successfully (no error message).
package/index.ts CHANGED
@@ -48,13 +48,6 @@ interface ProviderConfig {
48
48
  // matches its template and can't be auto-migrated, so the notice is shown
49
49
  // only once rather than on every session_start while the config stays stale.
50
50
  staleNotified?: boolean;
51
- // When true, rewrite the FIRST "__" of every model id to "/" before
52
- // registering with pi. pi rejects model ids containing "__", so providers like
53
- // llmproxy (which uses "provider__model" ids) would otherwise have their entire
54
- // catalog dropped from /model. The rewrite is the inverse of llmproxy's own
55
- // request-side canonicalization, so requests still round-trip. Defaults false;
56
- // the wizard turns it on only for the llmproxy template.
57
- rewriteDoubleUnderscore?: boolean;
58
51
  }
59
52
 
60
53
  interface ExtensionConfig {
@@ -104,12 +97,6 @@ const TEMPLATES: Record<string, {
104
97
  modelsIdField?: string;
105
98
  /** Keep only models whose task.name matches this string (case-insensitive). */
106
99
  modelsKeepTask?: string;
107
- /**
108
- * Rewrite the first "__" of each model id to "/" before registering with pi.
109
- * pi drops model ids containing "__", so this is required for llmproxy (whose
110
- * ids are "provider__model"). Default false; set true only where pi needs it.
111
- */
112
- rewriteDoubleUnderscore?: boolean;
113
100
  }> = {
114
101
  openrouter: {
115
102
  displayName: "OpenRouter",
@@ -301,10 +288,6 @@ const TEMPLATES: Record<string, {
301
288
  baseUrl: "http://localhost:8080/v1",
302
289
  keyless: true,
303
290
  promptUrl: true,
304
- // llmproxy advertises "provider__model" ids (and virtuals like
305
- // "llmproxy__free"). pi rejects "__" in model ids, so rewrite the first
306
- // "__" to "/" here; llmproxy canonicalizes the slash form back on requests.
307
- rewriteDoubleUnderscore: true,
308
291
  },
309
292
  vercel: {
310
293
  displayName: "Vercel AI Gateway",
@@ -552,21 +535,9 @@ async function fetchModels(
552
535
  // Provider registration helpers
553
536
  // ─────────────────────────────────────────────────────────────────────────────
554
537
 
555
- /**
556
- * Rewrite the FIRST "__" of a model id to "/". Only the first occurrence is
557
- * touched: the provider/virtual segment that precedes it never contains "__" or
558
- * "/", so this is the exact inverse of the slash→"__" canonicalization llmproxy
559
- * applies on the request side, keeping ids round-trippable. Ids without "__" are
560
- * returned unchanged.
561
- */
562
- function rewriteFirstDoubleUnderscore(id: string): string {
563
- const i = id.indexOf("__");
564
- return i === -1 ? id : `${id.slice(0, i)}/${id.slice(i + 2)}`;
565
- }
566
-
567
- function buildProviderModels(models: CachedModel[], rewriteDoubleUnderscore = false) {
538
+ function buildProviderModels(models: CachedModel[]) {
568
539
  return models.map((m) => {
569
- const id = rewriteDoubleUnderscore ? rewriteFirstDoubleUnderscore(m.id) : m.id;
540
+ const id = m.id;
570
541
  return {
571
542
  id,
572
543
  name: id,
@@ -584,16 +555,12 @@ function compatKey(key: string): string {
584
555
  }
585
556
 
586
557
  function registerProvider(pi: ExtensionAPI, key: string, p: ProviderConfig): void {
587
- // Honor the persisted per-provider flag; fall back to the template default for
588
- // this key so providers logged in before the flag existed (e.g. an existing
589
- // llmproxy provider) still get the rewrite without a re-login.
590
- const rewrite = p.rewriteDoubleUnderscore ?? TEMPLATES[key]?.rewriteDoubleUnderscore ?? false;
591
558
  pi.registerProvider(compatKey(key), {
592
559
  name: `compat/${key.replace(/_/g, "-")}`,
593
560
  baseUrl: p.baseUrl,
594
561
  apiKey: p.apiKey ?? (isLocalUrl(p.baseUrl) ? "local" : ""),
595
562
  api: "openai-completions" as const,
596
- models: buildProviderModels(p.cachedModels, rewrite),
563
+ models: buildProviderModels(p.cachedModels),
597
564
  });
598
565
  }
599
566
 
@@ -836,7 +803,6 @@ export default async function (pi: ExtensionAPI) {
836
803
  modelsUrl,
837
804
  modelsIdField: tpl.modelsIdField,
838
805
  modelsKeepTask: tpl.modelsKeepTask,
839
- rewriteDoubleUnderscore: tpl.rewriteDoubleUnderscore,
840
806
  };
841
807
  saveConfig(config);
842
808
  registerProvider(pi, key, config.providers[key]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@billjr99/pi-openai-compat",
3
- "version": "1.1.16",
3
+ "version": "1.1.18",
4
4
  "description": "pi-coding-agent extension: OpenAI-compatible endpoint support (OpenRouter, NVIDIA NIM, Nous Portal, Ollama, custom)",
5
5
  "author": "Bill Mongan <https://github.com/BillJr99>",
6
6
  "license": "MIT",