@ai-sdk/baseten 1.0.0-beta.9 → 1.0.1
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 +517 -8
- package/dist/index.d.mts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,518 @@
|
|
|
1
1
|
# @ai-sdk/baseten
|
|
2
2
|
|
|
3
|
+
## 1.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c0c8a0e: Add zai/glm-4.7 model support
|
|
8
|
+
|
|
9
|
+
## 1.0.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- dee8b05: ai SDK 6 beta
|
|
14
|
+
- 6cc9cd0: Added Baseten as a Provider for AI SDK
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 0c3b58b: fix(provider): add specificationVersion to ProviderV3
|
|
19
|
+
- ab9af9c: add moonshotai/Kimi-K2-Thinking model ID for Baseten provider
|
|
20
|
+
- 8d9e8ad: chore(provider): remove generics from EmbeddingModelV3
|
|
21
|
+
|
|
22
|
+
Before
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
model.textEmbeddingModel('my-model-id');
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
After
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
model.embeddingModel('my-model-id');
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
- 95f65c2: chore: use import \* from zod/v4
|
|
35
|
+
- 0c4822d: feat: `EmbeddingModelV3`
|
|
36
|
+
- ed329cb: feat: `Provider-V3`
|
|
37
|
+
- 1cad0ab: feat: add provider version to user-agent header
|
|
38
|
+
- 916bc46: bumped performance client to 0.0.10
|
|
39
|
+
- 8dac895: feat: `LanguageModelV3`
|
|
40
|
+
- 366f50b: chore(provider): add deprecated textEmbeddingModel and textEmbedding aliases
|
|
41
|
+
- 4616b86: chore: update zod peer depenedency version
|
|
42
|
+
- Updated dependencies
|
|
43
|
+
- @ai-sdk/openai-compatible@2.0.0
|
|
44
|
+
- @ai-sdk/provider@3.0.0
|
|
45
|
+
- @ai-sdk/provider-utils@4.0.0
|
|
46
|
+
|
|
47
|
+
## 1.0.0-beta.62
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- Updated dependencies [475189e]
|
|
52
|
+
- @ai-sdk/provider@3.0.0-beta.32
|
|
53
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.60
|
|
54
|
+
- @ai-sdk/provider-utils@4.0.0-beta.59
|
|
55
|
+
|
|
56
|
+
## 1.0.0-beta.61
|
|
57
|
+
|
|
58
|
+
### Patch Changes
|
|
59
|
+
|
|
60
|
+
- Updated dependencies [2625a04]
|
|
61
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.59
|
|
62
|
+
- @ai-sdk/provider@3.0.0-beta.31
|
|
63
|
+
- @ai-sdk/provider-utils@4.0.0-beta.58
|
|
64
|
+
|
|
65
|
+
## 1.0.0-beta.60
|
|
66
|
+
|
|
67
|
+
### Patch Changes
|
|
68
|
+
|
|
69
|
+
- Updated dependencies [cbf52cd]
|
|
70
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.58
|
|
71
|
+
- @ai-sdk/provider@3.0.0-beta.30
|
|
72
|
+
- @ai-sdk/provider-utils@4.0.0-beta.57
|
|
73
|
+
|
|
74
|
+
## 1.0.0-beta.59
|
|
75
|
+
|
|
76
|
+
### Patch Changes
|
|
77
|
+
|
|
78
|
+
- Updated dependencies [9549c9e]
|
|
79
|
+
- @ai-sdk/provider@3.0.0-beta.29
|
|
80
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.57
|
|
81
|
+
- @ai-sdk/provider-utils@4.0.0-beta.56
|
|
82
|
+
|
|
83
|
+
## 1.0.0-beta.58
|
|
84
|
+
|
|
85
|
+
### Patch Changes
|
|
86
|
+
|
|
87
|
+
- Updated dependencies [50b70d6]
|
|
88
|
+
- @ai-sdk/provider-utils@4.0.0-beta.55
|
|
89
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.56
|
|
90
|
+
|
|
91
|
+
## 1.0.0-beta.57
|
|
92
|
+
|
|
93
|
+
### Patch Changes
|
|
94
|
+
|
|
95
|
+
- Updated dependencies [9061dc0]
|
|
96
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.55
|
|
97
|
+
- @ai-sdk/provider-utils@4.0.0-beta.54
|
|
98
|
+
- @ai-sdk/provider@3.0.0-beta.28
|
|
99
|
+
|
|
100
|
+
## 1.0.0-beta.56
|
|
101
|
+
|
|
102
|
+
### Patch Changes
|
|
103
|
+
|
|
104
|
+
- 366f50b: chore(provider): add deprecated textEmbeddingModel and textEmbedding aliases
|
|
105
|
+
- Updated dependencies [366f50b]
|
|
106
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.54
|
|
107
|
+
- @ai-sdk/provider@3.0.0-beta.27
|
|
108
|
+
- @ai-sdk/provider-utils@4.0.0-beta.53
|
|
109
|
+
|
|
110
|
+
## 1.0.0-beta.55
|
|
111
|
+
|
|
112
|
+
### Patch Changes
|
|
113
|
+
|
|
114
|
+
- Updated dependencies [763d04a]
|
|
115
|
+
- @ai-sdk/provider-utils@4.0.0-beta.52
|
|
116
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.53
|
|
117
|
+
|
|
118
|
+
## 1.0.0-beta.54
|
|
119
|
+
|
|
120
|
+
### Patch Changes
|
|
121
|
+
|
|
122
|
+
- Updated dependencies [c1efac4]
|
|
123
|
+
- @ai-sdk/provider-utils@4.0.0-beta.51
|
|
124
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.52
|
|
125
|
+
|
|
126
|
+
## 1.0.0-beta.53
|
|
127
|
+
|
|
128
|
+
### Patch Changes
|
|
129
|
+
|
|
130
|
+
- Updated dependencies [32223c8]
|
|
131
|
+
- @ai-sdk/provider-utils@4.0.0-beta.50
|
|
132
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.51
|
|
133
|
+
|
|
134
|
+
## 1.0.0-beta.52
|
|
135
|
+
|
|
136
|
+
### Patch Changes
|
|
137
|
+
|
|
138
|
+
- Updated dependencies [83e5744]
|
|
139
|
+
- @ai-sdk/provider-utils@4.0.0-beta.49
|
|
140
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.50
|
|
141
|
+
|
|
142
|
+
## 1.0.0-beta.51
|
|
143
|
+
|
|
144
|
+
### Patch Changes
|
|
145
|
+
|
|
146
|
+
- Updated dependencies [960ec8f]
|
|
147
|
+
- @ai-sdk/provider-utils@4.0.0-beta.48
|
|
148
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.49
|
|
149
|
+
|
|
150
|
+
## 1.0.0-beta.50
|
|
151
|
+
|
|
152
|
+
### Patch Changes
|
|
153
|
+
|
|
154
|
+
- Updated dependencies [e9e157f]
|
|
155
|
+
- @ai-sdk/provider-utils@4.0.0-beta.47
|
|
156
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.48
|
|
157
|
+
|
|
158
|
+
## 1.0.0-beta.49
|
|
159
|
+
|
|
160
|
+
### Patch Changes
|
|
161
|
+
|
|
162
|
+
- Updated dependencies [81e29ab]
|
|
163
|
+
- @ai-sdk/provider-utils@4.0.0-beta.46
|
|
164
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.47
|
|
165
|
+
|
|
166
|
+
## 1.0.0-beta.48
|
|
167
|
+
|
|
168
|
+
### Patch Changes
|
|
169
|
+
|
|
170
|
+
- Updated dependencies [3bd2689]
|
|
171
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.46
|
|
172
|
+
- @ai-sdk/provider@3.0.0-beta.26
|
|
173
|
+
- @ai-sdk/provider-utils@4.0.0-beta.45
|
|
174
|
+
|
|
175
|
+
## 1.0.0-beta.47
|
|
176
|
+
|
|
177
|
+
### Patch Changes
|
|
178
|
+
|
|
179
|
+
- Updated dependencies [53f3368]
|
|
180
|
+
- @ai-sdk/provider@3.0.0-beta.25
|
|
181
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.45
|
|
182
|
+
- @ai-sdk/provider-utils@4.0.0-beta.44
|
|
183
|
+
|
|
184
|
+
## 1.0.0-beta.46
|
|
185
|
+
|
|
186
|
+
### Patch Changes
|
|
187
|
+
|
|
188
|
+
- Updated dependencies [dce03c4]
|
|
189
|
+
- @ai-sdk/provider-utils@4.0.0-beta.43
|
|
190
|
+
- @ai-sdk/provider@3.0.0-beta.24
|
|
191
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.44
|
|
192
|
+
|
|
193
|
+
## 1.0.0-beta.45
|
|
194
|
+
|
|
195
|
+
### Patch Changes
|
|
196
|
+
|
|
197
|
+
- Updated dependencies [3ed5519]
|
|
198
|
+
- @ai-sdk/provider-utils@4.0.0-beta.42
|
|
199
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.43
|
|
200
|
+
|
|
201
|
+
## 1.0.0-beta.44
|
|
202
|
+
|
|
203
|
+
### Patch Changes
|
|
204
|
+
|
|
205
|
+
- Updated dependencies [1bd7d32]
|
|
206
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.42
|
|
207
|
+
- @ai-sdk/provider-utils@4.0.0-beta.41
|
|
208
|
+
- @ai-sdk/provider@3.0.0-beta.23
|
|
209
|
+
|
|
210
|
+
## 1.0.0-beta.43
|
|
211
|
+
|
|
212
|
+
### Patch Changes
|
|
213
|
+
|
|
214
|
+
- Updated dependencies [544d4e8]
|
|
215
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.41
|
|
216
|
+
- @ai-sdk/provider-utils@4.0.0-beta.40
|
|
217
|
+
- @ai-sdk/provider@3.0.0-beta.22
|
|
218
|
+
|
|
219
|
+
## 1.0.0-beta.42
|
|
220
|
+
|
|
221
|
+
### Patch Changes
|
|
222
|
+
|
|
223
|
+
- Updated dependencies [954c356]
|
|
224
|
+
- @ai-sdk/provider-utils@4.0.0-beta.39
|
|
225
|
+
- @ai-sdk/provider@3.0.0-beta.21
|
|
226
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.40
|
|
227
|
+
|
|
228
|
+
## 1.0.0-beta.41
|
|
229
|
+
|
|
230
|
+
### Patch Changes
|
|
231
|
+
|
|
232
|
+
- Updated dependencies [03849b0]
|
|
233
|
+
- @ai-sdk/provider-utils@4.0.0-beta.38
|
|
234
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.39
|
|
235
|
+
|
|
236
|
+
## 1.0.0-beta.40
|
|
237
|
+
|
|
238
|
+
### Patch Changes
|
|
239
|
+
|
|
240
|
+
- Updated dependencies [457318b]
|
|
241
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.38
|
|
242
|
+
- @ai-sdk/provider@3.0.0-beta.20
|
|
243
|
+
- @ai-sdk/provider-utils@4.0.0-beta.37
|
|
244
|
+
|
|
245
|
+
## 1.0.0-beta.39
|
|
246
|
+
|
|
247
|
+
### Patch Changes
|
|
248
|
+
|
|
249
|
+
- 8d9e8ad: chore(provider): remove generics from EmbeddingModelV3
|
|
250
|
+
|
|
251
|
+
Before
|
|
252
|
+
|
|
253
|
+
```ts
|
|
254
|
+
model.textEmbeddingModel('my-model-id');
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
After
|
|
258
|
+
|
|
259
|
+
```ts
|
|
260
|
+
model.embeddingModel('my-model-id');
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
- Updated dependencies [8d9e8ad]
|
|
264
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.37
|
|
265
|
+
- @ai-sdk/provider@3.0.0-beta.19
|
|
266
|
+
- @ai-sdk/provider-utils@4.0.0-beta.36
|
|
267
|
+
|
|
268
|
+
## 1.0.0-beta.38
|
|
269
|
+
|
|
270
|
+
### Patch Changes
|
|
271
|
+
|
|
272
|
+
- Updated dependencies [10d819b]
|
|
273
|
+
- @ai-sdk/provider@3.0.0-beta.18
|
|
274
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.36
|
|
275
|
+
- @ai-sdk/provider-utils@4.0.0-beta.35
|
|
276
|
+
|
|
277
|
+
## 1.0.0-beta.37
|
|
278
|
+
|
|
279
|
+
### Patch Changes
|
|
280
|
+
|
|
281
|
+
- Updated dependencies [db913bd]
|
|
282
|
+
- @ai-sdk/provider@3.0.0-beta.17
|
|
283
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.35
|
|
284
|
+
- @ai-sdk/provider-utils@4.0.0-beta.34
|
|
285
|
+
|
|
286
|
+
## 1.0.0-beta.36
|
|
287
|
+
|
|
288
|
+
### Patch Changes
|
|
289
|
+
|
|
290
|
+
- ab9af9c: add moonshotai/Kimi-K2-Thinking model ID for Baseten provider
|
|
291
|
+
|
|
292
|
+
## 1.0.0-beta.35
|
|
293
|
+
|
|
294
|
+
### Patch Changes
|
|
295
|
+
|
|
296
|
+
- Updated dependencies [b681d7d]
|
|
297
|
+
- @ai-sdk/provider@3.0.0-beta.16
|
|
298
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.34
|
|
299
|
+
- @ai-sdk/provider-utils@4.0.0-beta.33
|
|
300
|
+
|
|
301
|
+
## 1.0.0-beta.34
|
|
302
|
+
|
|
303
|
+
### Patch Changes
|
|
304
|
+
|
|
305
|
+
- Updated dependencies [32d8dbb]
|
|
306
|
+
- @ai-sdk/provider-utils@4.0.0-beta.32
|
|
307
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.33
|
|
308
|
+
|
|
309
|
+
## 1.0.0-beta.33
|
|
310
|
+
|
|
311
|
+
### Patch Changes
|
|
312
|
+
|
|
313
|
+
- Updated dependencies [bb36798]
|
|
314
|
+
- @ai-sdk/provider@3.0.0-beta.15
|
|
315
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.32
|
|
316
|
+
- @ai-sdk/provider-utils@4.0.0-beta.31
|
|
317
|
+
|
|
318
|
+
## 1.0.0-beta.32
|
|
319
|
+
|
|
320
|
+
### Patch Changes
|
|
321
|
+
|
|
322
|
+
- Updated dependencies [4f16c37]
|
|
323
|
+
- @ai-sdk/provider-utils@4.0.0-beta.30
|
|
324
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.31
|
|
325
|
+
|
|
326
|
+
## 1.0.0-beta.31
|
|
327
|
+
|
|
328
|
+
### Patch Changes
|
|
329
|
+
|
|
330
|
+
- Updated dependencies [af3780b]
|
|
331
|
+
- @ai-sdk/provider@3.0.0-beta.14
|
|
332
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.30
|
|
333
|
+
- @ai-sdk/provider-utils@4.0.0-beta.29
|
|
334
|
+
|
|
335
|
+
## 1.0.0-beta.30
|
|
336
|
+
|
|
337
|
+
### Patch Changes
|
|
338
|
+
|
|
339
|
+
- Updated dependencies [016b111]
|
|
340
|
+
- @ai-sdk/provider-utils@4.0.0-beta.28
|
|
341
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.29
|
|
342
|
+
|
|
343
|
+
## 1.0.0-beta.29
|
|
344
|
+
|
|
345
|
+
### Patch Changes
|
|
346
|
+
|
|
347
|
+
- Updated dependencies [37c58a0]
|
|
348
|
+
- @ai-sdk/provider@3.0.0-beta.13
|
|
349
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.28
|
|
350
|
+
- @ai-sdk/provider-utils@4.0.0-beta.27
|
|
351
|
+
|
|
352
|
+
## 1.0.0-beta.28
|
|
353
|
+
|
|
354
|
+
### Patch Changes
|
|
355
|
+
|
|
356
|
+
- Updated dependencies [d1bdadb]
|
|
357
|
+
- @ai-sdk/provider@3.0.0-beta.12
|
|
358
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.27
|
|
359
|
+
- @ai-sdk/provider-utils@4.0.0-beta.26
|
|
360
|
+
|
|
361
|
+
## 1.0.0-beta.27
|
|
362
|
+
|
|
363
|
+
### Patch Changes
|
|
364
|
+
|
|
365
|
+
- Updated dependencies [4c44a5b]
|
|
366
|
+
- @ai-sdk/provider@3.0.0-beta.11
|
|
367
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.26
|
|
368
|
+
- @ai-sdk/provider-utils@4.0.0-beta.25
|
|
369
|
+
|
|
370
|
+
## 1.0.0-beta.26
|
|
371
|
+
|
|
372
|
+
### Patch Changes
|
|
373
|
+
|
|
374
|
+
- 0c3b58b: fix(provider): add specificationVersion to ProviderV3
|
|
375
|
+
- Updated dependencies [0c3b58b]
|
|
376
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.25
|
|
377
|
+
- @ai-sdk/provider@3.0.0-beta.10
|
|
378
|
+
- @ai-sdk/provider-utils@4.0.0-beta.24
|
|
379
|
+
|
|
380
|
+
## 1.0.0-beta.25
|
|
381
|
+
|
|
382
|
+
### Patch Changes
|
|
383
|
+
|
|
384
|
+
- Updated dependencies [a755db5]
|
|
385
|
+
- @ai-sdk/provider@3.0.0-beta.9
|
|
386
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.24
|
|
387
|
+
- @ai-sdk/provider-utils@4.0.0-beta.23
|
|
388
|
+
|
|
389
|
+
## 1.0.0-beta.24
|
|
390
|
+
|
|
391
|
+
### Patch Changes
|
|
392
|
+
|
|
393
|
+
- Updated dependencies [58920e0]
|
|
394
|
+
- @ai-sdk/provider-utils@4.0.0-beta.22
|
|
395
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.23
|
|
396
|
+
|
|
397
|
+
## 1.0.0-beta.23
|
|
398
|
+
|
|
399
|
+
### Patch Changes
|
|
400
|
+
|
|
401
|
+
- Updated dependencies [293a6b7]
|
|
402
|
+
- @ai-sdk/provider-utils@4.0.0-beta.21
|
|
403
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.22
|
|
404
|
+
|
|
405
|
+
## 1.0.0-beta.22
|
|
406
|
+
|
|
407
|
+
### Patch Changes
|
|
408
|
+
|
|
409
|
+
- Updated dependencies [fca786b]
|
|
410
|
+
- @ai-sdk/provider-utils@4.0.0-beta.20
|
|
411
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.21
|
|
412
|
+
|
|
413
|
+
## 1.0.0-beta.21
|
|
414
|
+
|
|
415
|
+
### Patch Changes
|
|
416
|
+
|
|
417
|
+
- Updated dependencies [3794514]
|
|
418
|
+
- @ai-sdk/provider-utils@4.0.0-beta.19
|
|
419
|
+
- @ai-sdk/provider@3.0.0-beta.8
|
|
420
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.20
|
|
421
|
+
|
|
422
|
+
## 1.0.0-beta.20
|
|
423
|
+
|
|
424
|
+
### Patch Changes
|
|
425
|
+
|
|
426
|
+
- Updated dependencies [81d4308]
|
|
427
|
+
- @ai-sdk/provider@3.0.0-beta.7
|
|
428
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.19
|
|
429
|
+
- @ai-sdk/provider-utils@4.0.0-beta.18
|
|
430
|
+
|
|
431
|
+
## 1.0.0-beta.19
|
|
432
|
+
|
|
433
|
+
### Patch Changes
|
|
434
|
+
|
|
435
|
+
- Updated dependencies [703459a]
|
|
436
|
+
- @ai-sdk/provider-utils@4.0.0-beta.17
|
|
437
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.18
|
|
438
|
+
|
|
439
|
+
## 1.0.0-beta.18
|
|
440
|
+
|
|
441
|
+
### Patch Changes
|
|
442
|
+
|
|
443
|
+
- Updated dependencies [b689220]
|
|
444
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.17
|
|
445
|
+
|
|
446
|
+
## 1.0.0-beta.17
|
|
447
|
+
|
|
448
|
+
### Patch Changes
|
|
449
|
+
|
|
450
|
+
- Updated dependencies [6306603]
|
|
451
|
+
- @ai-sdk/provider-utils@4.0.0-beta.16
|
|
452
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.16
|
|
453
|
+
|
|
454
|
+
## 1.0.0-beta.16
|
|
455
|
+
|
|
456
|
+
### Patch Changes
|
|
457
|
+
|
|
458
|
+
- Updated dependencies [f0b2157]
|
|
459
|
+
- @ai-sdk/provider-utils@4.0.0-beta.15
|
|
460
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.15
|
|
461
|
+
|
|
462
|
+
## 1.0.0-beta.15
|
|
463
|
+
|
|
464
|
+
### Patch Changes
|
|
465
|
+
|
|
466
|
+
- Updated dependencies [3b1d015]
|
|
467
|
+
- @ai-sdk/provider-utils@4.0.0-beta.14
|
|
468
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.14
|
|
469
|
+
|
|
470
|
+
## 1.0.0-beta.14
|
|
471
|
+
|
|
472
|
+
### Patch Changes
|
|
473
|
+
|
|
474
|
+
- Updated dependencies [d116b4b]
|
|
475
|
+
- @ai-sdk/provider-utils@4.0.0-beta.13
|
|
476
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.13
|
|
477
|
+
|
|
478
|
+
## 1.0.0-beta.13
|
|
479
|
+
|
|
480
|
+
### Patch Changes
|
|
481
|
+
|
|
482
|
+
- Updated dependencies [7e32fea]
|
|
483
|
+
- @ai-sdk/provider-utils@4.0.0-beta.12
|
|
484
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.12
|
|
485
|
+
|
|
486
|
+
## 1.0.0-beta.12
|
|
487
|
+
|
|
488
|
+
### Patch Changes
|
|
489
|
+
|
|
490
|
+
- 95f65c2: chore: use import \* from zod/v4
|
|
491
|
+
- Updated dependencies
|
|
492
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.11
|
|
493
|
+
- @ai-sdk/provider-utils@4.0.0-beta.11
|
|
494
|
+
|
|
495
|
+
## 1.0.0-beta.11
|
|
496
|
+
|
|
497
|
+
### Major Changes
|
|
498
|
+
|
|
499
|
+
- dee8b05: ai SDK 6 beta
|
|
500
|
+
|
|
501
|
+
### Patch Changes
|
|
502
|
+
|
|
503
|
+
- Updated dependencies [dee8b05]
|
|
504
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.10
|
|
505
|
+
- @ai-sdk/provider@3.0.0-beta.6
|
|
506
|
+
- @ai-sdk/provider-utils@4.0.0-beta.10
|
|
507
|
+
|
|
508
|
+
## 1.0.0-beta.10
|
|
509
|
+
|
|
510
|
+
### Patch Changes
|
|
511
|
+
|
|
512
|
+
- Updated dependencies [521c537]
|
|
513
|
+
- @ai-sdk/provider-utils@3.1.0-beta.9
|
|
514
|
+
- @ai-sdk/openai-compatible@1.1.0-beta.9
|
|
515
|
+
|
|
3
516
|
## 1.0.0-beta.9
|
|
4
517
|
|
|
5
518
|
### Patch Changes
|
|
@@ -12,8 +525,7 @@
|
|
|
12
525
|
|
|
13
526
|
### Patch Changes
|
|
14
527
|
|
|
15
|
-
- Updated dependencies
|
|
16
|
-
- Updated dependencies [e8109d3]
|
|
528
|
+
- Updated dependencies
|
|
17
529
|
- @ai-sdk/provider@2.1.0-beta.5
|
|
18
530
|
- @ai-sdk/openai-compatible@1.1.0-beta.7
|
|
19
531
|
- @ai-sdk/provider-utils@3.1.0-beta.7
|
|
@@ -22,8 +534,7 @@
|
|
|
22
534
|
|
|
23
535
|
### Patch Changes
|
|
24
536
|
|
|
25
|
-
- Updated dependencies
|
|
26
|
-
- Updated dependencies [2b0caef]
|
|
537
|
+
- Updated dependencies
|
|
27
538
|
- @ai-sdk/openai-compatible@1.1.0-beta.6
|
|
28
539
|
- @ai-sdk/provider-utils@3.1.0-beta.6
|
|
29
540
|
- @ai-sdk/provider@2.1.0-beta.4
|
|
@@ -39,8 +550,7 @@
|
|
|
39
550
|
### Patch Changes
|
|
40
551
|
|
|
41
552
|
- 8dac895: feat: `LanguageModelV3`
|
|
42
|
-
- Updated dependencies
|
|
43
|
-
- Updated dependencies [10c1322]
|
|
553
|
+
- Updated dependencies
|
|
44
554
|
- @ai-sdk/openai-compatible@1.1.0-beta.5
|
|
45
555
|
- @ai-sdk/provider-utils@3.1.0-beta.5
|
|
46
556
|
- @ai-sdk/provider@2.1.0-beta.3
|
|
@@ -59,8 +569,7 @@
|
|
|
59
569
|
### Patch Changes
|
|
60
570
|
|
|
61
571
|
- ed329cb: feat: `Provider-V3`
|
|
62
|
-
- Updated dependencies
|
|
63
|
-
- Updated dependencies [522f6b8]
|
|
572
|
+
- Updated dependencies
|
|
64
573
|
- @ai-sdk/openai-compatible@1.1.0-beta.3
|
|
65
574
|
- @ai-sdk/provider@2.1.0-beta.2
|
|
66
575
|
- @ai-sdk/provider-utils@3.1.0-beta.3
|
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { ProviderV3, LanguageModelV3, EmbeddingModelV3 } from '@ai-sdk/provider'
|
|
|
2
2
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
3
|
import { z } from 'zod/v4';
|
|
4
4
|
|
|
5
|
-
type BasetenChatModelId = 'deepseek-ai/DeepSeek-R1-0528' | 'deepseek-ai/DeepSeek-V3-0324' | '
|
|
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
6
|
|
|
7
7
|
type BasetenEmbeddingModelId = string & {};
|
|
8
8
|
|
|
@@ -49,9 +49,13 @@ interface BasetenProvider extends ProviderV3 {
|
|
|
49
49
|
*/
|
|
50
50
|
languageModel(modelId?: BasetenChatModelId): LanguageModelV3;
|
|
51
51
|
/**
|
|
52
|
-
Creates a
|
|
52
|
+
Creates a embedding model for text generation.
|
|
53
53
|
*/
|
|
54
|
-
|
|
54
|
+
embeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV3;
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated Use `embeddingModel` instead.
|
|
57
|
+
*/
|
|
58
|
+
textEmbeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV3;
|
|
55
59
|
}
|
|
56
60
|
declare function createBaseten(options?: BasetenProviderSettings): BasetenProvider;
|
|
57
61
|
declare const baseten: BasetenProvider;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ProviderV3, LanguageModelV3, EmbeddingModelV3 } from '@ai-sdk/provider'
|
|
|
2
2
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
3
|
import { z } from 'zod/v4';
|
|
4
4
|
|
|
5
|
-
type BasetenChatModelId = 'deepseek-ai/DeepSeek-R1-0528' | 'deepseek-ai/DeepSeek-V3-0324' | '
|
|
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
6
|
|
|
7
7
|
type BasetenEmbeddingModelId = string & {};
|
|
8
8
|
|
|
@@ -49,9 +49,13 @@ interface BasetenProvider extends ProviderV3 {
|
|
|
49
49
|
*/
|
|
50
50
|
languageModel(modelId?: BasetenChatModelId): LanguageModelV3;
|
|
51
51
|
/**
|
|
52
|
-
Creates a
|
|
52
|
+
Creates a embedding model for text generation.
|
|
53
53
|
*/
|
|
54
|
-
|
|
54
|
+
embeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV3;
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated Use `embeddingModel` instead.
|
|
57
|
+
*/
|
|
58
|
+
textEmbeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV3;
|
|
55
59
|
}
|
|
56
60
|
declare function createBaseten(options?: BasetenProviderSettings): BasetenProvider;
|
|
57
61
|
declare const baseten: BasetenProvider;
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,7 @@ var import_v4 = require("zod/v4");
|
|
|
34
34
|
var import_performance_client = require("@basetenlabs/performance-client");
|
|
35
35
|
|
|
36
36
|
// src/version.ts
|
|
37
|
-
var VERSION = true ? "1.0.
|
|
37
|
+
var VERSION = true ? "1.0.1" : "0.0.0-test";
|
|
38
38
|
|
|
39
39
|
// src/baseten-provider.ts
|
|
40
40
|
var basetenErrorSchema = import_v4.z.object({
|
|
@@ -90,7 +90,7 @@ function createBaseten(options = {}) {
|
|
|
90
90
|
errorStructure: basetenErrorStructure
|
|
91
91
|
});
|
|
92
92
|
};
|
|
93
|
-
const
|
|
93
|
+
const createEmbeddingModel = (modelId) => {
|
|
94
94
|
const customURL = options.modelURL;
|
|
95
95
|
if (!customURL) {
|
|
96
96
|
throw new Error(
|
|
@@ -128,7 +128,8 @@ function createBaseten(options = {}) {
|
|
|
128
128
|
return {
|
|
129
129
|
embeddings,
|
|
130
130
|
usage: response.usage ? { tokens: response.usage.total_tokens } : void 0,
|
|
131
|
-
response: { headers: {}, body: response }
|
|
131
|
+
response: { headers: {}, body: response },
|
|
132
|
+
warnings: []
|
|
132
133
|
};
|
|
133
134
|
};
|
|
134
135
|
return model;
|
|
@@ -139,12 +140,14 @@ function createBaseten(options = {}) {
|
|
|
139
140
|
}
|
|
140
141
|
};
|
|
141
142
|
const provider = (modelId) => createChatModel(modelId);
|
|
143
|
+
provider.specificationVersion = "v3";
|
|
142
144
|
provider.chatModel = createChatModel;
|
|
143
145
|
provider.languageModel = createChatModel;
|
|
144
146
|
provider.imageModel = (modelId) => {
|
|
145
147
|
throw new import_provider.NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
146
148
|
};
|
|
147
|
-
provider.
|
|
149
|
+
provider.embeddingModel = createEmbeddingModel;
|
|
150
|
+
provider.textEmbeddingModel = createEmbeddingModel;
|
|
148
151
|
return provider;
|
|
149
152
|
}
|
|
150
153
|
var baseten = createBaseten();
|
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 { VERSION } from './version';\n","import {\n OpenAICompatibleChatLanguageModel,\n OpenAICompatibleEmbeddingModel,\n ProviderErrorStructure,\n} from '@ai-sdk/openai-compatible';\nimport {\n EmbeddingModelV3,\n LanguageModelV3,\n NoSuchModelError,\n ProviderV3,\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 ProviderV3 {\n /**\nCreates a chat model for text generation. \n*/\n (modelId?: BasetenChatModelId): LanguageModelV3;\n\n /**\nCreates a chat model for text generation. \n*/\n chatModel(modelId?: BasetenChatModelId): LanguageModelV3;\n\n /**\nCreates a language model for text generation. Alias for chatModel.\n*/\n languageModel(modelId?: BasetenChatModelId): LanguageModelV3;\n\n /**\nCreates a text embedding model for text generation.\n*/\n textEmbeddingModel(\n modelId?: BasetenEmbeddingModelId,\n ): EmbeddingModelV3<string>;\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 createTextEmbeddingModel = (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: embeddings,\n usage: response.usage\n ? { tokens: response.usage.total_tokens }\n : undefined,\n response: { headers: {}, body: response },\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 provider.chatModel = createChatModel;\n provider.languageModel = createChatModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n provider.textEmbeddingModel = createTextEmbeddingModel;\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;AAwDA,IAAM,iBAAiB;AAEhB,SAAS,cACd,UAAmC,CAAC,GACnB;AA5FnB;AA6FE,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,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,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M,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,QAC1C;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;AAC1E,WAAS,YAAY;AACrB,WAAS,gBAAgB;AACzB,WAAS,aAAa,CAAC,YAAoB;AACzC,UAAM,IAAI,iCAAiB,EAAE,SAAS,WAAW,aAAa,CAAC;AAAA,EACjE;AACA,WAAS,qBAAqB;AAC9B,SAAO;AACT;AAEO,IAAM,UAAU,cAAc;","names":[]}
|
|
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 { VERSION } from './version';\n","import {\n OpenAICompatibleChatLanguageModel,\n OpenAICompatibleEmbeddingModel,\n ProviderErrorStructure,\n} from '@ai-sdk/openai-compatible';\nimport {\n EmbeddingModelV3,\n LanguageModelV3,\n NoSuchModelError,\n ProviderV3,\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 ProviderV3 {\n /**\nCreates a chat model for text generation.\n*/\n (modelId?: BasetenChatModelId): LanguageModelV3;\n\n /**\nCreates a chat model for text generation.\n*/\n chatModel(modelId?: BasetenChatModelId): LanguageModelV3;\n\n /**\nCreates a language model for text generation. Alias for chatModel.\n*/\n languageModel(modelId?: BasetenChatModelId): LanguageModelV3;\n\n /**\nCreates a embedding model for text generation.\n*/\n embeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV3;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV3;\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 = 'v3' 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,UACA;;;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,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;AAExD,UAAM,YAAY,QAAQ;AAE1B,QAAI,WAAW;AAEb,YAAM,qBAAqB,UAAU,SAAS,UAAU;AAExD,UAA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,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":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -15,7 +15,7 @@ import { z } from "zod/v4";
|
|
|
15
15
|
import { PerformanceClient } from "@basetenlabs/performance-client";
|
|
16
16
|
|
|
17
17
|
// src/version.ts
|
|
18
|
-
var VERSION = true ? "1.0.
|
|
18
|
+
var VERSION = true ? "1.0.1" : "0.0.0-test";
|
|
19
19
|
|
|
20
20
|
// src/baseten-provider.ts
|
|
21
21
|
var basetenErrorSchema = z.object({
|
|
@@ -71,7 +71,7 @@ function createBaseten(options = {}) {
|
|
|
71
71
|
errorStructure: basetenErrorStructure
|
|
72
72
|
});
|
|
73
73
|
};
|
|
74
|
-
const
|
|
74
|
+
const createEmbeddingModel = (modelId) => {
|
|
75
75
|
const customURL = options.modelURL;
|
|
76
76
|
if (!customURL) {
|
|
77
77
|
throw new Error(
|
|
@@ -109,7 +109,8 @@ function createBaseten(options = {}) {
|
|
|
109
109
|
return {
|
|
110
110
|
embeddings,
|
|
111
111
|
usage: response.usage ? { tokens: response.usage.total_tokens } : void 0,
|
|
112
|
-
response: { headers: {}, body: response }
|
|
112
|
+
response: { headers: {}, body: response },
|
|
113
|
+
warnings: []
|
|
113
114
|
};
|
|
114
115
|
};
|
|
115
116
|
return model;
|
|
@@ -120,12 +121,14 @@ function createBaseten(options = {}) {
|
|
|
120
121
|
}
|
|
121
122
|
};
|
|
122
123
|
const provider = (modelId) => createChatModel(modelId);
|
|
124
|
+
provider.specificationVersion = "v3";
|
|
123
125
|
provider.chatModel = createChatModel;
|
|
124
126
|
provider.languageModel = createChatModel;
|
|
125
127
|
provider.imageModel = (modelId) => {
|
|
126
128
|
throw new NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
127
129
|
};
|
|
128
|
-
provider.
|
|
130
|
+
provider.embeddingModel = createEmbeddingModel;
|
|
131
|
+
provider.textEmbeddingModel = createEmbeddingModel;
|
|
129
132
|
return provider;
|
|
130
133
|
}
|
|
131
134
|
var baseten = createBaseten();
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 EmbeddingModelV3,\n LanguageModelV3,\n NoSuchModelError,\n ProviderV3,\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 ProviderV3 {\n /**\nCreates a chat model for text generation. \n*/\n (modelId?: BasetenChatModelId): LanguageModelV3;\n\n /**\nCreates a chat model for text generation. \n*/\n chatModel(modelId?: BasetenChatModelId): LanguageModelV3;\n\n /**\nCreates a language model for text generation. Alias for chatModel.\n*/\n languageModel(modelId?: BasetenChatModelId): LanguageModelV3;\n\n /**\nCreates a text embedding model for text generation.\n*/\n textEmbeddingModel(\n modelId?: BasetenEmbeddingModelId,\n ): EmbeddingModelV3<string>;\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 createTextEmbeddingModel = (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: embeddings,\n usage: response.usage\n ? { tokens: response.usage.total_tokens }\n : undefined,\n response: { headers: {}, body: response },\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 provider.chatModel = createChatModel;\n provider.languageModel = createChatModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n provider.textEmbeddingModel = createTextEmbeddingModel;\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;AAwDA,IAAM,iBAAiB;AAEhB,SAAS,cACd,UAAmC,CAAC,GACnB;AA5FnB;AA6FE,QAAM,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"sourcesContent":["import {\n OpenAICompatibleChatLanguageModel,\n OpenAICompatibleEmbeddingModel,\n ProviderErrorStructure,\n} from '@ai-sdk/openai-compatible';\nimport {\n EmbeddingModelV3,\n LanguageModelV3,\n NoSuchModelError,\n ProviderV3,\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 ProviderV3 {\n /**\nCreates a chat model for text generation.\n*/\n (modelId?: BasetenChatModelId): LanguageModelV3;\n\n /**\nCreates a chat model for text generation.\n*/\n chatModel(modelId?: BasetenChatModelId): LanguageModelV3;\n\n /**\nCreates a language model for text generation. Alias for chatModel.\n*/\n languageModel(modelId?: BasetenChatModelId): LanguageModelV3;\n\n /**\nCreates a embedding model for text generation.\n*/\n embeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV3;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV3;\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 = 'v3' 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,UACA;;;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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M,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,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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/baseten",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist/**/*",
|
|
11
|
-
"CHANGELOG.md"
|
|
11
|
+
"CHANGELOG.md",
|
|
12
|
+
"README.md"
|
|
12
13
|
],
|
|
13
14
|
"exports": {
|
|
14
15
|
"./package.json": "./package.json",
|
|
@@ -20,9 +21,9 @@
|
|
|
20
21
|
},
|
|
21
22
|
"dependencies": {
|
|
22
23
|
"@basetenlabs/performance-client": "^0.0.10",
|
|
23
|
-
"@ai-sdk/openai-compatible": "
|
|
24
|
-
"@ai-sdk/provider": "
|
|
25
|
-
"@ai-sdk/provider-utils": "
|
|
24
|
+
"@ai-sdk/openai-compatible": "2.0.0",
|
|
25
|
+
"@ai-sdk/provider": "3.0.0",
|
|
26
|
+
"@ai-sdk/provider-utils": "4.0.0"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"@types/node": "20.17.24",
|