@ai-sdk/baseten 2.0.0-beta.5 → 2.0.0-beta.58

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/CHANGELOG.md CHANGED
@@ -1,5 +1,473 @@
1
1
  # @ai-sdk/baseten
2
2
 
3
+ ## 2.0.0-beta.58
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [0416e3e]
8
+ - @ai-sdk/provider@4.0.0-beta.20
9
+ - @ai-sdk/openai-compatible@3.0.0-beta.58
10
+ - @ai-sdk/provider-utils@5.0.0-beta.50
11
+
12
+ ## 2.0.0-beta.57
13
+
14
+ ### Patch Changes
15
+
16
+ - b8396f0: trigger initial beta release
17
+ - Updated dependencies [b8396f0]
18
+ - @ai-sdk/openai-compatible@3.0.0-beta.57
19
+ - @ai-sdk/provider-utils@5.0.0-beta.49
20
+ - @ai-sdk/provider@4.0.0-beta.19
21
+
22
+ ## 2.0.0-canary.56
23
+
24
+ ### Patch Changes
25
+
26
+ - Updated dependencies [aeda373]
27
+ - Updated dependencies [375fdd7]
28
+ - Updated dependencies [b4507d5]
29
+ - @ai-sdk/provider-utils@5.0.0-canary.48
30
+ - @ai-sdk/openai-compatible@3.0.0-canary.56
31
+
32
+ ## 2.0.0-canary.55
33
+
34
+ ### Patch Changes
35
+
36
+ - Updated dependencies [bae5e2b]
37
+ - @ai-sdk/provider-utils@5.0.0-canary.47
38
+ - @ai-sdk/openai-compatible@3.0.0-canary.55
39
+
40
+ ## 2.0.0-canary.54
41
+
42
+ ### Patch Changes
43
+
44
+ - Updated dependencies [ce769dd]
45
+ - @ai-sdk/provider@4.0.0-canary.18
46
+ - @ai-sdk/openai-compatible@3.0.0-canary.54
47
+ - @ai-sdk/provider-utils@5.0.0-canary.46
48
+
49
+ ## 2.0.0-canary.53
50
+
51
+ ### Patch Changes
52
+
53
+ - Updated dependencies [ee798eb]
54
+ - Updated dependencies [daf6637]
55
+ - @ai-sdk/provider-utils@5.0.0-canary.45
56
+ - @ai-sdk/openai-compatible@3.0.0-canary.53
57
+
58
+ ## 2.0.0-canary.52
59
+
60
+ ### Patch Changes
61
+
62
+ - Updated dependencies [6c93e36]
63
+ - Updated dependencies [f617ac2]
64
+ - @ai-sdk/provider-utils@5.0.0-canary.44
65
+ - @ai-sdk/openai-compatible@3.0.0-canary.52
66
+
67
+ ## 2.0.0-canary.51
68
+
69
+ ### Patch Changes
70
+
71
+ - Updated dependencies [9f1e1ba]
72
+ - @ai-sdk/openai-compatible@3.0.0-canary.51
73
+
74
+ ## 2.0.0-canary.50
75
+
76
+ ### Patch Changes
77
+
78
+ - 7fc6bd6: Raise minimum supported Node.js version to 22. Supported versions: 22, 24, and 26.
79
+ - Updated dependencies [7fc6bd6]
80
+ - @ai-sdk/openai-compatible@3.0.0-canary.50
81
+ - @ai-sdk/provider-utils@5.0.0-canary.43
82
+ - @ai-sdk/provider@4.0.0-canary.17
83
+
84
+ ## 2.0.0-canary.49
85
+
86
+ ### Patch Changes
87
+
88
+ - Updated dependencies [a6617c5]
89
+ - @ai-sdk/provider-utils@5.0.0-canary.42
90
+ - @ai-sdk/openai-compatible@3.0.0-canary.49
91
+
92
+ ## 2.0.0-canary.48
93
+
94
+ ### Patch Changes
95
+
96
+ - Updated dependencies [28dfa06]
97
+ - Updated dependencies [e93fa91]
98
+ - @ai-sdk/provider-utils@5.0.0-canary.41
99
+ - @ai-sdk/openai-compatible@3.0.0-canary.48
100
+
101
+ ## 2.0.0-canary.47
102
+
103
+ ### Patch Changes
104
+
105
+ - Updated dependencies [a7de9c9]
106
+ - @ai-sdk/provider-utils@5.0.0-canary.40
107
+ - @ai-sdk/openai-compatible@3.0.0-canary.47
108
+
109
+ ## 2.0.0-canary.46
110
+
111
+ ### Patch Changes
112
+
113
+ - Updated dependencies [105f95b]
114
+ - @ai-sdk/provider-utils@5.0.0-canary.39
115
+ - @ai-sdk/openai-compatible@3.0.0-canary.46
116
+
117
+ ## 2.0.0-canary.45
118
+
119
+ ### Patch Changes
120
+
121
+ - Updated dependencies [ca446f8]
122
+ - @ai-sdk/provider-utils@5.0.0-canary.38
123
+ - @ai-sdk/openai-compatible@3.0.0-canary.45
124
+
125
+ ## 2.0.0-canary.44
126
+
127
+ ### Patch Changes
128
+
129
+ - Updated dependencies [d848405]
130
+ - @ai-sdk/provider-utils@5.0.0-canary.37
131
+ - @ai-sdk/openai-compatible@3.0.0-canary.44
132
+
133
+ ## 2.0.0-canary.43
134
+
135
+ ### Patch Changes
136
+
137
+ - Updated dependencies [ca39020]
138
+ - @ai-sdk/provider-utils@5.0.0-canary.36
139
+ - @ai-sdk/openai-compatible@3.0.0-canary.43
140
+
141
+ ## 2.0.0-canary.42
142
+
143
+ ### Patch Changes
144
+
145
+ - Updated dependencies [f634bac]
146
+ - @ai-sdk/provider-utils@5.0.0-canary.35
147
+ - @ai-sdk/openai-compatible@3.0.0-canary.42
148
+
149
+ ## 2.0.0-canary.41
150
+
151
+ ### Patch Changes
152
+
153
+ - Updated dependencies [69254e0]
154
+ - Updated dependencies [3015fc3]
155
+ - @ai-sdk/provider-utils@5.0.0-canary.34
156
+ - @ai-sdk/openai-compatible@3.0.0-canary.41
157
+
158
+ ## 2.0.0-canary.40
159
+
160
+ ### Patch Changes
161
+
162
+ - Updated dependencies [2427d88]
163
+ - @ai-sdk/provider-utils@5.0.0-canary.33
164
+ - @ai-sdk/openai-compatible@3.0.0-canary.40
165
+
166
+ ## 2.0.0-canary.39
167
+
168
+ ### Patch Changes
169
+
170
+ - Updated dependencies [5463d0d]
171
+ - @ai-sdk/provider-utils@5.0.0-canary.32
172
+ - @ai-sdk/provider@4.0.0-canary.16
173
+ - @ai-sdk/openai-compatible@3.0.0-canary.39
174
+
175
+ ## 2.0.0-canary.38
176
+
177
+ ### Patch Changes
178
+
179
+ - Updated dependencies [cd9c311]
180
+ - @ai-sdk/openai-compatible@3.0.0-canary.38
181
+
182
+ ## 2.0.0-canary.37
183
+
184
+ ### Patch Changes
185
+
186
+ - 0c4c275: trigger initial canary release
187
+ - Updated dependencies [0c4c275]
188
+ - @ai-sdk/openai-compatible@3.0.0-canary.37
189
+ - @ai-sdk/provider-utils@5.0.0-canary.31
190
+ - @ai-sdk/provider@4.0.0-canary.15
191
+
192
+ ## 2.0.0-beta.36
193
+
194
+ ### Patch Changes
195
+
196
+ - Updated dependencies [e59c955]
197
+ - @ai-sdk/openai-compatible@3.0.0-beta.36
198
+
199
+ ## 2.0.0-beta.35
200
+
201
+ ### Patch Changes
202
+
203
+ - Updated dependencies [08d2129]
204
+ - Updated dependencies [04e9009]
205
+ - @ai-sdk/provider-utils@5.0.0-beta.30
206
+ - @ai-sdk/openai-compatible@3.0.0-beta.35
207
+
208
+ ## 2.0.0-beta.34
209
+
210
+ ### Patch Changes
211
+
212
+ - 258c093: chore: ensure consistent import handling and avoid import duplicates or cycles
213
+ - Updated dependencies [9bd6512]
214
+ - Updated dependencies [258c093]
215
+ - Updated dependencies [b6783da]
216
+ - @ai-sdk/openai-compatible@3.0.0-beta.34
217
+ - @ai-sdk/provider-utils@5.0.0-beta.29
218
+ - @ai-sdk/provider@4.0.0-beta.14
219
+
220
+ ## 2.0.0-beta.33
221
+
222
+ ### Patch Changes
223
+
224
+ - 9f0e36c: trigger release for all packages after provenance setup
225
+ - Updated dependencies [9f0e36c]
226
+ - @ai-sdk/openai-compatible@3.0.0-beta.33
227
+ - @ai-sdk/provider@4.0.0-beta.13
228
+ - @ai-sdk/provider-utils@5.0.0-beta.28
229
+
230
+ ## 2.0.0-beta.32
231
+
232
+ ### Patch Changes
233
+
234
+ - Updated dependencies [ab81968]
235
+ - Updated dependencies [785fe16]
236
+ - Updated dependencies [67df0a0]
237
+ - Updated dependencies [befb78c]
238
+ - Updated dependencies [0458559]
239
+ - Updated dependencies [58a2ad7]
240
+ - Updated dependencies [5852c0a]
241
+ - Updated dependencies [fc92055]
242
+ - @ai-sdk/openai-compatible@3.0.0-beta.32
243
+ - @ai-sdk/provider-utils@5.0.0-beta.27
244
+
245
+ ## 2.0.0-beta.31
246
+
247
+ ### Patch Changes
248
+
249
+ - Updated dependencies [2e98477]
250
+ - Updated dependencies [bfb756d]
251
+ - @ai-sdk/provider-utils@5.0.0-beta.26
252
+ - @ai-sdk/openai-compatible@3.0.0-beta.31
253
+
254
+ ## 2.0.0-beta.30
255
+
256
+ ### Patch Changes
257
+
258
+ - Updated dependencies [eea8d98]
259
+ - @ai-sdk/provider-utils@5.0.0-beta.25
260
+ - @ai-sdk/openai-compatible@3.0.0-beta.30
261
+
262
+ ## 2.0.0-beta.29
263
+
264
+ ### Patch Changes
265
+
266
+ - Updated dependencies [f807e45]
267
+ - @ai-sdk/provider-utils@5.0.0-beta.24
268
+ - @ai-sdk/openai-compatible@3.0.0-beta.29
269
+
270
+ ## 2.0.0-beta.28
271
+
272
+ ### Patch Changes
273
+
274
+ - Updated dependencies [350ea38]
275
+ - @ai-sdk/provider-utils@5.0.0-beta.23
276
+ - @ai-sdk/openai-compatible@3.0.0-beta.28
277
+
278
+ ## 2.0.0-beta.27
279
+
280
+ ### Patch Changes
281
+
282
+ - Updated dependencies [083947b]
283
+ - @ai-sdk/provider-utils@5.0.0-beta.22
284
+ - @ai-sdk/openai-compatible@3.0.0-beta.27
285
+
286
+ ## 2.0.0-beta.26
287
+
288
+ ### Patch Changes
289
+
290
+ - Updated dependencies [add1126]
291
+ - @ai-sdk/provider-utils@5.0.0-beta.21
292
+ - @ai-sdk/openai-compatible@3.0.0-beta.26
293
+
294
+ ## 2.0.0-beta.25
295
+
296
+ ### Patch Changes
297
+
298
+ - Updated dependencies [b3976a2]
299
+ - Updated dependencies [ff5eba1]
300
+ - @ai-sdk/provider-utils@5.0.0-beta.20
301
+ - @ai-sdk/openai-compatible@3.0.0-beta.25
302
+ - @ai-sdk/provider@4.0.0-beta.12
303
+
304
+ ## 2.0.0-beta.24
305
+
306
+ ### Major Changes
307
+
308
+ - ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
309
+
310
+ ### Patch Changes
311
+
312
+ - Updated dependencies [ef992f8]
313
+ - @ai-sdk/openai-compatible@3.0.0-beta.24
314
+ - @ai-sdk/provider@4.0.0-beta.11
315
+ - @ai-sdk/provider-utils@5.0.0-beta.19
316
+
317
+ ## 2.0.0-beta.23
318
+
319
+ ### Patch Changes
320
+
321
+ - 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
322
+ - Updated dependencies [90e2d8a]
323
+ - @ai-sdk/openai-compatible@3.0.0-beta.23
324
+ - @ai-sdk/provider-utils@5.0.0-beta.18
325
+
326
+ ## 2.0.0-beta.22
327
+
328
+ ### Patch Changes
329
+
330
+ - Updated dependencies [3ae1786]
331
+ - @ai-sdk/provider-utils@5.0.0-beta.17
332
+ - @ai-sdk/openai-compatible@3.0.0-beta.22
333
+
334
+ ## 2.0.0-beta.21
335
+
336
+ ### Patch Changes
337
+
338
+ - Updated dependencies [176466a]
339
+ - @ai-sdk/provider@4.0.0-beta.10
340
+ - @ai-sdk/openai-compatible@3.0.0-beta.21
341
+ - @ai-sdk/provider-utils@5.0.0-beta.16
342
+
343
+ ## 2.0.0-beta.20
344
+
345
+ ### Patch Changes
346
+
347
+ - Updated dependencies [e311194]
348
+ - @ai-sdk/provider@4.0.0-beta.9
349
+ - @ai-sdk/openai-compatible@3.0.0-beta.20
350
+ - @ai-sdk/provider-utils@5.0.0-beta.15
351
+
352
+ ## 2.0.0-beta.19
353
+
354
+ ### Patch Changes
355
+
356
+ - Updated dependencies [34bd95d]
357
+ - Updated dependencies [008271d]
358
+ - @ai-sdk/provider@4.0.0-beta.8
359
+ - @ai-sdk/openai-compatible@3.0.0-beta.19
360
+ - @ai-sdk/provider-utils@5.0.0-beta.14
361
+
362
+ ## 2.0.0-beta.18
363
+
364
+ ### Patch Changes
365
+
366
+ - Updated dependencies [b0c2869]
367
+ - Updated dependencies [7e26e81]
368
+ - @ai-sdk/provider-utils@5.0.0-beta.13
369
+ - @ai-sdk/openai-compatible@3.0.0-beta.18
370
+
371
+ ## 2.0.0-beta.17
372
+
373
+ ### Patch Changes
374
+
375
+ - Updated dependencies [816ff67]
376
+ - @ai-sdk/openai-compatible@3.0.0-beta.17
377
+
378
+ ## 2.0.0-beta.16
379
+
380
+ ### Patch Changes
381
+
382
+ - Updated dependencies [46d1149]
383
+ - @ai-sdk/provider-utils@5.0.0-beta.12
384
+ - @ai-sdk/openai-compatible@3.0.0-beta.16
385
+
386
+ ## 2.0.0-beta.15
387
+
388
+ ### Patch Changes
389
+
390
+ - Updated dependencies [6fd51c0]
391
+ - @ai-sdk/provider-utils@5.0.0-beta.11
392
+ - @ai-sdk/provider@4.0.0-beta.7
393
+ - @ai-sdk/openai-compatible@3.0.0-beta.15
394
+
395
+ ## 2.0.0-beta.14
396
+
397
+ ### Patch Changes
398
+
399
+ - Updated dependencies [c29a26f]
400
+ - @ai-sdk/openai-compatible@3.0.0-beta.14
401
+ - @ai-sdk/provider-utils@5.0.0-beta.10
402
+ - @ai-sdk/provider@4.0.0-beta.6
403
+
404
+ ## 2.0.0-beta.13
405
+
406
+ ### Patch Changes
407
+
408
+ - 38fc777: Add AI Gateway hint to provider READMEs
409
+ - Updated dependencies [38fc777]
410
+ - @ai-sdk/openai-compatible@3.0.0-beta.13
411
+
412
+ ## 2.0.0-beta.12
413
+
414
+ ### Patch Changes
415
+
416
+ - Updated dependencies [2e17091]
417
+ - @ai-sdk/provider-utils@5.0.0-beta.9
418
+ - @ai-sdk/openai-compatible@3.0.0-beta.12
419
+
420
+ ## 2.0.0-beta.11
421
+
422
+ ### Patch Changes
423
+
424
+ - Updated dependencies [986c6fd]
425
+ - Updated dependencies [493295c]
426
+ - @ai-sdk/provider-utils@5.0.0-beta.8
427
+ - @ai-sdk/openai-compatible@3.0.0-beta.11
428
+
429
+ ## 2.0.0-beta.10
430
+
431
+ ### Patch Changes
432
+
433
+ - Updated dependencies [1f509d4]
434
+ - @ai-sdk/provider-utils@5.0.0-beta.7
435
+ - @ai-sdk/provider@4.0.0-beta.5
436
+ - @ai-sdk/openai-compatible@3.0.0-beta.10
437
+
438
+ ## 2.0.0-beta.9
439
+
440
+ ### Patch Changes
441
+
442
+ - Updated dependencies [74d520f]
443
+ - @ai-sdk/openai-compatible@3.0.0-beta.9
444
+
445
+ ## 2.0.0-beta.8
446
+
447
+ ### Patch Changes
448
+
449
+ - Updated dependencies [3887c70]
450
+ - @ai-sdk/provider-utils@5.0.0-beta.6
451
+ - @ai-sdk/provider@4.0.0-beta.4
452
+ - @ai-sdk/openai-compatible@3.0.0-beta.8
453
+
454
+ ## 2.0.0-beta.7
455
+
456
+ ### Patch Changes
457
+
458
+ - Updated dependencies [776b617]
459
+ - @ai-sdk/provider-utils@5.0.0-beta.5
460
+ - @ai-sdk/provider@4.0.0-beta.3
461
+ - @ai-sdk/openai-compatible@3.0.0-beta.7
462
+
463
+ ## 2.0.0-beta.6
464
+
465
+ ### Patch Changes
466
+
467
+ - Updated dependencies [61753c3]
468
+ - @ai-sdk/provider-utils@5.0.0-beta.4
469
+ - @ai-sdk/openai-compatible@3.0.0-beta.6
470
+
3
471
  ## 2.0.0-beta.5
