pi-baseten-provider 1.0.9 → 1.0.10

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
@@ -79,10 +79,8 @@ pi
79
79
  | Kimi K2.6 | 262K | ✅ | ✅ | $0.95 | $4.00 |
80
80
  | Kimi K2.7 Code | 262K | ✅ | ✅ | $0.95 | $4.00 |
81
81
  | Kimi K3 | 1.0M | ✅ | ✅ | $3.00 | $15.00 |
82
- | Mercury 2 | 8K | ❌ | ✅ | Free | Free |
83
82
  | Nemotron Ultra | 203K | ❌ | ✅ | $0.60 | $2.40 |
84
83
  | OpenAI GPT 120B | 128K | ❌ | ✅ | $0.10 | $0.50 |
85
- | SID-1 | 33K | ❌ | ❌ | Free | Free |
86
84
 
87
85
  *Costs are per million tokens. Prices subject to change — check [baseten.co/pricing](https://www.baseten.co/pricing/) for current pricing.*
88
86
 
@@ -1 +1,48 @@
1
- {}
1
+ {
2
+ "inception/mercury-2": {
3
+ "id": "inception/mercury-2",
4
+ "name": "Mercury 2",
5
+ "reasoning": true,
6
+ "input": [
7
+ "text"
8
+ ],
9
+ "cost": {
10
+ "input": 0,
11
+ "output": 0,
12
+ "cacheRead": 0,
13
+ "cacheWrite": 0
14
+ },
15
+ "contextWindow": 8192,
16
+ "maxTokens": 5000,
17
+ "compat": {
18
+ "supportsDeveloperRole": true,
19
+ "supportsStore": false,
20
+ "maxTokensField": "max_completion_tokens",
21
+ "thinkingFormat": "openai"
22
+ },
23
+ "deprecatedAt": "2026-08-05T02:00:12.114Z"
24
+ },
25
+ "sid/sid-1": {
26
+ "id": "sid/sid-1",
27
+ "name": "SID-1",
28
+ "reasoning": true,
29
+ "input": [
30
+ "text"
31
+ ],
32
+ "cost": {
33
+ "input": 0,
34
+ "output": 0,
35
+ "cacheRead": 0,
36
+ "cacheWrite": 0
37
+ },
38
+ "contextWindow": 32768,
39
+ "maxTokens": 5000,
40
+ "compat": {
41
+ "supportsDeveloperRole": true,
42
+ "supportsStore": false,
43
+ "maxTokensField": "max_completion_tokens",
44
+ "thinkingFormat": "openai"
45
+ },
46
+ "deprecatedAt": "2026-08-05T02:00:12.114Z"
47
+ }
48
+ }
package/models.json CHANGED
@@ -224,28 +224,6 @@
224
224
  "thinkingFormat": "openai"
225
225
  }
226
226
  },
227
- {
228
- "id": "inception/mercury-2",
229
- "name": "Mercury 2",
230
- "reasoning": true,
231
- "input": [
232
- "text"
233
- ],
234
- "cost": {
235
- "input": 0,
236
- "output": 0,
237
- "cacheRead": 0,
238
- "cacheWrite": 0
239
- },
240
- "contextWindow": 8192,
241
- "maxTokens": 5000,
242
- "compat": {
243
- "supportsDeveloperRole": true,
244
- "supportsStore": false,
245
- "maxTokensField": "max_completion_tokens",
246
- "thinkingFormat": "openai"
247
- }
248
- },
249
227
  {
250
228
  "id": "nvidia/NVIDIA-Nemotron-3-Ultra-550B-A55B",
251
229
  "name": "Nemotron Ultra",
@@ -290,27 +268,5 @@
290
268
  "thinkingFormat": "openai",
291
269
  "supportsReasoningEffort": true
292
270
  }
293
- },
294
- {
295
- "id": "sid/sid-1",
296
- "name": "SID-1",
297
- "reasoning": true,
298
- "input": [
299
- "text"
300
- ],
301
- "cost": {
302
- "input": 0,
303
- "output": 0,
304
- "cacheRead": 0,
305
- "cacheWrite": 0
306
- },
307
- "contextWindow": 32768,
308
- "maxTokens": 5000,
309
- "compat": {
310
- "supportsDeveloperRole": true,
311
- "supportsStore": false,
312
- "maxTokensField": "max_completion_tokens",
313
- "thinkingFormat": "openai"
314
- }
315
271
  }
