@ai-sdk/deepinfra 1.0.0-canary.9 → 1.0.0

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,564 @@
1
1
  # @ai-sdk/deepinfra
2
2
 
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - d5f588f: AI SDK 5
8
+ - 516be5b: ### Move Image Model Settings into generate options
9
+
10
+ Image Models no longer have settings. Instead, `maxImagesPerCall` can be passed directly to `generateImage()`. All other image settings can be passed to `providerOptions[provider]`.
11
+
12
+ Before
13
+
14
+ ```js
15
+ await generateImage({
16
+ model: luma.image('photon-flash-1', {
17
+ maxImagesPerCall: 5,
18
+ pollIntervalMillis: 500,
19
+ }),
20
+ prompt,
21
+ n: 10,
22
+ });
23
+ ```
24
+
25
+ After
26
+
27
+ ```js
28
+ await generateImage({
29
+ model: luma.image('photon-flash-1'),
30
+ prompt,
31
+ n: 10,
32
+ maxImagesPerCall: 5,
33
+ providerOptions: {
34
+ luma: { pollIntervalMillis: 5 },
35
+ },
36
+ });
37
+ ```
38
+
39
+ Pull Request: https://github.com/vercel/ai/pull/6180
40
+
41
+ ### Patch Changes
42
+
43
+ - 7677477: feat (providers/deepinfra): add llama 4 models
44
+ - fa49207: feat(providers/openai-compatible): convert to providerOptions
45
+ - e2aceaf: feat: add raw chunk support
46
+ - eb173f1: chore (providers): remove model shorthand deprecation warnings
47
+ - 26735b5: chore(embedding-model): add v2 interface
48
+ - d9209ca: fix (image-model): `specificationVersion: v1` -> `v2`
49
+ - 9301f86: refactor (image-model): rename `ImageModelV1` to `ImageModelV2`
50
+ - 205077b: fix: improve Zod compatibility
51
+ - Updated dependencies [a571d6e]
52
+ - Updated dependencies [742b7be]
53
+ - Updated dependencies [e7fcc86]
54
+ - Updated dependencies [7cddb72]
55
+ - Updated dependencies [ccce59b]
56
+ - Updated dependencies [e2b9e4b]
57
+ - Updated dependencies [95857aa]
58
+ - Updated dependencies [45c1ea2]
59
+ - Updated dependencies [6f6bb89]
60
+ - Updated dependencies [060370c]
61
+ - Updated dependencies [dc714f3]
62
+ - Updated dependencies [b5da06a]
63
+ - Updated dependencies [d1a1aa1]
64
+ - Updated dependencies [63f9e9b]
65
+ - Updated dependencies [5d142ab]
66
+ - Updated dependencies [d5f588f]
67
+ - Updated dependencies [e025824]
68
+ - Updated dependencies [0571b98]
69
+ - Updated dependencies [6db02c9]
70
+ - Updated dependencies [b6b43c7]
71
+ - Updated dependencies [4fef487]
72
+ - Updated dependencies [48d257a]
73
+ - Updated dependencies [0c0c0b3]
74
+ - Updated dependencies [0d2c085]
75
+ - Updated dependencies [fa49207]
76
+ - Updated dependencies [40acf9b]
77
+ - Updated dependencies [cf8280e]
78
+ - Updated dependencies [9222aeb]
79
+ - Updated dependencies [b9a6121]
80
+ - Updated dependencies [e2aceaf]
81
+ - Updated dependencies [411e483]
82
+ - Updated dependencies [8ba77a7]
83
+ - Updated dependencies [db72adc]
84
+ - Updated dependencies [7b3ae3f]
85
+ - Updated dependencies [a166433]
86
+ - Updated dependencies [26735b5]
87
+ - Updated dependencies [443d8ec]
88
+ - Updated dependencies [42e32b0]
89
+ - Updated dependencies [a8c8bd5]
90
+ - Updated dependencies [abf9a79]
91
+ - Updated dependencies [14c9410]
92
+ - Updated dependencies [e86be6f]
93
+ - Updated dependencies [9bf7291]
94
+ - Updated dependencies [2e13791]
95
+ - Updated dependencies [7b069ed]
96
+ - Updated dependencies [9f95b35]
97
+ - Updated dependencies [66962ed]
98
+ - Updated dependencies [0d06df6]
99
+ - Updated dependencies [472524a]
100
+ - Updated dependencies [dd3ff01]
101
+ - Updated dependencies [d9209ca]
102
+ - Updated dependencies [d9c98f4]
103
+ - Updated dependencies [05d2819]
104
+ - Updated dependencies [9301f86]
105
+ - Updated dependencies [0a87932]
106
+ - Updated dependencies [737f1e2]
107
+ - Updated dependencies [c4a2fec]
108
+ - Updated dependencies [957b739]
109
+ - Updated dependencies [79457bd]
110
+ - Updated dependencies [a3f768e]
111
+ - Updated dependencies [7435eb5]
112
+ - Updated dependencies [8aa9e20]
113
+ - Updated dependencies [4617fab]
114
+ - Updated dependencies [516be5b]
115
+ - Updated dependencies [ac34802]
116
+ - Updated dependencies [0054544]
117
+ - Updated dependencies [cb68df0]
118
+ - Updated dependencies [ad80501]
119
+ - Updated dependencies [68ecf2f]
120
+ - Updated dependencies [9e9c809]
121
+ - Updated dependencies [32831c6]
122
+ - Updated dependencies [6dc848c]
123
+ - Updated dependencies [6b98118]
124
+ - Updated dependencies [d0f9495]
125
+ - Updated dependencies [63d791d]
126
+ - Updated dependencies [87b828f]
127
+ - Updated dependencies [3f2f00c]
128
+ - Updated dependencies [bfdca8d]
129
+ - Updated dependencies [0ff02bb]
130
+ - Updated dependencies [7979f7f]
131
+ - Updated dependencies [39a4fab]
132
+ - Updated dependencies [44f4aba]
133
+ - Updated dependencies [9bd5ab5]
134
+ - Updated dependencies [57edfcb]
135
+ - Updated dependencies [faf8446]
136
+ - Updated dependencies [7ea4132]
137
+ - Updated dependencies [d1a034f]
138
+ - Updated dependencies [5c56081]
139
+ - Updated dependencies [fd65bc6]
140
+ - Updated dependencies [023ba40]
141
+ - Updated dependencies [ea7a7c9]
142
+ - Updated dependencies [1b101e1]
143
+ - Updated dependencies [26535e0]
144
+ - Updated dependencies [e030615]
145
+ - Updated dependencies [5e57fae]
146
+ - Updated dependencies [393138b]
147
+ - Updated dependencies [c57e248]
148
+ - Updated dependencies [88a8ee5]
149
+ - Updated dependencies [41fa418]
150
+ - Updated dependencies [205077b]
151
+ - Updated dependencies [71f938d]
152
+ - Updated dependencies [3795467]
153
+ - Updated dependencies [28a5ed5]
154
+ - Updated dependencies [7182d14]
155
+ - Updated dependencies [c1e6647]
156
+ - Updated dependencies [1766ede]
157
+ - Updated dependencies [811dff3]
158
+ - Updated dependencies [f10304b]
159
+ - Updated dependencies [dd5fd43]
160
+ - Updated dependencies [33f4a6a]
161
+ - Updated dependencies [383cbfa]
162
+ - Updated dependencies [27deb4d]
163
+ - Updated dependencies [c4df419]
164
+ - Updated dependencies [281bb1c]
165
+ - @ai-sdk/provider-utils@3.0.0
166
+ - @ai-sdk/provider@2.0.0
167
+ - @ai-sdk/openai-compatible@1.0.0
168
+
169
+ ## 1.0.0-beta.13
170
+
171
+ ### Patch Changes
172
+
173
+ - Updated dependencies [88a8ee5]
174
+ - @ai-sdk/provider-utils@3.0.0-beta.10
175
+ - @ai-sdk/openai-compatible@1.0.0-beta.13
176
+
177
+ ## 1.0.0-beta.12
178
+
179
+ ### Patch Changes
180
+
181
+ - Updated dependencies [27deb4d]
182
+ - @ai-sdk/provider@2.0.0-beta.2
183
+ - @ai-sdk/openai-compatible@1.0.0-beta.12
184
+ - @ai-sdk/provider-utils@3.0.0-beta.9
185
+
186
+ ## 1.0.0-beta.11
187
+
188
+ ### Patch Changes
189
+
190
+ - eb173f1: chore (providers): remove model shorthand deprecation warnings
191
+ - Updated dependencies [dd5fd43]
192
+ - @ai-sdk/provider-utils@3.0.0-beta.8
193
+ - @ai-sdk/openai-compatible@1.0.0-beta.11
194
+
195
+ ## 1.0.0-beta.10
196
+
197
+ ### Patch Changes
198
+
199
+ - Updated dependencies [e7fcc86]
200
+ - @ai-sdk/provider-utils@3.0.0-beta.7
201
+ - @ai-sdk/openai-compatible@1.0.0-beta.10
202
+
203
+ ## 1.0.0-beta.9
204
+
205
+ ### Patch Changes
206
+
207
+ - Updated dependencies [737f1e2]
208
+ - Updated dependencies [ac34802]
209
+ - @ai-sdk/openai-compatible@1.0.0-beta.9
210
+ - @ai-sdk/provider-utils@3.0.0-beta.6
211
+
212
+ ## 1.0.0-beta.8
213
+
214
+ ### Patch Changes
215
+
216
+ - Updated dependencies [57edfcb]
217
+ - Updated dependencies [383cbfa]
218
+ - @ai-sdk/provider-utils@3.0.0-beta.5
219
+ - @ai-sdk/openai-compatible@1.0.0-beta.8
220
+
221
+ ## 1.0.0-beta.7
222
+
223
+ ### Patch Changes
224
+
225
+ - 205077b: fix: improve Zod compatibility
226
+ - Updated dependencies [205077b]
227
+ - @ai-sdk/openai-compatible@1.0.0-beta.7
228
+ - @ai-sdk/provider-utils@3.0.0-beta.4
229
+
230
+ ## 1.0.0-beta.6
231
+
232
+ ### Patch Changes
233
+
234
+ - Updated dependencies [281bb1c]
235
+ - @ai-sdk/openai-compatible@1.0.0-beta.6
236
+
237
+ ## 1.0.0-beta.5
238
+
239
+ ### Patch Changes
240
+
241
+ - Updated dependencies [05d2819]
242
+ - @ai-sdk/provider-utils@3.0.0-beta.3
243
+ - @ai-sdk/openai-compatible@1.0.0-beta.5
244
+
245
+ ## 1.0.0-beta.4
246
+
247
+ ### Patch Changes
248
+
249
+ - Updated dependencies [1b101e1]
250
+ - @ai-sdk/openai-compatible@1.0.0-beta.4
251
+
252
+ ## 1.0.0-beta.3
253
+
254
+ ### Patch Changes
255
+
256
+ - Updated dependencies [7b069ed]
257
+ - @ai-sdk/openai-compatible@1.0.0-beta.3
258
+
259
+ ## 1.0.0-beta.2
260
+
261
+ ### Patch Changes
262
+
263
+ - Updated dependencies [0571b98]
264
+ - Updated dependencies [39a4fab]
265
+ - Updated dependencies [d1a034f]
266
+ - @ai-sdk/provider-utils@3.0.0-beta.2
267
+ - @ai-sdk/openai-compatible@1.0.0-beta.2
268
+
269
+ ## 1.0.0-beta.1
270
+
271
+ ### Patch Changes
272
+
273
+ - Updated dependencies [742b7be]
274
+ - Updated dependencies [7cddb72]
275
+ - Updated dependencies [ccce59b]
276
+ - Updated dependencies [e2b9e4b]
277
+ - Updated dependencies [45c1ea2]
278
+ - Updated dependencies [e025824]
279
+ - Updated dependencies [0d06df6]
280
+ - Updated dependencies [472524a]
281
+ - Updated dependencies [dd3ff01]
282
+ - Updated dependencies [7435eb5]
283
+ - Updated dependencies [cb68df0]
284
+ - Updated dependencies [bfdca8d]
285
+ - Updated dependencies [44f4aba]
286
+ - Updated dependencies [023ba40]
287
+ - Updated dependencies [5e57fae]
288
+ - Updated dependencies [71f938d]
289
+ - Updated dependencies [28a5ed5]
290
+ - @ai-sdk/provider@2.0.0-beta.1
291
+ - @ai-sdk/provider-utils@3.0.0-beta.1
292
+ - @ai-sdk/openai-compatible@1.0.0-beta.1
293
+
294
+ ## 1.0.0-alpha.15
295
+
296
+ ### Patch Changes
297
+
298
+ - Updated dependencies [48d257a]
299
+ - Updated dependencies [8ba77a7]
300
+ - @ai-sdk/provider@2.0.0-alpha.15
301
+ - @ai-sdk/provider-utils@3.0.0-alpha.15
302
+ - @ai-sdk/openai-compatible@1.0.0-alpha.15
303
+
304
+ ## 1.0.0-alpha.14
305
+
306
+ ### Patch Changes
307
+
308
+ - Updated dependencies [b5da06a]
309
+ - Updated dependencies [63f9e9b]
310
+ - Updated dependencies [2e13791]
311
+ - @ai-sdk/provider@2.0.0-alpha.14
312
+ - @ai-sdk/openai-compatible@1.0.0-alpha.14
313
+ - @ai-sdk/provider-utils@3.0.0-alpha.14
314
+
315
+ ## 1.0.0-alpha.13
316
+
317
+ ### Patch Changes
318
+
319
+ - Updated dependencies [68ecf2f]
320
+ - @ai-sdk/provider@2.0.0-alpha.13
321
+ - @ai-sdk/openai-compatible@1.0.0-alpha.13
322
+ - @ai-sdk/provider-utils@3.0.0-alpha.13
323
+
324
+ ## 1.0.0-alpha.12
325
+
326
+ ### Patch Changes
327
+
328
+ - e2aceaf: feat: add raw chunk support
329
+ - Updated dependencies [e2aceaf]
330
+ - @ai-sdk/openai-compatible@1.0.0-alpha.12
331
+ - @ai-sdk/provider@2.0.0-alpha.12
332
+ - @ai-sdk/provider-utils@3.0.0-alpha.12
333
+
334
+ ## 1.0.0-alpha.11
335
+
336
+ ### Patch Changes
337
+
338
+ - Updated dependencies [c1e6647]
339
+ - @ai-sdk/provider@2.0.0-alpha.11
340
+ - @ai-sdk/openai-compatible@1.0.0-alpha.11
341
+ - @ai-sdk/provider-utils@3.0.0-alpha.11
342
+
343
+ ## 1.0.0-alpha.10
344
+
345
+ ### Patch Changes
346
+
347
+ - Updated dependencies [c4df419]
348
+ - @ai-sdk/provider@2.0.0-alpha.10
349
+ - @ai-sdk/openai-compatible@1.0.0-alpha.10
350
+ - @ai-sdk/provider-utils@3.0.0-alpha.10
351
+
352
+ ## 1.0.0-alpha.9
353
+
354
+ ### Patch Changes
355
+
356
+ - Updated dependencies [811dff3]
357
+ - @ai-sdk/provider@2.0.0-alpha.9
358
+ - @ai-sdk/openai-compatible@1.0.0-alpha.9
359
+ - @ai-sdk/provider-utils@3.0.0-alpha.9
360
+
361
+ ## 1.0.0-alpha.8
362
+
363
+ ### Patch Changes
364
+
365
+ - Updated dependencies [4fef487]
366
+ - Updated dependencies [9222aeb]
367
+ - @ai-sdk/provider-utils@3.0.0-alpha.8
368
+ - @ai-sdk/provider@2.0.0-alpha.8
369
+ - @ai-sdk/openai-compatible@1.0.0-alpha.8
370
+
371
+ ## 1.0.0-alpha.7
372
+
373
+ ### Patch Changes
374
+
375
+ - Updated dependencies [5c56081]
376
+ - @ai-sdk/provider@2.0.0-alpha.7
377
+ - @ai-sdk/openai-compatible@1.0.0-alpha.7
378
+ - @ai-sdk/provider-utils@3.0.0-alpha.7
379
+
380
+ ## 1.0.0-alpha.6
381
+
382
+ ### Patch Changes
383
+
384
+ - Updated dependencies [0d2c085]
385
+ - @ai-sdk/provider@2.0.0-alpha.6
386
+ - @ai-sdk/openai-compatible@1.0.0-alpha.6
387
+ - @ai-sdk/provider-utils@3.0.0-alpha.6
388
+
389
+ ## 1.0.0-alpha.4
390
+
391
+ ### Patch Changes
392
+
393
+ - Updated dependencies [dc714f3]
394
+ - @ai-sdk/provider@2.0.0-alpha.4
395
+ - @ai-sdk/openai-compatible@1.0.0-alpha.4
396
+ - @ai-sdk/provider-utils@3.0.0-alpha.4
397
+
398
+ ## 1.0.0-alpha.3
399
+
400
+ ### Patch Changes
401
+
402
+ - Updated dependencies [6b98118]
403
+ - @ai-sdk/provider@2.0.0-alpha.3
404
+ - @ai-sdk/openai-compatible@1.0.0-alpha.3
405
+ - @ai-sdk/provider-utils@3.0.0-alpha.3
406
+
407
+ ## 1.0.0-alpha.2
408
+
409
+ ### Patch Changes
410
+
411
+ - Updated dependencies [26535e0]
412
+ - @ai-sdk/provider@2.0.0-alpha.2
413
+ - @ai-sdk/openai-compatible@1.0.0-alpha.2
414
+ - @ai-sdk/provider-utils@3.0.0-alpha.2
415
+
416
+ ## 1.0.0-alpha.1
417
+
418
+ ### Patch Changes
419
+
420
+ - Updated dependencies [3f2f00c]
421
+ - @ai-sdk/provider@2.0.0-alpha.1
422
+ - @ai-sdk/openai-compatible@1.0.0-alpha.1
423
+ - @ai-sdk/provider-utils@3.0.0-alpha.1
424
+
425
+ ## 1.0.0-canary.19
426
+
427
+ ### Patch Changes
428
+
429
+ - Updated dependencies [faf8446]
430
+ - @ai-sdk/provider-utils@3.0.0-canary.19
431
+ - @ai-sdk/openai-compatible@1.0.0-canary.19
432
+
433
+ ## 1.0.0-canary.18
434
+
435
+ ### Patch Changes
436
+
437
+ - Updated dependencies [40acf9b]
438
+ - @ai-sdk/provider-utils@3.0.0-canary.18
439
+ - @ai-sdk/openai-compatible@1.0.0-canary.18
440
+
441
+ ## 1.0.0-canary.17
442
+
443
+ ### Major Changes
444
+
445
+ - 516be5b: ### Move Image Model Settings into generate options
446
+
447
+ Image Models no longer have settings. Instead, `maxImagesPerCall` can be passed directly to `generateImage()`. All other image settings can be passed to `providerOptions[provider]`.
448
+
449
+ Before
450
+
451
+ ```js
452
+ await generateImage({
453
+ model: luma.image('photon-flash-1', {
454
+ maxImagesPerCall: 5,
455
+ pollIntervalMillis: 500,
456
+ }),
457
+ prompt,
458
+ n: 10,
459
+ });
460
+ ```
461
+
462
+ After
463
+
464
+ ```js
465
+ await generateImage({
466
+ model: luma.image('photon-flash-1'),
467
+ prompt,
468
+ n: 10,
469
+ maxImagesPerCall: 5,
470
+ providerOptions: {
471
+ luma: { pollIntervalMillis: 5 },
472
+ },
473
+ });
474
+ ```
475
+
476
+ Pull Request: https://github.com/vercel/ai/pull/6180
477
+
478
+ ### Patch Changes
479
+
480
+ - Updated dependencies [516be5b]
481
+ - Updated dependencies [ea7a7c9]
482
+ - @ai-sdk/openai-compatible@1.0.0-canary.17
483
+ - @ai-sdk/provider-utils@3.0.0-canary.17
484
+
485
+ ## 1.0.0-canary.16
486
+
487
+ ### Patch Changes
488
+
489
+ - Updated dependencies [87b828f]
490
+ - @ai-sdk/provider-utils@3.0.0-canary.16
491
+ - @ai-sdk/openai-compatible@1.0.0-canary.16
492
+
493
+ ## 1.0.0-canary.15
494
+
495
+ ### Patch Changes
496
+
497
+ - Updated dependencies [a571d6e]
498
+ - Updated dependencies [a8c8bd5]
499
+ - Updated dependencies [7979f7f]
500
+ - Updated dependencies [41fa418]
501
+ - @ai-sdk/provider-utils@3.0.0-canary.15
502
+ - @ai-sdk/provider@2.0.0-canary.14
503
+ - @ai-sdk/openai-compatible@1.0.0-canary.15
504
+
505
+ ## 1.0.0-canary.14
506
+
507
+ ### Patch Changes
508
+
509
+ - Updated dependencies [957b739]
510
+ - Updated dependencies [9bd5ab5]
511
+ - @ai-sdk/provider-utils@3.0.0-canary.14
512
+ - @ai-sdk/provider@2.0.0-canary.13
513
+ - @ai-sdk/openai-compatible@1.0.0-canary.14
514
+
515
+ ## 1.0.0-canary.13
516
+
517
+ ### Patch Changes
518
+
519
+ - d9209ca: fix (image-model): `specificationVersion: v1` -> `v2`
520
+ - Updated dependencies [7b3ae3f]
521
+ - Updated dependencies [d9209ca]
522
+ - Updated dependencies [0ff02bb]
523
+ - @ai-sdk/provider@2.0.0-canary.12
524
+ - @ai-sdk/openai-compatible@1.0.0-canary.13
525
+ - @ai-sdk/provider-utils@3.0.0-canary.13
526
+
527
+ ## 1.0.0-canary.12
528
+
529
+ ### Patch Changes
530
+
531
+ - Updated dependencies [9bf7291]
532
+ - Updated dependencies [4617fab]
533
+ - Updated dependencies [e030615]
534
+ - @ai-sdk/provider@2.0.0-canary.11
535
+ - @ai-sdk/openai-compatible@1.0.0-canary.12
536
+ - @ai-sdk/provider-utils@3.0.0-canary.12
537
+
538
+ ## 1.0.0-canary.11
539
+
540
+ ### Patch Changes
541
+
542
+ - 9301f86: refactor (image-model): rename `ImageModelV1` to `ImageModelV2`
543
+ - Updated dependencies [db72adc]
544
+ - Updated dependencies [42e32b0]
545
+ - Updated dependencies [66962ed]
546
+ - Updated dependencies [9301f86]
547
+ - Updated dependencies [a3f768e]
548
+ - @ai-sdk/openai-compatible@1.0.0-canary.11
549
+ - @ai-sdk/provider-utils@3.0.0-canary.11
550
+ - @ai-sdk/provider@2.0.0-canary.10
551
+
552
+ ## 1.0.0-canary.10
553
+
554
+ ### Patch Changes
555
+
556
+ - Updated dependencies [cf8280e]
557
+ - Updated dependencies [e86be6f]
558
+ - @ai-sdk/openai-compatible@1.0.0-canary.10
559
+ - @ai-sdk/provider@2.0.0-canary.9
560
+ - @ai-sdk/provider-utils@3.0.0-canary.10
561
+
3
562
  ## 1.0.0-canary.9