4
472
 
5
473
  ### Patch Changes
@@ -366,13 +834,13 @@
366
834
  Before
367
835
 
368
836
  ```ts
369
- model.textEmbeddingModel('my-model-id');
837
+ model.textEmbeddingModel("my-model-id");
370
838
  ```
371
839
 
372
840
  After
373
841
 
374
842
  ```ts
375
- model.embeddingModel('my-model-id');
843
+ model.embeddingModel("my-model-id");
376
844
  ```
377
845
 
378
846
  - 95f65c2: chore: use import \* from zod/v4
@@ -595,13 +1063,13 @@
595
1063
  Before
596
1064
 
597
1065
  ```ts
598
- model.textEmbeddingModel('my-model-id');
1066
+ model.textEmbeddingModel("my-model-id");
599
1067
  ```
600
1068
 
601
1069
  After
602
1070
 
603
1071
  ```ts
604
- model.embeddingModel('my-model-id');
1072
+ model.embeddingModel("my-model-id");
605
1073
  ```
606
1074
 
607
1075
  - Updated dependencies [8d9e8ad]
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  The **[Baseten provider](https://ai-sdk.dev/providers/ai-sdk-providers/baseten)** for the [AI SDK](https://ai-sdk.dev/docs) contains language model and embedding model support for the [Baseten](https://baseten.co) platform.
4
4
 
5
+ > **Deploying to Vercel?** With Vercel's AI Gateway you can access Baseten (and hundreds of models from other providers) — no additional packages, API keys, or extra cost. [Get started with AI Gateway](https://vercel.com/ai-gateway).
6
+
5
7
  ## Setup
6
8
 
7
9
  The Baseten provider is available in the `@ai-sdk/baseten` module. You can install it with
package/dist/index.js CHANGED
@@ -1,44 +1,25 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- VERSION: () => VERSION,
24
- baseten: () => baseten,
25
- createBaseten: () => createBaseten
26
- });
27
- module.exports = __toCommonJS(index_exports);
28
-
29
1
  // src/baseten-provider.ts