316
272
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-baseten-provider",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
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",
package/patch.json CHANGED
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "deepseek-ai/DeepSeek-V4-Flash-0731": {
3
+ "maxTokens": 384000,
3
4
  "thinkingLevelMap": {
4
5
  "off": "none",
5
6
  "minimal": null,
@@ -17,15 +17,119 @@
17
17
  * patch.json and custom-models.json are applied at runtime by the provider.
18
18
  * They are NOT baked into models.json, but ARE used to generate the README table.
19
19
  *
20
- * Requires BASETEN_API_KEY environment variable.
20
+ * API key: the stored `baseten` credential in ~/.pi/agent/auth.json wins, then
21
+ * the BASETEN_API_KEY environment variable. The script refuses to run without one.
21
22
  */
22
23
 
23
24
  import fs from 'fs';
25
+ import os from 'os';
26
+ import { execSync } from 'child_process';
24
27
  import path from 'path';
25
28
  import { fileURLToPath } from 'url';
26
29
 
27
30
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
28
31
 
32
+ // pi's agent directory: PI_CODING_AGENT_DIR (with ~ expansion) or ~/.pi/agent.
33
+ function piAgentDir() {
34
+ const envDir = process.env.PI_CODING_AGENT_DIR;
35
+ if (envDir) {
36
+ return envDir.startsWith('~/') || envDir === '~'
37
+ ? path.join(os.homedir(), envDir.slice(1))
38
+ : envDir;
39
+ }
40
+ return path.join(os.homedir(), '.pi', 'agent');
41
+ }
42
+
43
+ const AUTH_JSON_PATH = path.join(piAgentDir(), 'auth.json');
44
+
45
+ /**
46
+ * Resolve a configured value using pi's semantics (resolve-config-value.ts in
47
+ * pi-mono): "!command" runs via the shell (10s timeout) and uses trimmed
48
+ * stdout; "$VAR" / "${VAR}" interpolate environment variables ("$$" escapes a
49
+ * literal "$", "$!" a literal "!"); anything else is a literal. Returns
50
+ * undefined when a referenced env var is unset or a command fails.
51
+ */
52
+ function resolveConfigValue(config, env) {
53
+ if (typeof config !== 'string' || config.length === 0) return undefined;
54
+ if (config.startsWith('!')) {
55
+ try {
56
+ const out = execSync(config.slice(1), {
57
+ encoding: 'utf8',
58
+ timeout: 10000,
59
+ stdio: ['ignore', 'pipe', 'ignore'],
60
+ });
61
+ return out.trim() || undefined;
62
+ } catch {
63
+ return undefined;
64
+ }
65
+ }
66
+ const ENV_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
67
+ let resolved = '';
68
+ let index = 0;
69
+ while (index < config.length) {
70
+ const dollar = config.indexOf('$', index);
71
+ if (dollar < 0) {
72
+ resolved += config.slice(index);
73
+ break;
74
+ }
75
+ resolved += config.slice(index, dollar);
76
+ const next = config[dollar + 1];
77
+ let name;
78
+ if (next === '$' || next === '!') {
79
+ resolved += next;
80
+ index = dollar + 2;
81
+ continue;
82
+ } else if (next === '{') {
83
+ const end = config.indexOf('}', dollar + 2);
84
+ if (end < 0) {
85
+ resolved += '$';
86
+ index = dollar + 1;
87
+ continue;
88
+ }
89
+ const inner = config.slice(dollar + 2, end);
90
+ if (!ENV_NAME_RE.test(inner)) {
91
+ resolved += config.slice(dollar, end + 1);
92
+ index = end + 1;
93
+ continue;
94
+ }
95
+ name = inner;
96
+ index = end + 1;
97
+ } else {
98
+ const match = config.slice(dollar + 1).match(/^[A-Za-z_][A-Za-z0-9_]*/);
99
+ if (!match) {
100
+ resolved += '$';
101
+ index = dollar + 1;
102
+ continue;
103
+ }
104
+ name = match[0];
105
+ index = dollar + 1 + name.length;
106
+ }
107
+ const value = (env && env[name]) || process.env[name] || undefined;
108
+ if (value === undefined) return undefined;
109
+ resolved += value;
110
+ }
111
+ return resolved;
112
+ }
113
+
114
+ /**
115
+ * The API key, resolved the way pi itself resolves it for this provider: the
116
+ * stored `baseten` credential in ~/.pi/agent/auth.json wins, then
117
+ * the BASETEN_API_KEY environment variable.
118
+ */
119
+ function resolveApiKey() {
120
+ try {
121
+ const auth = JSON.parse(fs.readFileSync(AUTH_JSON_PATH, 'utf8'));
122
+ const credential = auth?.baseten;
123
+ if (credential && credential.type === 'api_key' && typeof credential.key === 'string') {
124
+ const key = resolveConfigValue(credential.key, credential.env);
125
+ if (key) return key;
126
+ }
127
+ } catch {
128
+ // Missing or unparseable auth.json: fall through to the env var.
129
+ }
130
+ return process.env.BASETEN_API_KEY || undefined;
131
+ }
132
+
29
133
  const MODELS_API_URL = 'https://inference.baseten.co/v1/models';
30
134
  const MODELS_JSON_PATH = path.join(__dirname, '..', 'models.json');
31
135
  const PATCH_JSON_PATH = path.join(__dirname, '..', 'patch.json');
@@ -58,9 +162,9 @@ function toPerMillion(val) {
58
162
  // ─── API fetch ───────────────────────────────────────────────────────────────
59
163
 
60
164
  async function fetchModels() {
61
- const apiKey = process.env.BASETEN_API_KEY;
165
+ const apiKey = resolveApiKey();
62
166
  if (!apiKey) {
63
- throw new Error('BASETEN_API_KEY environment variable is required');
167
+ throw new Error('No API key found: no `baseten` credential resolved from ' + AUTH_JSON_PATH + ' and BASETEN_API_KEY is not set');
64
168
  }
65
169
 
66
170
  console.log(`Fetching models from ${MODELS_API_URL}...`);