4
563
 
5
564
  ### Patch Changes
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # AI SDK - DeepInfra Provider
2
2
 
3
- The **[DeepInfra provider](https://sdk.vercel.ai/providers/ai-sdk-providers/deepinfra)** for the [AI SDK](https://sdk.vercel.ai/docs)
3
+ The **[DeepInfra provider](https://ai-sdk.dev/providers/ai-sdk-providers/deepinfra)** for the [AI SDK](https://ai-sdk.dev/docs)
4
4
  contains language model support for the DeepInfra API, giving you access to models like Llama 3, Mixtral, and other state-of-the-art LLMs.
5
5
 
6
6
  ## Setup
@@ -33,4 +33,4 @@ const { text } = await generateText({
33
33
 
34
34
  ## Documentation
35
35
 
36
- Please check out the **[DeepInfra provider documentation](https://sdk.vercel.ai/providers/ai-sdk-providers/deepinfra)** for more information.
36
+ Please check out the **[DeepInfra provider documentation](https://ai-sdk.dev/providers/ai-sdk-providers/deepinfra)** for more information.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { ProviderV2, LanguageModelV2, ImageModelV1, EmbeddingModelV2 } from '@ai-sdk/provider';
1
+ import { ProviderV2, LanguageModelV2, ImageModelV2, EmbeddingModelV2 } from '@ai-sdk/provider';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
3
  export { OpenAICompatibleErrorData as DeepInfraErrorData } from '@ai-sdk/openai-compatible';
4
4
 
@@ -9,12 +9,6 @@ type DeepInfraEmbeddingModelId = 'BAAI/bge-base-en-v1.5' | 'BAAI/bge-large-en-v1
9
9
  type DeepInfraCompletionModelId = DeepInfraChatModelId;
10
10
 
11
11
  type DeepInfraImageModelId = 'stabilityai/sd3.5' | 'black-forest-labs/FLUX-1.1-pro' | 'black-forest-labs/FLUX-1-schnell' | 'black-forest-labs/FLUX-1-dev' | 'black-forest-labs/FLUX-pro' | 'stabilityai/sd3.5-medium' | 'stabilityai/sdxl-turbo' | (string & {});
12
- interface DeepInfraImageSettings {
13
- /**
14
- * Override the maximum number of images per call (default 1)
15
- */
16
- maxImagesPerCall?: number;
17
- }
18
12
 
19
13
  interface DeepInfraProviderSettings {
20
14
  /**
@@ -47,11 +41,11 @@ interface DeepInfraProvider extends ProviderV2 {
47
41
  /**
48
42
  Creates a model for image generation.
49
43
  */
50
- image(modelId: DeepInfraImageModelId, settings?: DeepInfraImageSettings): ImageModelV1;
44
+ image(modelId: DeepInfraImageModelId): ImageModelV2;
51
45
  /**
52
46
  Creates a model for image generation.
53
47
  */
54
- imageModel(modelId: DeepInfraImageModelId, settings?: DeepInfraImageSettings): ImageModelV1;
48
+ imageModel(modelId: DeepInfraImageModelId): ImageModelV2;
55
49
  /**
56
50
  Creates a chat model for text generation.
57
51
  */
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ProviderV2, LanguageModelV2, ImageModelV1, EmbeddingModelV2 } from '@ai-sdk/provider';
1
+ import { ProviderV2, LanguageModelV2, ImageModelV2, EmbeddingModelV2 } from '@ai-sdk/provider';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
3
  export { OpenAICompatibleErrorData as DeepInfraErrorData } from '@ai-sdk/openai-compatible';
4
4
 
@@ -9,12 +9,6 @@ type DeepInfraEmbeddingModelId = 'BAAI/bge-base-en-v1.5' | 'BAAI/bge-large-en-v1
9
9
  type DeepInfraCompletionModelId = DeepInfraChatModelId;
10
10
 
11
11
  type DeepInfraImageModelId = 'stabilityai/sd3.5' | 'black-forest-labs/FLUX-1.1-pro' | 'black-forest-labs/FLUX-1-schnell' | 'black-forest-labs/FLUX-1-dev' | 'black-forest-labs/FLUX-pro' | 'stabilityai/sd3.5-medium' | 'stabilityai/sdxl-turbo' | (string & {});
12
- interface DeepInfraImageSettings {
13
- /**
14
- * Override the maximum number of images per call (default 1)
15
- */
16
- maxImagesPerCall?: number;
17
- }
18
12
 
19
13
  interface DeepInfraProviderSettings {
20
14
  /**
@@ -47,11 +41,11 @@ interface DeepInfraProvider extends ProviderV2 {
47
41
  /**
48
42
  Creates a model for image generation.
49
43
  */
50
- image(modelId: DeepInfraImageModelId, settings?: DeepInfraImageSettings): ImageModelV1;
44
+ image(modelId: DeepInfraImageModelId): ImageModelV2;
51
45
  /**
52
46
  Creates a model for image generation.
53
47
  */
54
- imageModel(modelId: DeepInfraImageModelId, settings?: DeepInfraImageSettings): ImageModelV1;
48
+ imageModel(modelId: DeepInfraImageModelId): ImageModelV2;
55
49
  /**
56
50
  Creates a chat model for text generation.
57
51
  */
package/dist/index.js CHANGED
@@ -31,21 +31,17 @@ var import_provider_utils2 = require("@ai-sdk/provider-utils");
31
31
 
32
32
  // src/deepinfra-image-model.ts
33
33
  var import_provider_utils = require("@ai-sdk/provider-utils");
34
- var import_zod = require("zod");
34
+ var import_v4 = require("zod/v4");
35
35
  var DeepInfraImageModel = class {
36
- constructor(modelId, settings, config) {
36
+ constructor(modelId, config) {
37
37
  this.modelId = modelId;
38
- this.settings = settings;
39
38
  this.config = config;
40
- this.specificationVersion = "v1";
39
+ this.specificationVersion = "v2";
40
+ this.maxImagesPerCall = 1;
41
41
  }
42
42
  get provider() {
43
43
  return this.config.provider;
44
44
  }
45
- get maxImagesPerCall() {
46
- var _a;
47
- return (_a = this.settings.maxImagesPerCall) != null ? _a : 1;
48
- }
49
45
  async doGenerate({
50
46
  prompt,
51
47
  n,
@@ -94,13 +90,13 @@ var DeepInfraImageModel = class {
94
90
  };
95
91
  }
96
92
  };
97
- var deepInfraErrorSchema = import_zod.z.object({
98
- detail: import_zod.z.object({
99
- error: import_zod.z.string()
93
+ var deepInfraErrorSchema = import_v4.z.object({
94
+ detail: import_v4.z.object({
95
+ error: import_v4.z.string()
100
96
  })
101
97
  });
102
- var deepInfraImageResponseSchema = import_zod.z.object({
103
- images: import_zod.z.array(import_zod.z.string())
98
+ var deepInfraImageResponseSchema = import_v4.z.object({
99
+ images: import_v4.z.array(import_v4.z.string())
104
100
  });
105
101
 
106
102
  // src/deepinfra-provider.ts
@@ -137,7 +133,7 @@ function createDeepInfra(options = {}) {
137
133
  modelId,
138
134
  getCommonModelConfig("embedding")
139
135
  );
140
- const createImageModel = (modelId, settings = {}) => new DeepInfraImageModel(modelId, settings, {
136
+ const createImageModel = (modelId) => new DeepInfraImageModel(modelId, {
141
137
  ...getCommonModelConfig("image"),
142
138
  baseURL: baseURL ? `${baseURL}/inference` : "https://api.deepinfra.com/v1/inference"
143
139
  });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/deepinfra-provider.ts","../src/deepinfra-image-model.ts"],"sourcesContent":["export { createDeepInfra, deepinfra } from './deepinfra-provider';\nexport type {\n DeepInfraProvider,\n DeepInfraProviderSettings,\n} from './deepinfra-provider';\nexport type { OpenAICompatibleErrorData as DeepInfraErrorData } from '@ai-sdk/openai-compatible';\n","import {\n LanguageModelV2,\n EmbeddingModelV2,\n ProviderV2,\n ImageModelV1,\n} from '@ai-sdk/provider';\nimport {\n OpenAICompatibleChatLanguageModel,\n OpenAICompatibleCompletionLanguageModel,\n OpenAICompatibleEmbeddingModel,\n} from '@ai-sdk/openai-compatible';\nimport {\n FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n} from '@ai-sdk/provider-utils';\nimport { DeepInfraChatModelId } from './deepinfra-chat-settings';\nimport { DeepInfraEmbeddingModelId } from './deepinfra-embedding-settings';\nimport { DeepInfraCompletionModelId } from './deepinfra-completion-settings';\nimport {\n DeepInfraImageModelId,\n DeepInfraImageSettings,\n} from './deepinfra-image-settings';\nimport { DeepInfraImageModel } from './deepinfra-image-model';\n\nexport interface DeepInfraProviderSettings {\n /**\nDeepInfra API key.\n*/\n apiKey?: string;\n /**\nBase URL for the API calls.\n*/\n baseURL?: string;\n /**\nCustom headers to include in the requests.\n*/\n headers?: Record<string, string>;\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n*/\n fetch?: FetchFunction;\n}\n\nexport interface DeepInfraProvider extends ProviderV2 {\n /**\nCreates a model for text generation.\n*/\n (modelId: DeepInfraChatModelId): LanguageModelV2;\n\n /**\nCreates a chat model for text generation.\n*/\n chatModel(modelId: DeepInfraChatModelId): LanguageModelV2;\n\n /**\nCreates a model for image generation.\n */\n image(\n modelId: DeepInfraImageModelId,\n settings?: DeepInfraImageSettings,\n ): ImageModelV1;\n\n /**\nCreates a model for image generation.\n */\n imageModel(\n modelId: DeepInfraImageModelId,\n settings?: DeepInfraImageSettings,\n ): ImageModelV1;\n\n /**\nCreates a chat model for text generation.\n*/\n languageModel(modelId: DeepInfraChatModelId): LanguageModelV2;\n\n /**\nCreates a completion model for text generation.\n*/\n completionModel(modelId: DeepInfraCompletionModelId): LanguageModelV2;\n\n /**\nCreates a text embedding model for text generation.\n*/\n textEmbeddingModel(\n modelId: DeepInfraEmbeddingModelId,\n ): EmbeddingModelV2<string>;\n}\n\nexport function createDeepInfra(\n options: DeepInfraProviderSettings = {},\n): DeepInfraProvider {\n const baseURL = withoutTrailingSlash(\n options.baseURL ?? 'https://api.deepinfra.com/v1',\n );\n const getHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'DEEPINFRA_API_KEY',\n description: \"DeepInfra's API key\",\n })}`,\n ...options.headers,\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 = (modelType: string): CommonModelConfig => ({\n provider: `deepinfra.${modelType}`,\n url: ({ path }) => `${baseURL}/openai${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createChatModel = (modelId: DeepInfraChatModelId) => {\n return new OpenAICompatibleChatLanguageModel(\n modelId,\n getCommonModelConfig('chat'),\n );\n };\n\n const createCompletionModel = (modelId: DeepInfraCompletionModelId) =>\n new OpenAICompatibleCompletionLanguageModel(\n modelId,\n getCommonModelConfig('completion'),\n );\n\n const createTextEmbeddingModel = (modelId: DeepInfraEmbeddingModelId) =>\n new OpenAICompatibleEmbeddingModel(\n modelId,\n getCommonModelConfig('embedding'),\n );\n\n const createImageModel = (\n modelId: DeepInfraImageModelId,\n settings: DeepInfraImageSettings = {},\n ) =>\n new DeepInfraImageModel(modelId, settings, {\n ...getCommonModelConfig('image'),\n baseURL: baseURL\n ? `${baseURL}/inference`\n : 'https://api.deepinfra.com/v1/inference',\n });\n\n const provider = (modelId: DeepInfraChatModelId) => createChatModel(modelId);\n\n provider.completionModel = createCompletionModel;\n provider.chatModel = createChatModel;\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n provider.languageModel = createChatModel;\n provider.textEmbeddingModel = createTextEmbeddingModel;\n\n return provider;\n}\n\nexport const deepinfra = createDeepInfra();\n","import { ImageModelV1, ImageModelV1CallWarning } from '@ai-sdk/provider';\nimport {\n FetchFunction,\n combineHeaders,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n postJsonToApi,\n} from '@ai-sdk/provider-utils';\nimport {\n DeepInfraImageModelId,\n DeepInfraImageSettings,\n} from './deepinfra-image-settings';\nimport { z } from 'zod';\n\ninterface DeepInfraImageModelConfig {\n provider: string;\n baseURL: string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class DeepInfraImageModel implements ImageModelV1 {\n readonly specificationVersion = 'v1';\n\n get provider(): string {\n return this.config.provider;\n }\n\n get maxImagesPerCall(): number {\n return this.settings.maxImagesPerCall ?? 1;\n }\n\n constructor(\n readonly modelId: DeepInfraImageModelId,\n readonly settings: DeepInfraImageSettings,\n private config: DeepInfraImageModelConfig,\n ) {}\n\n async doGenerate({\n prompt,\n n,\n size,\n aspectRatio,\n seed,\n providerOptions,\n headers,\n abortSignal,\n }: Parameters<ImageModelV1['doGenerate']>[0]): Promise<\n Awaited<ReturnType<ImageModelV1['doGenerate']>>\n > {\n const warnings: Array<ImageModelV1CallWarning> = [];\n\n // Some deepinfra models support size while others support aspect ratio.\n // Allow passing either and leave it up to the server to validate.\n\n const splitSize = size?.split('x');\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const { value: response, responseHeaders } = await postJsonToApi({\n url: `${this.config.baseURL}/${this.modelId}`,\n headers: combineHeaders(this.config.headers(), headers),\n body: {\n prompt,\n num_images: n,\n ...(aspectRatio && { aspect_ratio: aspectRatio }),\n ...(splitSize && { width: splitSize[0], height: splitSize[1] }),\n ...(seed != null && { seed }),\n ...(providerOptions.deepinfra ?? {}),\n },\n failedResponseHandler: createJsonErrorResponseHandler({\n errorSchema: deepInfraErrorSchema,\n errorToMessage: error => error.detail.error,\n }),\n successfulResponseHandler: createJsonResponseHandler(\n deepInfraImageResponseSchema,\n ),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n images: response.images.map(image =>\n image.replace(/^data:image\\/\\w+;base64,/, ''),\n ),\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n },\n };\n }\n}\n\nexport const deepInfraErrorSchema = z.object({\n detail: z.object({\n error: z.string(),\n }),\n});\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nexport const deepInfraImageResponseSchema = z.object({\n images: z.array(z.string()),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,+BAIO;AACP,IAAAA,yBAIO;;;ACdP,4BAMO;AAKP,iBAAkB;AAYX,IAAM,sBAAN,MAAkD;AAAA,EAWvD,YACW,SACA,UACD,QACR;AAHS;AACA;AACD;AAbV,SAAS,uBAAuB;AAAA,EAc7B;AAAA,EAZH,IAAI,WAAmB;AACrB,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAEA,IAAI,mBAA2B;AA/BjC;AAgCI,YAAO,UAAK,SAAS,qBAAd,YAAkC;AAAA,EAC3C;AAAA,EAQA,MAAM,WAAW;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAEE;AApDJ;AAqDI,UAAM,WAA2C,CAAC;AAKlD,UAAM,YAAY,6BAAM,MAAM;AAC9B,UAAM,eAAc,sBAAK,OAAO,cAAZ,mBAAuB,gBAAvB,4CAA0C,oBAAI,KAAK;AACvE,UAAM,EAAE,OAAO,UAAU,gBAAgB,IAAI,UAAM,qCAAc;AAAA,MAC/D,KAAK,GAAG,KAAK,OAAO,OAAO,IAAI,KAAK,OAAO;AAAA,MAC3C,aAAS,sCAAe,KAAK,OAAO,QAAQ,GAAG,OAAO;AAAA,MACtD,MAAM;AAAA,QACJ;AAAA,QACA,YAAY;AAAA,QACZ,GAAI,eAAe,EAAE,cAAc,YAAY;AAAA,QAC/C,GAAI,aAAa,EAAE,OAAO,UAAU,CAAC,GAAG,QAAQ,UAAU,CAAC,EAAE;AAAA,QAC7D,GAAI,QAAQ,QAAQ,EAAE,KAAK;AAAA,QAC3B,IAAI,qBAAgB,cAAhB,YAA6B,CAAC;AAAA,MACpC;AAAA,MACA,2BAAuB,sDAA+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B,IAAI;AAAA,IACF;AAAA,IACA,qBAAqB,YAAY;AAAA,EACnC;AAEF,QAAM,2BAA2B,CAAC,YAChC,IAAI;AAAA,IACF;AAAA,IACA,qBAAqB,WAAW;AAAA,EAClC;AAEF,QAAM,mBAAmB,CACvB,SACA,WAAmC,CAAC,MAEpC,IAAI,oBAAoB,SAAS,UAAU;AAAA,IACzC,GAAG,qBAAqB,OAAO;AAAA,IAC/B,SAAS,UACL,GAAG,OAAO,eACV;AAAA,EACN,CAAC;AAEH,QAAM,WAAW,CAAC,YAAkC,gBAAgB,OAAO;AAE3E,WAAS,kBAAkB;AAC3B,WAAS,YAAY;AACrB,WAAS,QAAQ;AACjB,WAAS,aAAa;AACtB,WAAS,gBAAgB;AACzB,WAAS,qBAAqB;AAE9B,SAAO;AACT;AAEO,IAAM,YAAY,gBAAgB;","names":["import_provider_utils"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/deepinfra-provider.ts","../src/deepinfra-image-model.ts"],"sourcesContent":["export { createDeepInfra, deepinfra } from './deepinfra-provider';\nexport type {\n DeepInfraProvider,\n DeepInfraProviderSettings,\n} from './deepinfra-provider';\nexport type { OpenAICompatibleErrorData as DeepInfraErrorData } from '@ai-sdk/openai-compatible';\n","import {\n LanguageModelV2,\n EmbeddingModelV2,\n ProviderV2,\n ImageModelV2,\n} from '@ai-sdk/provider';\nimport {\n OpenAICompatibleChatLanguageModel,\n OpenAICompatibleCompletionLanguageModel,\n OpenAICompatibleEmbeddingModel,\n} from '@ai-sdk/openai-compatible';\nimport {\n FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n} from '@ai-sdk/provider-utils';\nimport { DeepInfraChatModelId } from './deepinfra-chat-options';\nimport { DeepInfraEmbeddingModelId } from './deepinfra-embedding-options';\nimport { DeepInfraCompletionModelId } from './deepinfra-completion-options';\nimport { DeepInfraImageModelId } from './deepinfra-image-settings';\nimport { DeepInfraImageModel } from './deepinfra-image-model';\n\nexport interface DeepInfraProviderSettings {\n /**\nDeepInfra API key.\n*/\n apiKey?: string;\n /**\nBase URL for the API calls.\n*/\n baseURL?: string;\n /**\nCustom headers to include in the requests.\n*/\n headers?: Record<string, string>;\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n*/\n fetch?: FetchFunction;\n}\n\nexport interface DeepInfraProvider extends ProviderV2 {\n /**\nCreates a model for text generation.\n*/\n (modelId: DeepInfraChatModelId): LanguageModelV2;\n\n /**\nCreates a chat model for text generation.\n*/\n chatModel(modelId: DeepInfraChatModelId): LanguageModelV2;\n\n /**\nCreates a model for image generation.\n */\n image(modelId: DeepInfraImageModelId): ImageModelV2;\n\n /**\nCreates a model for image generation.\n */\n imageModel(modelId: DeepInfraImageModelId): ImageModelV2;\n\n /**\nCreates a chat model for text generation.\n*/\n languageModel(modelId: DeepInfraChatModelId): LanguageModelV2;\n\n /**\nCreates a completion model for text generation.\n*/\n completionModel(modelId: DeepInfraCompletionModelId): LanguageModelV2;\n\n /**\nCreates a text embedding model for text generation.\n*/\n textEmbeddingModel(\n modelId: DeepInfraEmbeddingModelId,\n ): EmbeddingModelV2<string>;\n}\n\nexport function createDeepInfra(\n options: DeepInfraProviderSettings = {},\n): DeepInfraProvider {\n const baseURL = withoutTrailingSlash(\n options.baseURL ?? 'https://api.deepinfra.com/v1',\n );\n const getHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'DEEPINFRA_API_KEY',\n description: \"DeepInfra's API key\",\n })}`,\n ...options.headers,\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 = (modelType: string): CommonModelConfig => ({\n provider: `deepinfra.${modelType}`,\n url: ({ path }) => `${baseURL}/openai${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createChatModel = (modelId: DeepInfraChatModelId) => {\n return new OpenAICompatibleChatLanguageModel(\n modelId,\n getCommonModelConfig('chat'),\n );\n };\n\n const createCompletionModel = (modelId: DeepInfraCompletionModelId) =>\n new OpenAICompatibleCompletionLanguageModel(\n modelId,\n getCommonModelConfig('completion'),\n );\n\n const createTextEmbeddingModel = (modelId: DeepInfraEmbeddingModelId) =>\n new OpenAICompatibleEmbeddingModel(\n modelId,\n getCommonModelConfig('embedding'),\n );\n\n const createImageModel = (modelId: DeepInfraImageModelId) =>\n new DeepInfraImageModel(modelId, {\n ...getCommonModelConfig('image'),\n baseURL: baseURL\n ? `${baseURL}/inference`\n : 'https://api.deepinfra.com/v1/inference',\n });\n\n const provider = (modelId: DeepInfraChatModelId) => createChatModel(modelId);\n\n provider.completionModel = createCompletionModel;\n provider.chatModel = createChatModel;\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n provider.languageModel = createChatModel;\n provider.textEmbeddingModel = createTextEmbeddingModel;\n\n return provider;\n}\n\nexport const deepinfra = createDeepInfra();\n","import { ImageModelV2, ImageModelV2CallWarning } from '@ai-sdk/provider';\nimport {\n FetchFunction,\n combineHeaders,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n postJsonToApi,\n} from '@ai-sdk/provider-utils';\nimport { DeepInfraImageModelId } from './deepinfra-image-settings';\nimport { z } from 'zod/v4';\n\ninterface DeepInfraImageModelConfig {\n provider: string;\n baseURL: string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class DeepInfraImageModel implements ImageModelV2 {\n readonly specificationVersion = 'v2';\n readonly maxImagesPerCall = 1;\n\n get provider(): string {\n return this.config.provider;\n }\n\n constructor(\n readonly modelId: DeepInfraImageModelId,\n private config: DeepInfraImageModelConfig,\n ) {}\n\n async doGenerate({\n prompt,\n n,\n size,\n aspectRatio,\n seed,\n providerOptions,\n headers,\n abortSignal,\n }: Parameters<ImageModelV2['doGenerate']>[0]): Promise<\n Awaited<ReturnType<ImageModelV2['doGenerate']>>\n > {\n const warnings: Array<ImageModelV2CallWarning> = [];\n\n // Some deepinfra models support size while others support aspect ratio.\n // Allow passing either and leave it up to the server to validate.\n\n const splitSize = size?.split('x');\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const { value: response, responseHeaders } = await postJsonToApi({\n url: `${this.config.baseURL}/${this.modelId}`,\n headers: combineHeaders(this.config.headers(), headers),\n body: {\n prompt,\n num_images: n,\n ...(aspectRatio && { aspect_ratio: aspectRatio }),\n ...(splitSize && { width: splitSize[0], height: splitSize[1] }),\n ...(seed != null && { seed }),\n ...(providerOptions.deepinfra ?? {}),\n },\n failedResponseHandler: createJsonErrorResponseHandler({\n errorSchema: deepInfraErrorSchema,\n errorToMessage: error => error.detail.error,\n }),\n successfulResponseHandler: createJsonResponseHandler(\n deepInfraImageResponseSchema,\n ),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n images: response.images.map(image =>\n image.replace(/^data:image\\/\\w+;base64,/, ''),\n ),\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n },\n };\n }\n}\n\nexport const deepInfraErrorSchema = z.object({\n detail: z.object({\n error: z.string(),\n }),\n});\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nexport const deepInfraImageResponseSchema = z.object({\n images: z.array(z.string()),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,+BAIO;AACP,IAAAA,yBAIO;;;ACdP,4BAMO;AAEP,gBAAkB;AAYX,IAAM,sBAAN,MAAkD;AAAA,EAQvD,YACW,SACD,QACR;AAFS;AACD;AATV,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAAA,EASzB;AAAA,EAPH,IAAI,WAAmB;AACrB,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAOA,MAAM,WAAW;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAA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ler,
17
17
  postJsonToApi
18
18
  } from "@ai-sdk/provider-utils";
19
- import { z } from "zod";
19
+ import { z } from "zod/v4";
20
20
  var DeepInfraImageModel = class {
21
- constructor(modelId, settings, config) {
21
+ constructor(modelId, config) {
22
22
  this.modelId = modelId;
23
- this.settings = settings;
24
23
  this.config = config;
25
- this.specificationVersion = "v1";
24
+ this.specificationVersion = "v2";
25
+ this.maxImagesPerCall = 1;
26
26
  }
27
27
  get provider() {
28
28
  return this.config.provider;
29
29
  }
30
- get maxImagesPerCall() {
31
- var _a;
32
- return (_a = this.settings.maxImagesPerCall) != null ? _a : 1;
33
- }
34
30
  async doGenerate({
35
31
  prompt,
36
32
  n,
@@ -122,7 +118,7 @@ function createDeepInfra(options = {}) {
122
118
  modelId,
123
119
  getCommonModelConfig("embedding")
124
120
  );
125
- const createImageModel = (modelId, settings = {}) => new DeepInfraImageModel(modelId, settings, {
121
+ const createImageModel = (modelId) => new DeepInfraImageModel(modelId, {
126
122
  ...getCommonModelConfig("image"),
127
123
  baseURL: baseURL ? `${baseURL}/inference` : "https://api.deepinfra.com/v1/inference"
128
124
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/deepinfra-provider.ts","../src/deepinfra-image-model.ts"],"sourcesContent":["import {\n LanguageModelV2,\n EmbeddingModelV2,\n ProviderV2,\n ImageModelV1,\n} from '@ai-sdk/provider';\nimport {\n OpenAICompatibleChatLanguageModel,\n OpenAICompatibleCompletionLanguageModel,\n OpenAICompatibleEmbeddingModel,\n} from '@ai-sdk/openai-compatible';\nimport {\n FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n} from '@ai-sdk/provider-utils';\nimport { DeepInfraChatModelId } from './deepinfra-chat-settings';\nimport { DeepInfraEmbeddingModelId } from './deepinfra-embedding-settings';\nimport { DeepInfraCompletionModelId } from './deepinfra-completion-settings';\nimport {\n DeepInfraImageModelId,\n DeepInfraImageSettings,\n} from './deepinfra-image-settings';\nimport { DeepInfraImageModel } from './deepinfra-image-model';\n\nexport interface DeepInfraProviderSettings {\n /**\nDeepInfra API key.\n*/\n apiKey?: string;\n /**\nBase URL for the API calls.\n*/\n baseURL?: string;\n /**\nCustom headers to include in the requests.\n*/\n headers?: Record<string, string>;\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n*/\n fetch?: FetchFunction;\n}\n\nexport interface DeepInfraProvider extends ProviderV2 {\n /**\nCreates a model for text generation.\n*/\n (modelId: DeepInfraChatModelId): LanguageModelV2;\n\n /**\nCreates a chat model for text generation.\n*/\n chatModel(modelId: DeepInfraChatModelId): LanguageModelV2;\n\n /**\nCreates a model for image generation.\n */\n image(\n modelId: DeepInfraImageModelId,\n settings?: DeepInfraImageSettings,\n ): ImageModelV1;\n\n /**\nCreates a model for image generation.\n */\n imageModel(\n modelId: DeepInfraImageModelId,\n settings?: DeepInfraImageSettings,\n ): ImageModelV1;\n\n /**\nCreates a chat model for text generation.\n*/\n languageModel(modelId: DeepInfraChatModelId): LanguageModelV2;\n\n /**\nCreates a completion model for text generation.\n*/\n completionModel(modelId: DeepInfraCompletionModelId): LanguageModelV2;\n\n /**\nCreates a text embedding model for text generation.\n*/\n textEmbeddingModel(\n modelId: DeepInfraEmbeddingModelId,\n ): EmbeddingModelV2<string>;\n}\n\nexport function createDeepInfra(\n options: DeepInfraProviderSettings = {},\n): DeepInfraProvider {\n const baseURL = withoutTrailingSlash(\n options.baseURL ?? 'https://api.deepinfra.com/v1',\n );\n const getHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'DEEPINFRA_API_KEY',\n description: \"DeepInfra's API key\",\n })}`,\n ...options.headers,\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 = (modelType: string): CommonModelConfig => ({\n provider: `deepinfra.${modelType}`,\n url: ({ path }) => `${baseURL}/openai${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createChatModel = (modelId: DeepInfraChatModelId) => {\n return new OpenAICompatibleChatLanguageModel(\n modelId,\n getCommonModelConfig('chat'),\n );\n };\n\n const createCompletionModel = (modelId: DeepInfraCompletionModelId) =>\n new OpenAICompatibleCompletionLanguageModel(\n modelId,\n getCommonModelConfig('completion'),\n );\n\n const createTextEmbeddingModel = (modelId: DeepInfraEmbeddingModelId) =>\n new OpenAICompatibleEmbeddingModel(\n modelId,\n getCommonModelConfig('embedding'),\n );\n\n const createImageModel = (\n modelId: DeepInfraImageModelId,\n settings: DeepInfraImageSettings = {},\n ) =>\n new DeepInfraImageModel(modelId, settings, {\n ...getCommonModelConfig('image'),\n baseURL: baseURL\n ? `${baseURL}/inference`\n : 'https://api.deepinfra.com/v1/inference',\n });\n\n const provider = (modelId: DeepInfraChatModelId) => createChatModel(modelId);\n\n provider.completionModel = createCompletionModel;\n provider.chatModel = createChatModel;\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n provider.languageModel = createChatModel;\n provider.textEmbeddingModel = createTextEmbeddingModel;\n\n return provider;\n}\n\nexport const deepinfra = createDeepInfra();\n","import { ImageModelV1, ImageModelV1CallWarning } from '@ai-sdk/provider';\nimport {\n FetchFunction,\n combineHeaders,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n postJsonToApi,\n} from '@ai-sdk/provider-utils';\nimport {\n DeepInfraImageModelId,\n DeepInfraImageSettings,\n} from './deepinfra-image-settings';\nimport { z } from 'zod';\n\ninterface DeepInfraImageModelConfig {\n provider: string;\n baseURL: string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class DeepInfraImageModel implements ImageModelV1 {\n readonly specificationVersion = 'v1';\n\n get provider(): string {\n return this.config.provider;\n }\n\n get maxImagesPerCall(): number {\n return this.settings.maxImagesPerCall ?? 1;\n }\n\n constructor(\n readonly modelId: DeepInfraImageModelId,\n readonly settings: DeepInfraImageSettings,\n private config: DeepInfraImageModelConfig,\n ) {}\n\n async doGenerate({\n prompt,\n n,\n size,\n aspectRatio,\n seed,\n providerOptions,\n headers,\n abortSignal,\n }: Parameters<ImageModelV1['doGenerate']>[0]): Promise<\n Awaited<ReturnType<ImageModelV1['doGenerate']>>\n > {\n const warnings: Array<ImageModelV1CallWarning> = [];\n\n // Some deepinfra models support size while others support aspect ratio.\n // Allow passing either and leave it up to the server to validate.\n\n const splitSize = size?.split('x');\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const { value: response, responseHeaders } = await postJsonToApi({\n url: `${this.config.baseURL}/${this.modelId}`,\n headers: combineHeaders(this.config.headers(), headers),\n body: {\n prompt,\n num_images: n,\n ...(aspectRatio && { aspect_ratio: aspectRatio }),\n ...(splitSize && { width: splitSize[0], height: splitSize[1] }),\n ...(seed != null && { seed }),\n ...(providerOptions.deepinfra ?? {}),\n },\n failedResponseHandler: createJsonErrorResponseHandler({\n errorSchema: deepInfraErrorSchema,\n errorToMessage: error => error.detail.error,\n }),\n successfulResponseHandler: createJsonResponseHandler(\n deepInfraImageResponseSchema,\n ),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n images: response.images.map(image =>\n image.replace(/^data:image\\/\\w+;base64,/, ''),\n ),\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n },\n };\n }\n}\n\nexport const deepInfraErrorSchema = z.object({\n detail: z.object({\n error: z.string(),\n }),\n});\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nexport const deepInfraImageResponseSchema = z.object({\n images: z.array(z.string()),\n});\n"],"mappings":";AAMA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EAEE;AAAA,EACA;AAAA,OACK;;;ACdP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAKP,SAAS,SAAS;AAYX,IAAM,sBAAN,MAAkD;A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AA,IAC/B,SAAS,UACL,GAAG,OAAO,eACV;AAAA,EACN,CAAC;AAEH,QAAM,WAAW,CAAC,YAAkC,gBAAgB,OAAO;AAE3E,WAAS,kBAAkB;AAC3B,WAAS,YAAY;AACrB,WAAS,QAAQ;AACjB,WAAS,aAAa;AACtB,WAAS,gBAAgB;AACzB,WAAS,qBAAqB;AAE9B,SAAO;AACT;AAEO,IAAM,YAAY,gBAAgB;","names":[]}
1
+ {"version":3,"sources":["../src/deepinfra-provider.ts","../src/deepinfra-image-model.ts"],"sourcesContent":["import {\n LanguageModelV2,\n EmbeddingModelV2,\n ProviderV2,\n ImageModelV2,\n} from '@ai-sdk/provider';\nimport {\n OpenAICompatibleChatLanguageModel,\n OpenAICompatibleCompletionLanguageModel,\n OpenAICompatibleEmbeddingModel,\n} from '@ai-sdk/openai-compatible';\nimport {\n FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n} from '@ai-sdk/provider-utils';\nimport { DeepInfraChatModelId } from './deepinfra-chat-options';\nimport { DeepInfraEmbeddingModelId } from './deepinfra-embedding-options';\nimport { DeepInfraCompletionModelId } from './deepinfra-completion-options';\nimport { DeepInfraImageModelId } from './deepinfra-image-settings';\nimport { DeepInfraImageModel } from './deepinfra-image-model';\n\nexport interface DeepInfraProviderSettings {\n /**\nDeepInfra API key.\n*/\n apiKey?: string;\n /**\nBase URL for the API calls.\n*/\n baseURL?: string;\n /**\nCustom headers to include in the requests.\n*/\n headers?: Record<string, string>;\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n*/\n fetch?: FetchFunction;\n}\n\nexport interface DeepInfraProvider extends ProviderV2 {\n /**\nCreates a model for text generation.\n*/\n (modelId: DeepInfraChatModelId): LanguageModelV2;\n\n /**\nCreates a chat model for text generation.\n*/\n chatModel(modelId: DeepInfraChatModelId): LanguageModelV2;\n\n /**\nCreates a model for image generation.\n */\n image(modelId: DeepInfraImageModelId): ImageModelV2;\n\n /**\nCreates a model for image generation.\n */\n imageModel(modelId: DeepInfraImageModelId): ImageModelV2;\n\n /**\nCreates a chat model for text generation.\n*/\n languageModel(modelId: DeepInfraChatModelId): LanguageModelV2;\n\n /**\nCreates a completion model for text generation.\n*/\n completionModel(modelId: DeepInfraCompletionModelId): LanguageModelV2;\n\n /**\nCreates a text embedding model for text generation.\n*/\n textEmbeddingModel(\n modelId: DeepInfraEmbeddingModelId,\n ): EmbeddingModelV2<string>;\n}\n\nexport function createDeepInfra(\n options: DeepInfraProviderSettings = {},\n): DeepInfraProvider {\n const baseURL = withoutTrailingSlash(\n options.baseURL ?? 'https://api.deepinfra.com/v1',\n );\n const getHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'DEEPINFRA_API_KEY',\n description: \"DeepInfra's API key\",\n })}`,\n ...options.headers,\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 = (modelType: string): CommonModelConfig => ({\n provider: `deepinfra.${modelType}`,\n url: ({ path }) => `${baseURL}/openai${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createChatModel = (modelId: DeepInfraChatModelId) => {\n return new OpenAICompatibleChatLanguageModel(\n modelId,\n getCommonModelConfig('chat'),\n );\n };\n\n const createCompletionModel = (modelId: DeepInfraCompletionModelId) =>\n new OpenAICompatibleCompletionLanguageModel(\n modelId,\n getCommonModelConfig('completion'),\n );\n\n const createTextEmbeddingModel = (modelId: DeepInfraEmbeddingModelId) =>\n new OpenAICompatibleEmbeddingModel(\n modelId,\n getCommonModelConfig('embedding'),\n );\n\n const createImageModel = (modelId: DeepInfraImageModelId) =>\n new DeepInfraImageModel(modelId, {\n ...getCommonModelConfig('image'),\n baseURL: baseURL\n ? `${baseURL}/inference`\n : 'https://api.deepinfra.com/v1/inference',\n });\n\n const provider = (modelId: DeepInfraChatModelId) => createChatModel(modelId);\n\n provider.completionModel = createCompletionModel;\n provider.chatModel = createChatModel;\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n provider.languageModel = createChatModel;\n provider.textEmbeddingModel = createTextEmbeddingModel;\n\n return provider;\n}\n\nexport const deepinfra = createDeepInfra();\n","import { ImageModelV2, ImageModelV2CallWarning } from '@ai-sdk/provider';\nimport {\n FetchFunction,\n combineHeaders,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n postJsonToApi,\n} from '@ai-sdk/provider-utils';\nimport { DeepInfraImageModelId } from './deepinfra-image-settings';\nimport { z } from 'zod/v4';\n\ninterface DeepInfraImageModelConfig {\n provider: string;\n baseURL: string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class DeepInfraImageModel implements ImageModelV2 {\n readonly specificationVersion = 'v2';\n readonly maxImagesPerCall = 1;\n\n get provider(): string {\n return this.config.provider;\n }\n\n constructor(\n readonly modelId: DeepInfraImageModelId,\n private config: DeepInfraImageModelConfig,\n ) {}\n\n async doGenerate({\n prompt,\n n,\n size,\n aspectRatio,\n seed,\n providerOptions,\n headers,\n abortSignal,\n }: Parameters<ImageModelV2['doGenerate']>[0]): Promise<\n Awaited<ReturnType<ImageModelV2['doGenerate']>>\n > {\n const warnings: Array<ImageModelV2CallWarning> = [];\n\n // Some deepinfra models support size while others support aspect ratio.\n // Allow passing either and leave it up to the server to validate.\n\n const splitSize = size?.split('x');\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const { value: response, responseHeaders } = await postJsonToApi({\n url: `${this.config.baseURL}/${this.modelId}`,\n headers: combineHeaders(this.config.headers(), headers),\n body: {\n prompt,\n num_images: n,\n ...(aspectRatio && { aspect_ratio: aspectRatio }),\n ...(splitSize && { width: splitSize[0], height: splitSize[1] }),\n ...(seed != null && { seed }),\n ...(providerOptions.deepinfra ?? {}),\n },\n failedResponseHandler: createJsonErrorResponseHandler({\n errorSchema: deepInfraErrorSchema,\n errorToMessage: error => error.detail.error,\n }),\n successfulResponseHandler: createJsonResponseHandler(\n deepInfraImageResponseSchema,\n ),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n images: response.images.map(image =>\n image.replace(/^data:image\\/\\w+;base64,/, ''),\n ),\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n },\n };\n }\n}\n\nexport const deepInfraErrorSchema = z.object({\n detail: z.object({\n error: z.string(),\n }),\n});\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nexport const deepInfraImageResponseSchema = z.object({\n images: z.array(z.string()),\n});\n"],"mappings":";AAMA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EAEE;AAAA,EACA;AAAA,OACK;;;ACdP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,SAAS;AAYX,IAAM,sBAAN,MAAkD;AAAA,EAQvD,YACW,SACD,QACR;AAFS;AACD;AATV,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAAA,EASzB;AAAA,EAPH,IAAI,WAAmB;AACrB,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAOA,MAAM,WAAW;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAEE;AA7CJ;AA8CI,UAAM,WAA2C,CAAC;AAKlD,UAAM,YAAY,6BAAM,MAAM;AAC9B,UAAM,eAAc,sBAAK,OAAO,cAAZ,mBAAuB,gBAAvB,4CAA0C,oBAAI,KAAK;AACvE,UAAM,EAAE,OAAO,UAAU,gBAAgB,IAAI,MAAM,cAAc;AAAA,MAC/D,KAAK,GAAG,KAAK,OAAO,OAAO,IAAI,KAAK,OAAO;AAAA,MAC3C,SAAS,eAAe,KAAK,OAAO,QAAQ,GAAG,OAAO;AAAA,MACtD,MAAM;AAAA,Q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Aa,SAAS;AAAA,IAChC,KAAK,CAAC,EAAE,KAAK,MAAM,GAAG,OAAO,UAAU,IAAI;AAAA,IAC3C,SAAS;AAAA,IACT,OAAO,QAAQ;AAAA,EACjB;AAEA,QAAM,kBAAkB,CAAC,YAAkC;AACzD,WAAO,IAAI;AAAA,MACT;AAAA,MACA,qBAAqB,MAAM;AAAA,IAC7B;AAAA,EACF;AAEA,QAAM,wBAAwB,CAAC,YAC7B,IAAI;AAAA,IACF;AAAA,IACA,qBAAqB,YAAY;AAAA,EACnC;AAEF,QAAM,2BAA2B,CAAC,YAChC,IAAI;AAAA,IACF;AAAA,IACA,qBAAqB,WAAW;AAAA,EAClC;AAEF,QAAM,mBAAmB,CAAC,YACxB,IAAI,oBAAoB,SAAS;AAAA,IAC/B,GAAG,qBAAqB,OAAO;AAAA,IAC/B,SAAS,UACL,GAAG,OAAO,eACV;AAAA,EACN,CAAC;AAEH,QAAM,WAAW,CAAC,YAAkC,gBAAgB,OAAO;AAE3E,WAAS,kBAAkB;AAC3B,WAAS,YAAY;AACrB,WAAS,QAAQ;AACjB,WAAS,aAAa;AACtB,WAAS,gBAAgB;AACzB,WAAS,qBAAqB;AAE9B,SAAO;AACT;AAEO,IAAM,YAAY,gBAAgB;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/deepinfra",
3
- "version": "1.0.0-canary.9",
3
+ "version": "1.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -19,19 +19,19 @@
19
19
  }
20
20
  },
21
21
  "dependencies": {
22
- "@ai-sdk/openai-compatible": "1.0.0-canary.9",
23
- "@ai-sdk/provider": "2.0.0-canary.8",
24
- "@ai-sdk/provider-utils": "3.0.0-canary.9"
22
+ "@ai-sdk/openai-compatible": "1.0.0",
23
+ "@ai-sdk/provider": "2.0.0",
24
+ "@ai-sdk/provider-utils": "3.0.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/node": "20.17.24",
28
28
  "tsup": "^8",
29
29
  "typescript": "5.8.3",
30
- "zod": "3.23.8",
30
+ "zod": "3.25.76",
31
31
  "@vercel/ai-tsconfig": "0.0.0"
32
32
  },
33
33
  "peerDependencies": {
34
- "zod": "^3.0.0"
34
+ "zod": "^3.25.76 || ^4"
35
35
  },
36
36
  "engines": {
37
37
  "node": ">=18"
@@ -39,7 +39,7 @@
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "homepage": "https://sdk.vercel.ai/docs",
42
+ "homepage": "https://ai-sdk.dev/docs",
43
43
  "repository": {
44
44
  "type": "git",
45
45
  "url": "git+https://github.com/vercel/ai.git"