pi-baseten-provider 1.0.1 → 1.0.3

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
@@ -73,7 +73,7 @@ pi
73
73
  | GLM 4.7 | 200K | ❌ | ✅ | $0.60 | $2.20 |
74
74
  | GLM 5 | 203K | ❌ | ✅ | $0.95 | $3.15 |
75
75
  | GLM 5.1 | 203K | ❌ | ❌ | $1.30 | $4.30 |
76
- | GLM 5.2 | 262K | ❌ | ✅ | $1.40 | $4.40 |
76
+ | GLM 5.2 | 203K | ❌ | ✅ | $1.40 | $4.40 |
77
77
  | Kimi K2.5 | 262K | ✅ | ✅ | $0.60 | $3.00 |
78
78
  | Kimi K2.6 | 262K | ✅ | ✅ | $0.60 | $3.00 |
79
79
  | Kimi K2.7 Code | 262K | ❌ | ✅ | $0.95 | $4.00 |
package/index.ts CHANGED
@@ -165,7 +165,10 @@ function transformApiModel(apiModel: any): JsonModel | null {
165
165
  const features: string[] = apiModel.supported_features || [];
166
166
  const hasVision = (apiModel.input_modalities || []).includes("image");
167
167
  const pricing = apiModel.pricing || {};
168
- const toPerM = (v: any) => (typeof v === "string" ? parseFloat(v) : (v || 0)) * 1_000_000;
168
+ // API returns per-token pricing; convert to $/M and round to 6 decimals.
169
+ // The ×1e6 multiply produces float noise (e.g. 0.7000000000000001); rounding to
170
+ // 6 decimals normalizes it and preserves sub-cent cache prices like 0.003.
171
+ const toPerM = (v: any) => Math.round((typeof v === "string" ? parseFloat(v) : (v || 0)) * 1_000_000 * 1e6) / 1e6;
169
172
  const model: JsonModel = {
170
173
  id: apiModel.id,
171
174
  name: apiModel.name || apiModel.id,
@@ -228,9 +231,20 @@ function mergeWithEmbedded(liveModels: JsonModel[], embeddedModels: JsonModel[])
228
231
  const embedded = embeddedMap.get(liveModel.id);
229
232
  seen.add(liveModel.id);
230
233
  if (embedded) {
234
+ // Self-heal: live API pricing is authoritative field-by-field. Prefer the
235
+ // live cost when the API reports it (non-zero); fall back to embedded when
236
+ // the API is silent (0) so curated cacheRead/cacheWrite isn't clobbered and
237
+ // providers whose /models endpoint exposes no pricing keep their curated
238
+ // cost. Curation (reasoning/input/compat/name) still wins via ...embedded.
231
239
  result.push({
232
240
  ...liveModel,
233
241
  ...embedded,
242
+ cost: {
243
+ input: liveModel.cost.input || embedded.cost.input,
244
+ output: liveModel.cost.output || embedded.cost.output,
245
+ cacheRead: liveModel.cost.cacheRead || embedded.cost.cacheRead,
246
+ cacheWrite: liveModel.cost.cacheWrite || embedded.cost.cacheWrite,
247
+ },
234
248
  contextWindow: liveModel.contextWindow || embedded.contextWindow,
235
249
  });
236
250
  } else {
package/models.json CHANGED
@@ -12,8 +12,8 @@
12
12
  "cacheRead": 0,
13
13
  "cacheWrite": 0
14
14
  },
15
- "contextWindow": 131000,
16
- "maxTokens": 131000,
15
+ "contextWindow": 262144,
16
+ "maxTokens": 262144,
17
17
  "compat": {
18
18
  "supportsDeveloperRole": true,
19
19
  "supportsStore": false,
@@ -99,8 +99,8 @@
99
99
  "cacheRead": 0,
100
100
  "cacheWrite": 0
101
101
  },
102
- "contextWindow": 262144,
103
- "maxTokens": 262144,
102
+ "contextWindow": 202720,
103
+ "maxTokens": 202720,
104
104
  "compat": {
105
105
  "supportsDeveloperRole": true,
106
106
  "supportsStore": false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-baseten-provider",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Baseten provider extension for pi - Access DeepSeek, Kimi, GLM, MiniMax, Nemotron, and GPT-OSS models through the Baseten Model API",
5
5
  "author": "monotykamary",
6
6
  "homepage": "https://github.com/monotykamary/pi-baseten-provider#readme",
@@ -50,7 +50,9 @@ function saveJson(filePath, data) {
50
50
  // Convert per-token pricing from API to per-million-tokens
51
51
  function toPerMillion(val) {
52
52
  if (val === '' || val === null || val === undefined) return null;
53
- return Math.round(parseFloat(val) * 1_000_000 * 100) / 100;
53
+ // Round to 6 decimals of $/M: normalizes float noise from the ×1e6 multiply
54
+ // and preserves sub-cent cache prices like 0.003 ($/M).
55
+ return Math.round(parseFloat(val) * 1_000_000 * 1e6) / 1e6;
54
56
  }
55
57
 
56
58
  // ─── API fetch ───────────────────────────────────────────────────────────────