30
- var import_openai_compatible = require("@ai-sdk/openai-compatible");
31
- var import_provider = require("@ai-sdk/provider");
32
- var import_provider_utils = require("@ai-sdk/provider-utils");
33
- var import_v4 = require("zod/v4");
34
- var import_performance_client = require("@basetenlabs/performance-client");
2
+ import {
3
+ OpenAICompatibleChatLanguageModel,
4
+ OpenAICompatibleEmbeddingModel
5
+ } from "@ai-sdk/openai-compatible";
6
+ import {
7
+ NoSuchModelError
8
+ } from "@ai-sdk/provider";
9
+ import {
10
+ loadApiKey,
11
+ withoutTrailingSlash,
12
+ withUserAgentSuffix
13
+ } from "@ai-sdk/provider-utils";
14
+ import { z } from "zod/v4";
15
+ import { PerformanceClient } from "@basetenlabs/performance-client";
35
16
 
36
17
  // src/version.ts
37
- var VERSION = true ? "2.0.0-beta.5" : "0.0.0-test";
18
+ var VERSION = true ? "2.0.0-beta.58" : "0.0.0-test";
38
19
 
39
20
  // src/baseten-provider.ts
40
- var basetenErrorSchema = import_v4.z.object({
41
- error: import_v4.z.string()
21
+ var basetenErrorSchema = z.object({
22
+ error: z.string()
42
23
  });
43
24
  var basetenErrorStructure = {
44
25
  errorSchema: basetenErrorSchema,
@@ -47,10 +28,10 @@ var basetenErrorStructure = {
47
28
  var defaultBaseURL = "https://inference.baseten.co/v1";
48
29
  function createBaseten(options = {}) {
49
30
  var _a;
50
- const baseURL = (0, import_provider_utils.withoutTrailingSlash)((_a = options.baseURL) != null ? _a : defaultBaseURL);
51
- const getHeaders = () => (0, import_provider_utils.withUserAgentSuffix)(
31
+ const baseURL = withoutTrailingSlash((_a = options.baseURL) != null ? _a : defaultBaseURL);
32
+ const getHeaders = () => withUserAgentSuffix(
52
33
  {
53
- Authorization: `Bearer ${(0, import_provider_utils.loadApiKey)({
34
+ Authorization: `Bearer ${loadApiKey({
54
35
  apiKey: options.apiKey,
55
36
  environmentVariableName: "BASETEN_API_KEY",
56
37
  description: "Baseten API key"
@@ -75,7 +56,7 @@ function createBaseten(options = {}) {
75
56
  if (customURL) {
76
57
  const isOpenAICompatible = customURL.includes("/sync/v1");
77
58
  if (isOpenAICompatible) {
78
- return new import_openai_compatible.OpenAICompatibleChatLanguageModel(modelId != null ? modelId : "placeholder", {
59
+ return new OpenAICompatibleChatLanguageModel(modelId != null ? modelId : "placeholder", {
79
60
  ...getCommonModelConfig("chat", customURL),
80
61
  errorStructure: basetenErrorStructure
81
62
  });
@@ -85,7 +66,7 @@ function createBaseten(options = {}) {
85
66
  );
86
67
  }
87
68
  }
88
- return new import_openai_compatible.OpenAICompatibleChatLanguageModel(modelId != null ? modelId : "chat", {
69
+ return new OpenAICompatibleChatLanguageModel(modelId != null ? modelId : "chat", {
89
70
  ...getCommonModelConfig("chat"),
90
71
  errorStructure: basetenErrorStructure
91
72
  });
@@ -99,7 +80,7 @@ function createBaseten(options = {}) {
99
80
  }
100
81
  const isOpenAICompatible = customURL.includes("/sync");
101
82
  if (isOpenAICompatible) {
102
- const model = new import_openai_compatible.OpenAICompatibleEmbeddingModel(
83
+ const model = new OpenAICompatibleEmbeddingModel(
103
84
  modelId != null ? modelId : "embeddings",
104
85
  {
105
86
  ...getCommonModelConfig("embedding", customURL),
@@ -107,9 +88,9 @@ function createBaseten(options = {}) {
107
88
  }
108
89
  );
109
90
  const performanceClientURL = customURL.replace("/sync/v1", "/sync");
110
- const performanceClient = new import_performance_client.PerformanceClient(
91
+ const performanceClient = new PerformanceClient(
111
92
  performanceClientURL,
112
- (0, import_provider_utils.loadApiKey)({
93
+ loadApiKey({
113
94
  apiKey: options.apiKey,
114
95
  environmentVariableName: "BASETEN_API_KEY",
115
96
  description: "Baseten API key"
@@ -144,17 +125,16 @@ function createBaseten(options = {}) {
144
125
  provider.chatModel = createChatModel;
145
126
  provider.languageModel = createChatModel;
146
127
  provider.imageModel = (modelId) => {
147
- throw new import_provider.NoSuchModelError({ modelId, modelType: "imageModel" });
128
+ throw new NoSuchModelError({ modelId, modelType: "imageModel" });
148
129
  };
149
130
  provider.embeddingModel = createEmbeddingModel;
150
131
  provider.textEmbeddingModel = createEmbeddingModel;
151
132
  return provider;
152
133
  }
153
134
  var baseten = createBaseten();
154
- // Annotate the CommonJS export names for ESM import in node:
155
- 0 && (module.exports = {
135
+ export {
156
136
  VERSION,
157
137
  baseten,
158
138
  createBaseten
159
- });
139
+ };
160
140
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/baseten-provider.ts","../src/version.ts"],"sourcesContent":["export type { BasetenChatModelId } from './baseten-chat-options';\nexport { baseten, createBaseten } from './baseten-provider';\nexport type {\n BasetenProvider,\n BasetenProviderSettings,\n BasetenErrorData,\n} from './baseten-provider';\nexport type { BasetenEmbeddingModelOptions } from './baseten-embedding-options';\nexport { VERSION } from './version';\n","import {\n OpenAICompatibleChatLanguageModel,\n OpenAICompatibleEmbeddingModel,\n ProviderErrorStructure,\n} from '@ai-sdk/openai-compatible';\nimport {\n EmbeddingModelV4,\n LanguageModelV4,\n NoSuchModelError,\n ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { BasetenChatModelId } from './baseten-chat-options';\nimport { BasetenEmbeddingModelId } from './baseten-embedding-options';\nimport { PerformanceClient } from '@basetenlabs/performance-client';\nimport { VERSION } from './version';\n\nexport type BasetenErrorData = z.infer<typeof basetenErrorSchema>;\n\nconst basetenErrorSchema = z.object({\n error: z.string(),\n});\n\nconst basetenErrorStructure: ProviderErrorStructure<BasetenErrorData> = {\n errorSchema: basetenErrorSchema,\n errorToMessage: data => data.error,\n};\n\nexport interface BasetenProviderSettings {\n /**\n * Baseten API key. Default value is taken from the `BASETEN_API_KEY`\n * environment variable.\n */\n apiKey?: string;\n\n /**\n * Base URL for the Model APIs. Default: 'https://inference.baseten.co/v1'\n */\n baseURL?: string;\n\n /**\n * Model URL for custom models (chat or embeddings).\n * If not supplied, the default Model APIs will be used.\n */\n modelURL?: string;\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\nexport interface BasetenProvider extends ProviderV4 {\n /**\n * Creates a chat model for text generation.\n */\n (modelId?: BasetenChatModelId): LanguageModelV4;\n\n /**\n * Creates a chat model for text generation.\n */\n chatModel(modelId?: BasetenChatModelId): LanguageModelV4;\n\n /**\n * Creates a language model for text generation. Alias for chatModel.\n */\n languageModel(modelId?: BasetenChatModelId): LanguageModelV4;\n\n /**\n * Creates a embedding model for text generation.\n */\n embeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV4;\n}\n\n// by default, we use the Model APIs\nconst defaultBaseURL = 'https://inference.baseten.co/v1';\n\nexport function createBaseten(\n options: BasetenProviderSettings = {},\n): BasetenProvider {\n const baseURL = withoutTrailingSlash(options.baseURL ?? defaultBaseURL);\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'BASETEN_API_KEY',\n description: 'Baseten API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk/baseten/${VERSION}`,\n );\n\n interface CommonModelConfig {\n provider: string;\n url: ({ path }: { path: string }) => string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n }\n\n const getCommonModelConfig = (\n modelType: string,\n customURL?: string,\n ): CommonModelConfig => ({\n provider: `baseten.${modelType}`,\n url: ({ path }) => {\n // For embeddings with /sync URLs (but not /sync/v1), we need to add /v1\n if (\n modelType === 'embedding' &&\n customURL?.includes('/sync') &&\n !customURL?.includes('/sync/v1')\n ) {\n return `${customURL}/v1${path}`;\n }\n return `${customURL || baseURL}${path}`;\n },\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createChatModel = (modelId?: BasetenChatModelId) => {\n // Use modelURL if provided, otherwise use default Model APIs\n const customURL = options.modelURL;\n\n if (customURL) {\n // Check if this is a /sync/v1 endpoint (OpenAI-compatible) or /predict endpoint (custom)\n const isOpenAICompatible = customURL.includes('/sync/v1');\n\n if (isOpenAICompatible) {\n // For /sync/v1 endpoints, use standard OpenAI-compatible format\n return new OpenAICompatibleChatLanguageModel(modelId ?? 'placeholder', {\n ...getCommonModelConfig('chat', customURL),\n errorStructure: basetenErrorStructure,\n });\n } else if (customURL.includes('/predict')) {\n throw new Error(\n 'Not supported. You must use a /sync/v1 endpoint for chat models.',\n );\n }\n }\n\n // Use default OpenAI-compatible format for Model APIs\n return new OpenAICompatibleChatLanguageModel(modelId ?? 'chat', {\n ...getCommonModelConfig('chat'),\n errorStructure: basetenErrorStructure,\n });\n };\n\n const createEmbeddingModel = (modelId?: BasetenEmbeddingModelId) => {\n // Use modelURL if provided\n const customURL = options.modelURL;\n if (!customURL) {\n throw new Error(\n 'No model URL provided for embeddings. Please set modelURL option for embeddings.',\n );\n }\n\n // Check if this is a /sync or /sync/v1 endpoint (OpenAI-compatible)\n // We support both /sync and /sync/v1, stripping /v1 before passing to Performance Client, as Performance Client adds /v1 itself\n const isOpenAICompatible = customURL.includes('/sync');\n\n if (isOpenAICompatible) {\n // Create the model using OpenAICompatibleEmbeddingModel and override doEmbed\n const model = new OpenAICompatibleEmbeddingModel(\n modelId ?? 'embeddings',\n {\n ...getCommonModelConfig('embedding', customURL),\n errorStructure: basetenErrorStructure,\n },\n );\n\n // Strip /v1 from URL if present before passing to Performance Client to avoid double /v1\n const performanceClientURL = customURL.replace('/sync/v1', '/sync');\n\n // Initialize the B10 Performance Client once for reuse\n const performanceClient = new PerformanceClient(\n performanceClientURL,\n loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'BASETEN_API_KEY',\n description: 'Baseten API key',\n }),\n );\n\n // Override the doEmbed method to use the pre-created Performance Client\n model.doEmbed = async params => {\n if (!params.values || !Array.isArray(params.values)) {\n throw new Error('params.values must be an array of strings');\n }\n\n // Performance Client handles batching internally, so we don't need to limit in 128 here\n const response = await performanceClient.embed(\n params.values,\n modelId ?? 'embeddings', // model_id is for Model APIs, we don't use it here for dedicated\n );\n // Transform the response to match the expected format\n const embeddings = response.data.map((item: any) => item.embedding);\n\n return {\n embeddings,\n usage: response.usage\n ? { tokens: response.usage.total_tokens }\n : undefined,\n response: { headers: {}, body: response },\n warnings: [],\n };\n };\n\n return model;\n } else {\n throw new Error(\n 'Not supported. You must use a /sync or /sync/v1 endpoint for embeddings.',\n );\n }\n };\n\n const provider = (modelId?: BasetenChatModelId) => createChatModel(modelId);\n\n provider.specificationVersion = 'v4' as const;\n provider.chatModel = createChatModel;\n provider.languageModel = createChatModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n provider.embeddingModel = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n return provider;\n}\n\nexport const baseten = createBaseten();\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,+BAIO;AACP,sBAKO;AACP,4BAKO;AACP,gBAAkB;AAGlB,gCAAkC;;;AClB3B,IAAM,UACX,OACI,iBACA;;;ADoBN,IAAM,qBAAqB,YAAE,OAAO;AAAA,EAClC,OAAO,YAAE,OAAO;AAClB,CAAC;AAED,IAAM,wBAAkE;AAAA,EACtE,aAAa;AAAA,EACb,gBAAgB,UAAQ,KAAK;AAC/B;AA2DA,IAAM,iBAAiB;AAEhB,SAAS,cACd,UAAmC,CAAC,GACnB;AA/FnB;AAgGE,QAAM,cAAU,6CAAqB,aAAQ,YAAR,YAAmB,cAAc;AACtE,QAAM,aAAa,UACjB;AAAA,IACE;AAAA,MACE,eAAe,cAAU,kCAAW;AAAA,QAClC,QAAQ,QAAQ;AAAA,QAChB,yBAAyB;AAAA,QACzB,aAAa;AAAA,MACf,CAAC,CAAC;AAAA,MACF,GAAG,QAAQ;AAAA,IACb;AAAA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E,YAAM,oBAAoB,IAAI;AAAA,QAC5B;AAAA,YACA,kCAAW;AAAA,UACT,QAAQ,QAAQ;AAAA,UAChB,yBAAyB;AAAA,UACzB,aAAa;AAAA,QACf,CAAC;AAAA,MACH;AAGA,YAAM,UAAU,OAAM,WAAU;AAC9B,YAAI,CAAC,OAAO,UAAU,CAAC,MAAM,QAAQ,OAAO,MAAM,GAAG;AACnD,gBAAM,IAAI,MAAM,2CAA2C;AAAA,QAC7D;AAGA,cAAM,WAAW,MAAM,kBAAkB;AAAA,UACvC,OAAO;AAAA,UACP,4BAAW;AAAA;AAAA,QACb;AAEA,cAAM,aAAa,SAAS,KAAK,IAAI,CAAC,SAAc,KAAK,SAAS;AAElE,eAAO;AAAA,UACL;AAAA,UACA,OAAO,SAAS,QACZ,EAAE,QAAQ,SAAS,MAAM,aAAa,IACtC;AAAA,UACJ,UAAU,EAAE,SAAS,CAAC,GAAG,MAAM,SAAS;AAAA,UACxC,UAAU,CAAC;AAAA,QACb;AAAA,MACF;AAEA,aAAO;AAAA,IACT,OAAO;AACL,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,WAAW,CAAC,YAAiC,gBAAgB,OAAO;AAE1E,WAAS,uBAAuB;AAChC,WAAS,YAAY;AACrB,WAAS,gBAAgB;AACzB,WAAS,aAAa,CAAC,YAAoB;AACzC,UAAM,IAAI,iCAAiB,EAAE,SAAS,WAAW,aAAa,CAAC;AAAA,EACjE;AACA,WAAS,iBAAiB;AAC1B,WAAS,qBAAqB;AAC9B,SAAO;AACT;AAEO,IAAM,UAAU,cAAc;","names":[]}
1
+ {"version":3,"sources":["../src/baseten-provider.ts","../src/version.ts"],"sourcesContent":["import {\n OpenAICompatibleChatLanguageModel,\n OpenAICompatibleEmbeddingModel,\n type ProviderErrorStructure,\n} from '@ai-sdk/openai-compatible';\nimport {\n NoSuchModelError,\n type EmbeddingModelV4,\n type LanguageModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport type { BasetenChatModelId } from './baseten-chat-options';\nimport type { BasetenEmbeddingModelId } from './baseten-embedding-options';\nimport { PerformanceClient } from '@basetenlabs/performance-client';\nimport { VERSION } from './version';\n\nexport type BasetenErrorData = z.infer<typeof basetenErrorSchema>;\n\nconst basetenErrorSchema = z.object({\n error: z.string(),\n});\n\nconst basetenErrorStructure: ProviderErrorStructure<BasetenErrorData> = {\n errorSchema: basetenErrorSchema,\n errorToMessage: data => data.error,\n};\n\nexport interface BasetenProviderSettings {\n /**\n * Baseten API key. Default value is taken from the `BASETEN_API_KEY`\n * environment variable.\n */\n apiKey?: string;\n\n /**\n * Base URL for the Model APIs. Default: 'https://inference.baseten.co/v1'\n */\n baseURL?: string;\n\n /**\n * Model URL for custom models (chat or embeddings).\n * If not supplied, the default Model APIs will be used.\n */\n modelURL?: string;\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\nexport interface BasetenProvider extends ProviderV4 {\n /**\n * Creates a chat model for text generation.\n */\n (modelId?: BasetenChatModelId): LanguageModelV4;\n\n /**\n * Creates a chat model for text generation.\n */\n chatModel(modelId?: BasetenChatModelId): LanguageModelV4;\n\n /**\n * Creates a language model for text generation. Alias for chatModel.\n */\n languageModel(modelId?: BasetenChatModelId): LanguageModelV4;\n\n /**\n * Creates a embedding model for text generation.\n */\n embeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV4;\n}\n\n// by default, we use the Model APIs\nconst defaultBaseURL = 'https://inference.baseten.co/v1';\n\nexport function createBaseten(\n options: BasetenProviderSettings = {},\n): BasetenProvider {\n const baseURL = withoutTrailingSlash(options.baseURL ?? defaultBaseURL);\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'BASETEN_API_KEY',\n description: 'Baseten API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk/baseten/${VERSION}`,\n );\n\n interface CommonModelConfig {\n provider: string;\n url: ({ path }: { path: string }) => string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n }\n\n const getCommonModelConfig = (\n modelType: string,\n customURL?: string,\n ): CommonModelConfig => ({\n provider: `baseten.${modelType}`,\n url: ({ path }) => {\n // For embeddings with /sync URLs (but not /sync/v1), we need to add /v1\n if (\n modelType === 'embedding' &&\n customURL?.includes('/sync') &&\n !customURL?.includes('/sync/v1')\n ) {\n return `${customURL}/v1${path}`;\n }\n return `${customURL || baseURL}${path}`;\n },\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createChatModel = (modelId?: BasetenChatModelId) => {\n // Use modelURL if provided, otherwise use default Model APIs\n const customURL = options.modelURL;\n\n if (customURL) {\n // Check if this is a /sync/v1 endpoint (OpenAI-compatible) or /predict endpoint (custom)\n const isOpenAICompatible = customURL.includes('/sync/v1');\n\n if (isOpenAICompatible) {\n // For /sync/v1 endpoints, use standard OpenAI-compatible format\n return new OpenAICompatibleChatLanguageModel(modelId ?? 'placeholder', {\n ...getCommonModelConfig('chat', customURL),\n errorStructure: basetenErrorStructure,\n });\n } else if (customURL.includes('/predict')) {\n throw new Error(\n 'Not supported. You must use a /sync/v1 endpoint for chat models.',\n );\n }\n }\n\n // Use default OpenAI-compatible format for Model APIs\n return new OpenAICompatibleChatLanguageModel(modelId ?? 'chat', {\n ...getCommonModelConfig('chat'),\n errorStructure: basetenErrorStructure,\n });\n };\n\n const createEmbeddingModel = (modelId?: BasetenEmbeddingModelId) => {\n // Use modelURL if provided\n const customURL = options.modelURL;\n if (!customURL) {\n throw new Error(\n 'No model URL provided for embeddings. Please set modelURL option for embeddings.',\n );\n }\n\n // Check if this is a /sync or /sync/v1 endpoint (OpenAI-compatible)\n // We support both /sync and /sync/v1, stripping /v1 before passing to Performance Client, as Performance Client adds /v1 itself\n const isOpenAICompatible = customURL.includes('/sync');\n\n if (isOpenAICompatible) {\n // Create the model using OpenAICompatibleEmbeddingModel and override doEmbed\n const model = new OpenAICompatibleEmbeddingModel(\n modelId ?? 'embeddings',\n {\n ...getCommonModelConfig('embedding', customURL),\n errorStructure: basetenErrorStructure,\n },\n );\n\n // Strip /v1 from URL if present before passing to Performance Client to avoid double /v1\n const performanceClientURL = customURL.replace('/sync/v1', '/sync');\n\n // Initialize the B10 Performance Client once for reuse\n const performanceClient = new PerformanceClient(\n performanceClientURL,\n loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'BASETEN_API_KEY',\n description: 'Baseten API key',\n }),\n );\n\n // Override the doEmbed method to use the pre-created Performance Client\n model.doEmbed = async params => {\n if (!params.values || !Array.isArray(params.values)) {\n throw new Error('params.values must be an array of strings');\n }\n\n // Performance Client handles batching internally, so we don't need to limit in 128 here\n const response = await performanceClient.embed(\n params.values,\n modelId ?? 'embeddings', // model_id is for Model APIs, we don't use it here for dedicated\n );\n // Transform the response to match the expected format\n const embeddings = response.data.map((item: any) => item.embedding);\n\n return {\n embeddings,\n usage: response.usage\n ? { tokens: response.usage.total_tokens }\n : undefined,\n response: { headers: {}, body: response },\n warnings: [],\n };\n };\n\n return model;\n } else {\n throw new Error(\n 'Not supported. You must use a /sync or /sync/v1 endpoint for embeddings.',\n );\n }\n };\n\n const provider = (modelId?: BasetenChatModelId) => createChatModel(modelId);\n\n provider.specificationVersion = 'v4' as const;\n provider.chatModel = createChatModel;\n provider.languageModel = createChatModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n provider.embeddingModel = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n return provider;\n}\n\nexport const baseten = createBaseten();\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP;AAAA,EACE;AAAA,OAIK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,SAAS;AAGlB,SAAS,yBAAyB;;;AClB3B,IAAM,UACX,OACI,kBACA;;;ADoBN,IAAM,qBAAqB,EAAE,OAAO;AAAA,EAClC,OAAO,EAAE,OAAO;AAClB,CAAC;AAED,IAAM,wBAAkE;AAAA,EACtE,aAAa;AAAA,EACb,gBAAgB,UAAQ,KAAK;AAC/B;AA2DA,IAAM,iBAAiB;AAEhB,SAAS,cACd,UAAmC,CAAC,GACnB;AA/FnB;AAgGE,QAAM,UAAU,sBAAqB,aAAQ,YAAR,YAAmB,cAAc;AACtE,QAAM,aAAa,MACjB;AAAA,IACE;AAAA,MACE,eAAe,UAAU,WAAW;AAAA,QAClC,QAAQ,QAAQ;AAAA,QAChB,yBAAyB;AAAA,QACzB,aAAa;AAAA,MACf,CAAC,CAAC;AAAA,MACF,GAAG,QAAQ;AAAA,IACb;AAAA,IACA,kBAAkB,OAAO;AAAA,EAC3B;AASF,QAAM,uBAAuB,CAC3B,WACA,eACuB;AAAA,IACvB,UAAU,WAAW,SAAS;AAAA,IAC9B,KAAK,CAAC,EAAE,KAAK,MAAM;AAEjB,UACE,cAAc,gBACd,uCAAW,SAAS,aACpB,EAAC,uCAAW,SAAS,cACrB;AACA,eAAO,GAAG,SAAS,MAAM,IAAI;AAAA,MAC/B;AACA,aAAO,GAAG,aAAa,OAAO,GAAG,IAAI;AAAA,IACvC;AAAA,IACA,SAAS;AAAA,IACT,OAAO,QAAQ;AAAA,EACjB;AAEA,QAAM,kBAAkB,CAAC,YAAiC;A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AK,IAAI,CAAC,SAAc,KAAK,SAAS;AAElE,eAAO;AAAA,UACL;AAAA,UACA,OAAO,SAAS,QACZ,EAAE,QAAQ,SAAS,MAAM,aAAa,IACtC;AAAA,UACJ,UAAU,EAAE,SAAS,CAAC,GAAG,MAAM,SAAS;AAAA,UACxC,UAAU,CAAC;AAAA,QACb;AAAA,MACF;AAEA,aAAO;AAAA,IACT,OAAO;AACL,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,WAAW,CAAC,YAAiC,gBAAgB,OAAO;AAE1E,WAAS,uBAAuB;AAChC,WAAS,YAAY;AACrB,WAAS,gBAAgB;AACzB,WAAS,aAAa,CAAC,YAAoB;AACzC,UAAM,IAAI,iBAAiB,EAAE,SAAS,WAAW,aAAa,CAAC;AAAA,EACjE;AACA,WAAS,iBAAiB;AAC1B,WAAS,qBAAqB;AAC9B,SAAO;AACT;AAEO,IAAM,UAAU,cAAc;","names":[]}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@ai-sdk/baseten",
3
- "version": "2.0.0-beta.5",
3
+ "version": "2.0.0-beta.58",
4
+ "type": "module",
4
5
  "license": "Apache-2.0",
5
6
  "sideEffects": false,
6
7
  "main": "./dist/index.js",
7
- "module": "./dist/index.mjs",
8
8
  "types": "./dist/index.d.ts",
9
9
  "files": [
10
10
  "dist/**/*",
@@ -24,19 +24,19 @@
24
24
  "./package.json": "./package.json",
25
25
  ".": {
26
26
  "types": "./dist/index.d.ts",
27
- "import": "./dist/index.mjs",
28
- "require": "./dist/index.js"
27
+ "import": "./dist/index.js",
28
+ "default": "./dist/index.js"
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
32
  "@basetenlabs/performance-client": "^0.0.10",
33
- "@ai-sdk/openai-compatible": "3.0.0-beta.5",
34
- "@ai-sdk/provider": "4.0.0-beta.2",
35
- "@ai-sdk/provider-utils": "5.0.0-beta.3"
33
+ "@ai-sdk/openai-compatible": "3.0.0-beta.58",
34
+ "@ai-sdk/provider": "4.0.0-beta.20",
35
+ "@ai-sdk/provider-utils": "5.0.0-beta.50"
36
36
  },
37
37
  "devDependencies": {
38
- "@types/node": "20.17.24",
39
- "tsup": "^8",
38
+ "@types/node": "22.19.19",
39
+ "tsup": "^8.5.1",
40
40
  "typescript": "5.8.3",
41
41
  "zod": "3.25.76",
42
42
  "@vercel/ai-tsconfig": "0.0.0"
@@ -45,15 +45,17 @@
45
45
  "zod": "^3.25.76 || ^4.1.8"
46
46
  },
47
47
  "engines": {
48
- "node": ">=18"
48
+ "node": ">=22"
49
49
  },
50
50
  "publishConfig": {
51
- "access": "public"
51
+ "access": "public",
52
+ "provenance": true
52
53
  },
53
54
  "homepage": "https://ai-sdk.dev/docs",
54
55
  "repository": {
55
56
  "type": "git",
56
- "url": "git+https://github.com/vercel/ai.git"
57
+ "url": "https://github.com/vercel/ai",
58
+ "directory": "packages/baseten"
57
59
  },
58
60
  "bugs": {
59
61
  "url": "https://github.com/vercel/ai/issues"
@@ -65,9 +67,7 @@
65
67
  "build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
66
68
  "build:watch": "pnpm clean && tsup --watch",
67
69
  "clean": "rm -rf dist docs *.tsbuildinfo",
68
- "lint": "eslint \"./**/*.ts*\"",
69
70
  "type-check": "tsc --build",
70
- "prettier-check": "prettier --check \"./**/*.ts*\"",
71
71
  "test": "pnpm test:node && pnpm test:edge",
72
72
  "test:update": "pnpm test:node -u",
73
73
  "test:watch": "vitest --config vitest.node.config.js",
@@ -1,23 +1,23 @@
1
1
  import {
2
2
  OpenAICompatibleChatLanguageModel,
3
3
  OpenAICompatibleEmbeddingModel,
4
- ProviderErrorStructure,
4
+ type ProviderErrorStructure,
5
5
  } from '@ai-sdk/openai-compatible';
6
6
  import {
7
- EmbeddingModelV4,
8
- LanguageModelV4,
9
7
  NoSuchModelError,
10
- ProviderV4,
8
+ type EmbeddingModelV4,
9
+ type LanguageModelV4,
10
+ type ProviderV4,
11
11
  } from '@ai-sdk/provider';
12
12
  import {
13
- FetchFunction,
14
13
  loadApiKey,
15
14
  withoutTrailingSlash,
16
15
  withUserAgentSuffix,
16
+ type FetchFunction,
17
17
  } from '@ai-sdk/provider-utils';
18
18
  import { z } from 'zod/v4';
19
- import { BasetenChatModelId } from './baseten-chat-options';
20
- import { BasetenEmbeddingModelId } from './baseten-embedding-options';
19
+ import type { BasetenChatModelId } from './baseten-chat-options';
20
+ import type { BasetenEmbeddingModelId } from './baseten-embedding-options';
21
21
  import { PerformanceClient } from '@basetenlabs/performance-client';
22
22
  import { VERSION } from './version';
23
23
 
package/dist/index.d.mts DELETED
@@ -1,67 +0,0 @@
1
- import { ProviderV4, LanguageModelV4, EmbeddingModelV4 } from '@ai-sdk/provider';
2
- import { FetchFunction } from '@ai-sdk/provider-utils';
3
- import { z } from 'zod/v4';
4
-
5
- type BasetenChatModelId = 'deepseek-ai/DeepSeek-R1-0528' | 'deepseek-ai/DeepSeek-V3-0324' | 'deepseek-ai/DeepSeek-V3.1' | 'moonshotai/Kimi-K2-Instruct-0905' | 'moonshotai/Kimi-K2-Thinking' | 'Qwen/Qwen3-235B-A22B-Instruct-2507' | 'Qwen/Qwen3-Coder-480B-A35B-Instruct' | 'openai/gpt-oss-120b' | 'zai-org/GLM-4.6' | 'zai-org/GLM-4.7' | (string & {});
6
-
7
- type BasetenEmbeddingModelId = string & {};
8
- declare const basetenEmbeddingModelOptions: z.ZodObject<{}, z.core.$strip>;
9
- type BasetenEmbeddingModelOptions = z.infer<typeof basetenEmbeddingModelOptions>;
10
-
11
- type BasetenErrorData = z.infer<typeof basetenErrorSchema>;
12
- declare const basetenErrorSchema: z.ZodObject<{
13
- error: z.ZodString;
14
- }, z.core.$strip>;
15
- interface BasetenProviderSettings {
16
- /**
17
- * Baseten API key. Default value is taken from the `BASETEN_API_KEY`
18
- * environment variable.
19
- */
20
- apiKey?: string;
21
- /**
22
- * Base URL for the Model APIs. Default: 'https://inference.baseten.co/v1'
23
- */
24
- baseURL?: string;
25
- /**
26
- * Model URL for custom models (chat or embeddings).
27
- * If not supplied, the default Model APIs will be used.
28
- */
29
- modelURL?: string;
30
- /**
31
- * Custom headers to include in the requests.
32
- */
33
- headers?: Record<string, string>;
34
- /**
35
- * Custom fetch implementation. You can use it as a middleware to intercept requests,
36
- * or to provide a custom fetch implementation for e.g. testing.
37
- */
38
- fetch?: FetchFunction;
39
- }
40
- interface BasetenProvider extends ProviderV4 {
41
- /**
42
- * Creates a chat model for text generation.
43
- */
44
- (modelId?: BasetenChatModelId): LanguageModelV4;
45
- /**
46
- * Creates a chat model for text generation.
47
- */
48
- chatModel(modelId?: BasetenChatModelId): LanguageModelV4;
49
- /**
50
- * Creates a language model for text generation. Alias for chatModel.
51
- */
52
- languageModel(modelId?: BasetenChatModelId): LanguageModelV4;
53
- /**
54
- * Creates a embedding model for text generation.
55
- */
56
- embeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV4;
57
- /**
58
- * @deprecated Use `embeddingModel` instead.
59
- */
60
- textEmbeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV4;
61
- }
62
- declare function createBaseten(options?: BasetenProviderSettings): BasetenProvider;
63
- declare const baseten: BasetenProvider;
64
-
65
- declare const VERSION: string;
66
-
67
- export { type BasetenChatModelId, type BasetenEmbeddingModelOptions, type BasetenErrorData, type BasetenProvider, type BasetenProviderSettings, VERSION, baseten, createBaseten };
package/dist/index.mjs DELETED
@@ -1,140 +0,0 @@
1
- // src/baseten-provider.ts
2
- import {
3
- OpenAICompatibleChatLanguageModel,
4
- OpenAICompatibleEmbeddingModel
5
- } from "@ai-sdk/openai-compatible";
6
- import {
7
- NoSuchModelError
8
- } from "@ai-sdk/provider";
9
- import {
10
- loadApiKey,
11
- withoutTrailingSlash,
12
- withUserAgentSuffix
13
- } from "@ai-sdk/provider-utils";
14
- import { z } from "zod/v4";
15
- import { PerformanceClient } from "@basetenlabs/performance-client";
16
-
17
- // src/version.ts
18
- var VERSION = true ? "2.0.0-beta.5" : "0.0.0-test";
19
-
20
- // src/baseten-provider.ts
21
- var basetenErrorSchema = z.object({
22
- error: z.string()
23
- });
24
- var basetenErrorStructure = {
25
- errorSchema: basetenErrorSchema,
26
- errorToMessage: (data) => data.error
27
- };
28
- var defaultBaseURL = "https://inference.baseten.co/v1";
29
- function createBaseten(options = {}) {
30
- var _a;
31
- const baseURL = withoutTrailingSlash((_a = options.baseURL) != null ? _a : defaultBaseURL);
32
- const getHeaders = () => withUserAgentSuffix(
33
- {
34
- Authorization: `Bearer ${loadApiKey({
35
- apiKey: options.apiKey,
36
- environmentVariableName: "BASETEN_API_KEY",
37
- description: "Baseten API key"
38
- })}`,
39
- ...options.headers
40
- },
41
- `ai-sdk/baseten/${VERSION}`
42
- );
43
- const getCommonModelConfig = (modelType, customURL) => ({
44
- provider: `baseten.${modelType}`,
45
- url: ({ path }) => {
46
- if (modelType === "embedding" && (customURL == null ? void 0 : customURL.includes("/sync")) && !(customURL == null ? void 0 : customURL.includes("/sync/v1"))) {
47
- return `${customURL}/v1${path}`;
48
- }
49
- return `${customURL || baseURL}${path}`;
50
- },
51
- headers: getHeaders,
52
- fetch: options.fetch
53
- });
54
- const createChatModel = (modelId) => {
55
- const customURL = options.modelURL;
56
- if (customURL) {
57
- const isOpenAICompatible = customURL.includes("/sync/v1");
58
- if (isOpenAICompatible) {
59
- return new OpenAICompatibleChatLanguageModel(modelId != null ? modelId : "placeholder", {
60
- ...getCommonModelConfig("chat", customURL),
61
- errorStructure: basetenErrorStructure
62
- });
63
- } else if (customURL.includes("/predict")) {
64
- throw new Error(
65
- "Not supported. You must use a /sync/v1 endpoint for chat models."
66
- );
67
- }
68
- }
69
- return new OpenAICompatibleChatLanguageModel(modelId != null ? modelId : "chat", {
70
- ...getCommonModelConfig("chat"),
71
- errorStructure: basetenErrorStructure
72
- });
73
- };
74
- const createEmbeddingModel = (modelId) => {
75
- const customURL = options.modelURL;
76
- if (!customURL) {
77
- throw new Error(
78
- "No model URL provided for embeddings. Please set modelURL option for embeddings."
79
- );
80
- }
81
- const isOpenAICompatible = customURL.includes("/sync");
82
- if (isOpenAICompatible) {
83
- const model = new OpenAICompatibleEmbeddingModel(
84
- modelId != null ? modelId : "embeddings",
85
- {
86
- ...getCommonModelConfig("embedding", customURL),
87
- errorStructure: basetenErrorStructure
88
- }
89
- );
90
- const performanceClientURL = customURL.replace("/sync/v1", "/sync");
91
- const performanceClient = new PerformanceClient(
92
- performanceClientURL,
93
- loadApiKey({
94
- apiKey: options.apiKey,
95
- environmentVariableName: "BASETEN_API_KEY",
96
- description: "Baseten API key"
97
- })
98
- );
99
- model.doEmbed = async (params) => {
100
- if (!params.values || !Array.isArray(params.values)) {
101
- throw new Error("params.values must be an array of strings");
102
- }
103
- const response = await performanceClient.embed(
104
- params.values,
105
- modelId != null ? modelId : "embeddings"
106
- // model_id is for Model APIs, we don't use it here for dedicated
107
- );
108
- const embeddings = response.data.map((item) => item.embedding);
109
- return {
110
- embeddings,
111
- usage: response.usage ? { tokens: response.usage.total_tokens } : void 0,
112
- response: { headers: {}, body: response },
113
- warnings: []
114
- };
115
- };
116
- return model;
117
- } else {
118
- throw new Error(
119
- "Not supported. You must use a /sync or /sync/v1 endpoint for embeddings."
120
- );
121
- }
122
- };
123
- const provider = (modelId) => createChatModel(modelId);
124
- provider.specificationVersion = "v4";
125
- provider.chatModel = createChatModel;
126
- provider.languageModel = createChatModel;
127
- provider.imageModel = (modelId) => {
128
- throw new NoSuchModelError({ modelId, modelType: "imageModel" });
129
- };
130
- provider.embeddingModel = createEmbeddingModel;
131
- provider.textEmbeddingModel = createEmbeddingModel;
132
- return provider;
133
- }
134
- var baseten = createBaseten();
135
- export {
136
- VERSION,
137
- baseten,
138
- createBaseten
139
- };
140
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/baseten-provider.ts","../src/version.ts"],"sourcesContent":["import {\n OpenAICompatibleChatLanguageModel,\n OpenAICompatibleEmbeddingModel,\n ProviderErrorStructure,\n} from '@ai-sdk/openai-compatible';\nimport {\n EmbeddingModelV4,\n LanguageModelV4,\n NoSuchModelError,\n ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { BasetenChatModelId } from './baseten-chat-options';\nimport { BasetenEmbeddingModelId } from './baseten-embedding-options';\nimport { PerformanceClient } from '@basetenlabs/performance-client';\nimport { VERSION } from './version';\n\nexport type BasetenErrorData = z.infer<typeof basetenErrorSchema>;\n\nconst basetenErrorSchema = z.object({\n error: z.string(),\n});\n\nconst basetenErrorStructure: ProviderErrorStructure<BasetenErrorData> = {\n errorSchema: basetenErrorSchema,\n errorToMessage: data => data.error,\n};\n\nexport interface BasetenProviderSettings {\n /**\n * Baseten API key. Default value is taken from the `BASETEN_API_KEY`\n * environment variable.\n */\n apiKey?: string;\n\n /**\n * Base URL for the Model APIs. Default: 'https://inference.baseten.co/v1'\n */\n baseURL?: string;\n\n /**\n * Model URL for custom models (chat or embeddings).\n * If not supplied, the default Model APIs will be used.\n */\n modelURL?: string;\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\nexport interface BasetenProvider extends ProviderV4 {\n /**\n * Creates a chat model for text generation.\n */\n (modelId?: BasetenChatModelId): LanguageModelV4;\n\n /**\n * Creates a chat model for text generation.\n */\n chatModel(modelId?: BasetenChatModelId): LanguageModelV4;\n\n /**\n * Creates a language model for text generation. Alias for chatModel.\n */\n languageModel(modelId?: BasetenChatModelId): LanguageModelV4;\n\n /**\n * Creates a embedding model for text generation.\n */\n embeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV4;\n}\n\n// by default, we use the Model APIs\nconst defaultBaseURL = 'https://inference.baseten.co/v1';\n\nexport function createBaseten(\n options: BasetenProviderSettings = {},\n): BasetenProvider {\n const baseURL = withoutTrailingSlash(options.baseURL ?? defaultBaseURL);\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'BASETEN_API_KEY',\n description: 'Baseten API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk/baseten/${VERSION}`,\n );\n\n interface CommonModelConfig {\n provider: string;\n url: ({ path }: { path: string }) => string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n }\n\n const getCommonModelConfig = (\n modelType: string,\n customURL?: string,\n ): CommonModelConfig => ({\n provider: `baseten.${modelType}`,\n url: ({ path }) => {\n // For embeddings with /sync URLs (but not /sync/v1), we need to add /v1\n if (\n modelType === 'embedding' &&\n customURL?.includes('/sync') &&\n !customURL?.includes('/sync/v1')\n ) {\n return `${customURL}/v1${path}`;\n }\n return `${customURL || baseURL}${path}`;\n },\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createChatModel = (modelId?: BasetenChatModelId) => {\n // Use modelURL if provided, otherwise use default Model APIs\n const customURL = options.modelURL;\n\n if (customURL) {\n // Check if this is a /sync/v1 endpoint (OpenAI-compatible) or /predict endpoint (custom)\n const isOpenAICompatible = customURL.includes('/sync/v1');\n\n if (isOpenAICompatible) {\n // For /sync/v1 endpoints, use standard OpenAI-compatible format\n return new OpenAICompatibleChatLanguageModel(modelId ?? 'placeholder', {\n ...getCommonModelConfig('chat', customURL),\n errorStructure: basetenErrorStructure,\n });\n } else if (customURL.includes('/predict')) {\n throw new Error(\n 'Not supported. You must use a /sync/v1 endpoint for chat models.',\n );\n }\n }\n\n // Use default OpenAI-compatible format for Model APIs\n return new OpenAICompatibleChatLanguageModel(modelId ?? 'chat', {\n ...getCommonModelConfig('chat'),\n errorStructure: basetenErrorStructure,\n });\n };\n\n const createEmbeddingModel = (modelId?: BasetenEmbeddingModelId) => {\n // Use modelURL if provided\n const customURL = options.modelURL;\n if (!customURL) {\n throw new Error(\n 'No model URL provided for embeddings. Please set modelURL option for embeddings.',\n );\n }\n\n // Check if this is a /sync or /sync/v1 endpoint (OpenAI-compatible)\n // We support both /sync and /sync/v1, stripping /v1 before passing to Performance Client, as Performance Client adds /v1 itself\n const isOpenAICompatible = customURL.includes('/sync');\n\n if (isOpenAICompatible) {\n // Create the model using OpenAICompatibleEmbeddingModel and override doEmbed\n const model = new OpenAICompatibleEmbeddingModel(\n modelId ?? 'embeddings',\n {\n ...getCommonModelConfig('embedding', customURL),\n errorStructure: basetenErrorStructure,\n },\n );\n\n // Strip /v1 from URL if present before passing to Performance Client to avoid double /v1\n const performanceClientURL = customURL.replace('/sync/v1', '/sync');\n\n // Initialize the B10 Performance Client once for reuse\n const performanceClient = new PerformanceClient(\n performanceClientURL,\n loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'BASETEN_API_KEY',\n description: 'Baseten API key',\n }),\n );\n\n // Override the doEmbed method to use the pre-created Performance Client\n model.doEmbed = async params => {\n if (!params.values || !Array.isArray(params.values)) {\n throw new Error('params.values must be an array of strings');\n }\n\n // Performance Client handles batching internally, so we don't need to limit in 128 here\n const response = await performanceClient.embed(\n params.values,\n modelId ?? 'embeddings', // model_id is for Model APIs, we don't use it here for dedicated\n );\n // Transform the response to match the expected format\n const embeddings = response.data.map((item: any) => item.embedding);\n\n return {\n embeddings,\n usage: response.usage\n ? { tokens: response.usage.total_tokens }\n : undefined,\n response: { headers: {}, body: response },\n warnings: [],\n };\n };\n\n return model;\n } else {\n throw new Error(\n 'Not supported. You must use a /sync or /sync/v1 endpoint for embeddings.',\n );\n }\n };\n\n const provider = (modelId?: BasetenChatModelId) => createChatModel(modelId);\n\n provider.specificationVersion = 'v4' as const;\n provider.chatModel = createChatModel;\n provider.languageModel = createChatModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n provider.embeddingModel = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n return provider;\n}\n\nexport const baseten = createBaseten();\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP;AAAA,EAGE;AAAA,OAEK;AACP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,SAAS;AAGlB,SAAS,yBAAyB;;;AClB3B,IAAM,UACX,OACI,iBACA;;;ADoBN,IAAM,qBAAqB,EAAE,OAAO;AAAA,EAClC,OAAO,EAAE,OAAO;AAClB,CAAC;AAED,IAAM,wBAAkE;AAAA,EACtE,aAAa;AAAA,EACb,gBAAgB,UAAQ,KAAK;AAC/B;AA2DA,IAAM,iBAAiB;AAEhB,SAAS,cACd,UAAmC,CAAC,GACnB;AA/FnB;AAgGE,QAAM,UAAU,sBAAqB,aAAQ,YAAR,YAAmB,cAAc;AACtE,QAAM,aAAa,MACjB;AAAA,IACE;AAAA,MACE,eAAe,UAAU,WAAW;AAAA,QAClC,QAAQ,QAAQ;AAAA,QAChB,yBAAyB;AAAA,QACzB,aAAa;AAAA,MACf,CAAC,CAAC;AAAA,MACF,GAAG,QAAQ;AAAA,IACb;AAAA,IACA,kBAAkB,OAAO;AAAA,EAC3B;AASF,QAAM,uBAAuB,CAC3B,WACA,eACuB;AAAA,IACvB,UAAU,WAAW,SAAS;AAAA,IAC9B,KAAK,CAAC,EAAE,KAAK,MAAM;AAEjB,UACE,cAAc,gBACd,uCAAW,SAAS,aACpB,EAAC,uCAAW,SAAS,cACrB;AACA,eAAO,GAAG,SAAS,MAAM,IAAI;AAAA,MAC/B;AACA,aAAO,GAAG,aAAa,OAAO,GA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