@ai-sdk/deepinfra 1.0.0-canary.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 CHANGED
@@ -1,5 +1,571 @@
1
1
  # @ai-sdk/deepinfra
2
2
 
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [0e8ed8e]
8
+ - @ai-sdk/openai-compatible@1.0.1
9
+
10
+ ## 1.0.0
11
+
12
+ ### Major Changes
13
+
14
+ - d5f588f: AI SDK 5
15
+ - 516be5b: ### Move Image Model Settings into generate options
16
+
17
+ Image Models no longer have settings. Instead, `maxImagesPerCall` can be passed directly to `generateImage()`. All other image settings can be passed to `providerOptions[provider]`.
18
+
19
+ Before
20
+
21
+ ```js
22
+ await generateImage({
23
+ model: luma.image('photon-flash-1', {
24
+ maxImagesPerCall: 5,
25
+ pollIntervalMillis: 500,
26
+ }),
27
+ prompt,
28
+ n: 10,
29
+ });
30
+ ```
31
+
32
+ After
33
+
34
+ ```js
35
+ await generateImage({
36
+ model: luma.image('photon-flash-1'),
37
+ prompt,
38
+ n: 10,
39
+ maxImagesPerCall: 5,
40
+ providerOptions: {
41
+ luma: { pollIntervalMillis: 5 },
42
+ },
43
+ });
44
+ ```
45
+
46
+ Pull Request: https://github.com/vercel/ai/pull/6180
47
+
48
+ ### Patch Changes
49
+
50
+ - 7677477: feat (providers/deepinfra): add llama 4 models
51
+ - fa49207: feat(providers/openai-compatible): convert to providerOptions
52
+ - e2aceaf: feat: add raw chunk support
53
+ - eb173f1: chore (providers): remove model shorthand deprecation warnings
54
+ - 26735b5: chore(embedding-model): add v2 interface
55
+ - d9209ca: fix (image-model): `specificationVersion: v1` -> `v2`
56
+ - 9301f86: refactor (image-model): rename `ImageModelV1` to `ImageModelV2`
57
+ - 205077b: fix: improve Zod compatibility
58
+ - Updated dependencies [a571d6e]
59
+ - Updated dependencies [742b7be]
60
+ - Updated dependencies [e7fcc86]
61
+ - Updated dependencies [7cddb72]
62
+ - Updated dependencies [ccce59b]
63
+ - Updated dependencies [e2b9e4b]
64
+ - Updated dependencies [95857aa]
65
+ - Updated dependencies [45c1ea2]
66
+ - Updated dependencies [6f6bb89]
67
+ - Updated dependencies [060370c]
68
+ - Updated dependencies [dc714f3]
69
+ - Updated dependencies [b5da06a]
70
+ - Updated dependencies [d1a1aa1]
71
+ - Updated dependencies [63f9e9b]
72
+ - Updated dependencies [5d142ab]
73
+ - Updated dependencies [d5f588f]
74
+ - Updated dependencies [e025824]
75
+ - Updated dependencies [0571b98]
76
+ - Updated dependencies [6db02c9]
77
+ - Updated dependencies [b6b43c7]
78
+ - Updated dependencies [4fef487]
79
+ - Updated dependencies [48d257a]
80
+ - Updated dependencies [0c0c0b3]
81
+ - Updated dependencies [0d2c085]
82
+ - Updated dependencies [fa49207]
83
+ - Updated dependencies [40acf9b]
84
+ - Updated dependencies [cf8280e]
85
+ - Updated dependencies [9222aeb]
86
+ - Updated dependencies [b9a6121]
87
+ - Updated dependencies [e2aceaf]
88
+ - Updated dependencies [411e483]
89
+ - Updated dependencies [8ba77a7]
90
+ - Updated dependencies [db72adc]
91
+ - Updated dependencies [7b3ae3f]
92
+ - Updated dependencies [a166433]
93
+ - Updated dependencies [26735b5]
94
+ - Updated dependencies [443d8ec]
95
+ - Updated dependencies [42e32b0]
96
+ - Updated dependencies [a8c8bd5]
97
+ - Updated dependencies [abf9a79]
98
+ - Updated dependencies [14c9410]
99
+ - Updated dependencies [e86be6f]
100
+ - Updated dependencies [9bf7291]
101
+ - Updated dependencies [2e13791]
102
+ - Updated dependencies [7b069ed]
103
+ - Updated dependencies [9f95b35]
104
+ - Updated dependencies [66962ed]
105
+ - Updated dependencies [0d06df6]
106
+ - Updated dependencies [472524a]
107
+ - Updated dependencies [dd3ff01]
108
+ - Updated dependencies [d9209ca]
109
+ - Updated dependencies [d9c98f4]
110
+ - Updated dependencies [05d2819]
111
+ - Updated dependencies [9301f86]
112
+ - Updated dependencies [0a87932]
113
+ - Updated dependencies [737f1e2]
114
+ - Updated dependencies [c4a2fec]
115
+ - Updated dependencies [957b739]
116
+ - Updated dependencies [79457bd]
117
+ - Updated dependencies [a3f768e]
118
+ - Updated dependencies [7435eb5]
119
+ - Updated dependencies [8aa9e20]
120
+ - Updated dependencies [4617fab]
121
+ - Updated dependencies [516be5b]
122
+ - Updated dependencies [ac34802]
123
+ - Updated dependencies [0054544]
124
+ - Updated dependencies [cb68df0]
125
+ - Updated dependencies [ad80501]
126
+ - Updated dependencies [68ecf2f]
127
+ - Updated dependencies [9e9c809]
128
+ - Updated dependencies [32831c6]
129
+ - Updated dependencies [6dc848c]
130
+ - Updated dependencies [6b98118]
131
+ - Updated dependencies [d0f9495]
132
+ - Updated dependencies [63d791d]
133
+ - Updated dependencies [87b828f]
134
+ - Updated dependencies [3f2f00c]
135
+ - Updated dependencies [bfdca8d]
136
+ - Updated dependencies [0ff02bb]
137
+ - Updated dependencies [7979f7f]
138
+ - Updated dependencies [39a4fab]
139
+ - Updated dependencies [44f4aba]
140
+ - Updated dependencies [9bd5ab5]
141
+ - Updated dependencies [57edfcb]
142
+ - Updated dependencies [faf8446]
143
+ - Updated dependencies [7ea4132]
144
+ - Updated dependencies [d1a034f]
145
+ - Updated dependencies [5c56081]
146
+ - Updated dependencies [fd65bc6]
147
+ - Updated dependencies [023ba40]
148
+ - Updated dependencies [ea7a7c9]
149
+ - Updated dependencies [1b101e1]
150
+ - Updated dependencies [26535e0]
151
+ - Updated dependencies [e030615]
152
+ - Updated dependencies [5e57fae]
153
+ - Updated dependencies [393138b]
154
+ - Updated dependencies [c57e248]
155
+ - Updated dependencies [88a8ee5]
156
+ - Updated dependencies [41fa418]
157
+ - Updated dependencies [205077b]
158
+ - Updated dependencies [71f938d]
159
+ - Updated dependencies [3795467]
160
+ - Updated dependencies [28a5ed5]
161
+ - Updated dependencies [7182d14]
162
+ - Updated dependencies [c1e6647]
163
+ - Updated dependencies [1766ede]
164
+ - Updated dependencies [811dff3]
165
+ - Updated dependencies [f10304b]
166
+ - Updated dependencies [dd5fd43]
167
+ - Updated dependencies [33f4a6a]
168
+ - Updated dependencies [383cbfa]
169
+ - Updated dependencies [27deb4d]
170
+ - Updated dependencies [c4df419]
171
+ - Updated dependencies [281bb1c]
172
+ - @ai-sdk/provider-utils@3.0.0
173
+ - @ai-sdk/provider@2.0.0
174
+ - @ai-sdk/openai-compatible@1.0.0
175
+
176
+ ## 1.0.0-beta.13
177
+
178
+ ### Patch Changes
179
+
180
+ - Updated dependencies [88a8ee5]
181
+ - @ai-sdk/provider-utils@3.0.0-beta.10
182
+ - @ai-sdk/openai-compatible@1.0.0-beta.13
183
+
184
+ ## 1.0.0-beta.12
185
+
186
+ ### Patch Changes
187
+
188
+ - Updated dependencies [27deb4d]
189
+ - @ai-sdk/provider@2.0.0-beta.2
190
+ - @ai-sdk/openai-compatible@1.0.0-beta.12
191
+ - @ai-sdk/provider-utils@3.0.0-beta.9
192
+
193
+ ## 1.0.0-beta.11
194
+
195
+ ### Patch Changes
196
+
197
+ - eb173f1: chore (providers): remove model shorthand deprecation warnings
198
+ - Updated dependencies [dd5fd43]
199
+ - @ai-sdk/provider-utils@3.0.0-beta.8
200
+ - @ai-sdk/openai-compatible@1.0.0-beta.11
201
+
202
+ ## 1.0.0-beta.10
203
+
204
+ ### Patch Changes
205
+
206
+ - Updated dependencies [e7fcc86]
207
+ - @ai-sdk/provider-utils@3.0.0-beta.7
208
+ - @ai-sdk/openai-compatible@1.0.0-beta.10
209
+
210
+ ## 1.0.0-beta.9
211
+
212
+ ### Patch Changes
213
+
214
+ - Updated dependencies [737f1e2]
215
+ - Updated dependencies [ac34802]
216
+ - @ai-sdk/openai-compatible@1.0.0-beta.9
217
+ - @ai-sdk/provider-utils@3.0.0-beta.6
218
+
219
+ ## 1.0.0-beta.8
220
+
221
+ ### Patch Changes
222
+
223
+ - Updated dependencies [57edfcb]
224
+ - Updated dependencies [383cbfa]
225
+ - @ai-sdk/provider-utils@3.0.0-beta.5
226
+ - @ai-sdk/openai-compatible@1.0.0-beta.8
227
+
228
+ ## 1.0.0-beta.7
229
+
230
+ ### Patch Changes
231
+
232
+ - 205077b: fix: improve Zod compatibility
233
+ - Updated dependencies [205077b]
234
+ - @ai-sdk/openai-compatible@1.0.0-beta.7
235
+ - @ai-sdk/provider-utils@3.0.0-beta.4
236
+
237
+ ## 1.0.0-beta.6
238
+
239
+ ### Patch Changes
240
+
241
+ - Updated dependencies [281bb1c]
242
+ - @ai-sdk/openai-compatible@1.0.0-beta.6
243
+
244
+ ## 1.0.0-beta.5
245
+
246
+ ### Patch Changes
247
+
248
+ - Updated dependencies [05d2819]
249
+ - @ai-sdk/provider-utils@3.0.0-beta.3
250
+ - @ai-sdk/openai-compatible@1.0.0-beta.5
251
+
252
+ ## 1.0.0-beta.4
253
+
254
+ ### Patch Changes
255
+
256
+ - Updated dependencies [1b101e1]
257
+ - @ai-sdk/openai-compatible@1.0.0-beta.4
258
+
259
+ ## 1.0.0-beta.3
260
+
261
+ ### Patch Changes
262
+
263
+ - Updated dependencies [7b069ed]
264
+ - @ai-sdk/openai-compatible@1.0.0-beta.3
265
+
266
+ ## 1.0.0-beta.2
267
+
268
+ ### Patch Changes
269
+
270
+ - Updated dependencies [0571b98]
271
+ - Updated dependencies [39a4fab]
272
+ - Updated dependencies [d1a034f]
273
+ - @ai-sdk/provider-utils@3.0.0-beta.2
274
+ - @ai-sdk/openai-compatible@1.0.0-beta.2
275
+
276
+ ## 1.0.0-beta.1
277
+
278
+ ### Patch Changes
279
+
280
+ - Updated dependencies [742b7be]
281
+ - Updated dependencies [7cddb72]
282
+ - Updated dependencies [ccce59b]
283
+ - Updated dependencies [e2b9e4b]
284
+ - Updated dependencies [45c1ea2]
285
+ - Updated dependencies [e025824]
286
+ - Updated dependencies [0d06df6]
287
+ - Updated dependencies [472524a]
288
+ - Updated dependencies [dd3ff01]
289
+ - Updated dependencies [7435eb5]
290
+ - Updated dependencies [cb68df0]
291
+ - Updated dependencies [bfdca8d]
292
+ - Updated dependencies [44f4aba]
293
+ - Updated dependencies [023ba40]
294
+ - Updated dependencies [5e57fae]
295
+ - Updated dependencies [71f938d]
296
+ - Updated dependencies [28a5ed5]
297
+ - @ai-sdk/provider@2.0.0-beta.1
298
+ - @ai-sdk/provider-utils@3.0.0-beta.1
299
+ - @ai-sdk/openai-compatible@1.0.0-beta.1
300
+
301
+ ## 1.0.0-alpha.15
302
+
303
+ ### Patch Changes
304
+
305
+ - Updated dependencies [48d257a]
306
+ - Updated dependencies [8ba77a7]
307
+ - @ai-sdk/provider@2.0.0-alpha.15
308
+ - @ai-sdk/provider-utils@3.0.0-alpha.15
309
+ - @ai-sdk/openai-compatible@1.0.0-alpha.15
310
+
311
+ ## 1.0.0-alpha.14
312
+
313
+ ### Patch Changes
314
+
315
+ - Updated dependencies [b5da06a]
316
+ - Updated dependencies [63f9e9b]
317
+ - Updated dependencies [2e13791]
318
+ - @ai-sdk/provider@2.0.0-alpha.14
319
+ - @ai-sdk/openai-compatible@1.0.0-alpha.14
320
+ - @ai-sdk/provider-utils@3.0.0-alpha.14
321
+
322
+ ## 1.0.0-alpha.13
323
+
324
+ ### Patch Changes
325
+
326
+ - Updated dependencies [68ecf2f]
327
+ - @ai-sdk/provider@2.0.0-alpha.13
328
+ - @ai-sdk/openai-compatible@1.0.0-alpha.13
329
+ - @ai-sdk/provider-utils@3.0.0-alpha.13
330
+
331
+ ## 1.0.0-alpha.12
332
+
333
+ ### Patch Changes
334
+
335
+ - e2aceaf: feat: add raw chunk support
336
+ - Updated dependencies [e2aceaf]
337
+ - @ai-sdk/openai-compatible@1.0.0-alpha.12
338
+ - @ai-sdk/provider@2.0.0-alpha.12
339
+ - @ai-sdk/provider-utils@3.0.0-alpha.12
340
+
341
+ ## 1.0.0-alpha.11
342
+
343
+ ### Patch Changes
344
+
345
+ - Updated dependencies [c1e6647]
346
+ - @ai-sdk/provider@2.0.0-alpha.11
347
+ - @ai-sdk/openai-compatible@1.0.0-alpha.11
348
+ - @ai-sdk/provider-utils@3.0.0-alpha.11
349
+
350
+ ## 1.0.0-alpha.10
351
+
352
+ ### Patch Changes
353
+
354
+ - Updated dependencies [c4df419]
355
+ - @ai-sdk/provider@2.0.0-alpha.10
356
+ - @ai-sdk/openai-compatible@1.0.0-alpha.10
357
+ - @ai-sdk/provider-utils@3.0.0-alpha.10
358
+
359
+ ## 1.0.0-alpha.9
360
+
361
+ ### Patch Changes
362
+
363
+ - Updated dependencies [811dff3]
364
+ - @ai-sdk/provider@2.0.0-alpha.9
365
+ - @ai-sdk/openai-compatible@1.0.0-alpha.9
366
+ - @ai-sdk/provider-utils@3.0.0-alpha.9
367
+
368
+ ## 1.0.0-alpha.8
369
+
370
+ ### Patch Changes
371
+
372
+ - Updated dependencies [4fef487]
373
+ - Updated dependencies [9222aeb]
374
+ - @ai-sdk/provider-utils@3.0.0-alpha.8
375
+ - @ai-sdk/provider@2.0.0-alpha.8
376
+ - @ai-sdk/openai-compatible@1.0.0-alpha.8
377
+
378
+ ## 1.0.0-alpha.7
379
+
380
+ ### Patch Changes
381
+
382
+ - Updated dependencies [5c56081]
383
+ - @ai-sdk/provider@2.0.0-alpha.7
384
+ - @ai-sdk/openai-compatible@1.0.0-alpha.7
385
+ - @ai-sdk/provider-utils@3.0.0-alpha.7
386
+
387
+ ## 1.0.0-alpha.6
388
+
389
+ ### Patch Changes
390
+
391
+ - Updated dependencies [0d2c085]
392
+ - @ai-sdk/provider@2.0.0-alpha.6
393
+ - @ai-sdk/openai-compatible@1.0.0-alpha.6
394
+ - @ai-sdk/provider-utils@3.0.0-alpha.6
395
+
396
+ ## 1.0.0-alpha.4
397
+
398
+ ### Patch Changes
399
+
400
+ - Updated dependencies [dc714f3]
401
+ - @ai-sdk/provider@2.0.0-alpha.4
402
+ - @ai-sdk/openai-compatible@1.0.0-alpha.4
403
+ - @ai-sdk/provider-utils@3.0.0-alpha.4
404
+
405
+ ## 1.0.0-alpha.3
406
+
407
+ ### Patch Changes
408
+
409
+ - Updated dependencies [6b98118]
410
+ - @ai-sdk/provider@2.0.0-alpha.3
411
+ - @ai-sdk/openai-compatible@1.0.0-alpha.3
412
+ - @ai-sdk/provider-utils@3.0.0-alpha.3
413
+
414
+ ## 1.0.0-alpha.2
415
+
416
+ ### Patch Changes
417
+
418
+ - Updated dependencies [26535e0]
419
+ - @ai-sdk/provider@2.0.0-alpha.2
420
+ - @ai-sdk/openai-compatible@1.0.0-alpha.2
421
+ - @ai-sdk/provider-utils@3.0.0-alpha.2
422
+
423
+ ## 1.0.0-alpha.1
424
+
425
+ ### Patch Changes
426
+
427
+ - Updated dependencies [3f2f00c]
428
+ - @ai-sdk/provider@2.0.0-alpha.1
429
+ - @ai-sdk/openai-compatible@1.0.0-alpha.1
430
+ - @ai-sdk/provider-utils@3.0.0-alpha.1
431
+
432
+ ## 1.0.0-canary.19
433
+
434
+ ### Patch Changes
435
+
436
+ - Updated dependencies [faf8446]
437
+ - @ai-sdk/provider-utils@3.0.0-canary.19
438
+ - @ai-sdk/openai-compatible@1.0.0-canary.19
439
+
440
+ ## 1.0.0-canary.18
441
+
442
+ ### Patch Changes
443
+
444
+ - Updated dependencies [40acf9b]
445
+ - @ai-sdk/provider-utils@3.0.0-canary.18
446
+ - @ai-sdk/openai-compatible@1.0.0-canary.18
447
+
448
+ ## 1.0.0-canary.17
449
+
450
+ ### Major Changes
451
+
452
+ - 516be5b: ### Move Image Model Settings into generate options
453
+
454
+ Image Models no longer have settings. Instead, `maxImagesPerCall` can be passed directly to `generateImage()`. All other image settings can be passed to `providerOptions[provider]`.
455
+
456
+ Before
457
+
458
+ ```js
459
+ await generateImage({
460
+ model: luma.image('photon-flash-1', {
461
+ maxImagesPerCall: 5,
462
+ pollIntervalMillis: 500,
463
+ }),
464
+ prompt,
465
+ n: 10,
466
+ });
467
+ ```
468
+
469
+ After
470
+
471
+ ```js
472
+ await generateImage({
473
+ model: luma.image('photon-flash-1'),
474
+ prompt,
475
+ n: 10,
476
+ maxImagesPerCall: 5,
477
+ providerOptions: {
478
+ luma: { pollIntervalMillis: 5 },
479
+ },
480
+ });
481
+ ```
482
+
483
+ Pull Request: https://github.com/vercel/ai/pull/6180
484
+
485
+ ### Patch Changes
486
+
487
+ - Updated dependencies [516be5b]
488
+ - Updated dependencies [ea7a7c9]
489
+ - @ai-sdk/openai-compatible@1.0.0-canary.17
490
+ - @ai-sdk/provider-utils@3.0.0-canary.17
491
+
492
+ ## 1.0.0-canary.16
493
+
494
+ ### Patch Changes
495
+
496
+ - Updated dependencies [87b828f]
497
+ - @ai-sdk/provider-utils@3.0.0-canary.16
498
+ - @ai-sdk/openai-compatible@1.0.0-canary.16
499
+
500
+ ## 1.0.0-canary.15
501
+
502
+ ### Patch Changes
503
+
504
+ - Updated dependencies [a571d6e]
505
+ - Updated dependencies [a8c8bd5]
506
+ - Updated dependencies [7979f7f]
507
+ - Updated dependencies [41fa418]
508
+ - @ai-sdk/provider-utils@3.0.0-canary.15
509
+ - @ai-sdk/provider@2.0.0-canary.14
510
+ - @ai-sdk/openai-compatible@1.0.0-canary.15
511
+
512
+ ## 1.0.0-canary.14
513
+
514
+ ### Patch Changes
515
+
516
+ - Updated dependencies [957b739]
517
+ - Updated dependencies [9bd5ab5]
518
+ - @ai-sdk/provider-utils@3.0.0-canary.14
519
+ - @ai-sdk/provider@2.0.0-canary.13
520
+ - @ai-sdk/openai-compatible@1.0.0-canary.14
521
+
522
+ ## 1.0.0-canary.13
523
+
524
+ ### Patch Changes
525
+
526
+ - d9209ca: fix (image-model): `specificationVersion: v1` -> `v2`
527
+ - Updated dependencies [7b3ae3f]
528
+ - Updated dependencies [d9209ca]
529
+ - Updated dependencies [0ff02bb]
530
+ - @ai-sdk/provider@2.0.0-canary.12
531
+ - @ai-sdk/openai-compatible@1.0.0-canary.13
532
+ - @ai-sdk/provider-utils@3.0.0-canary.13
533
+
534
+ ## 1.0.0-canary.12
535
+
536
+ ### Patch Changes
537
+
538
+ - Updated dependencies [9bf7291]
539
+ - Updated dependencies [4617fab]
540
+ - Updated dependencies [e030615]
541
+ - @ai-sdk/provider@2.0.0-canary.11
542
+ - @ai-sdk/openai-compatible@1.0.0-canary.12
543
+ - @ai-sdk/provider-utils@3.0.0-canary.12
544
+
545
+ ## 1.0.0-canary.11
546
+
547
+ ### Patch Changes
548
+
549
+ - 9301f86: refactor (image-model): rename `ImageModelV1` to `ImageModelV2`
550
+ - Updated dependencies [db72adc]
551
+ - Updated dependencies [42e32b0]
552
+ - Updated dependencies [66962ed]
553
+ - Updated dependencies [9301f86]
554
+ - Updated dependencies [a3f768e]
555
+ - @ai-sdk/openai-compatible@1.0.0-canary.11
556
+ - @ai-sdk/provider-utils@3.0.0-canary.11
557
+ - @ai-sdk/provider@2.0.0-canary.10
558
+
559
+ ## 1.0.0-canary.10
560
+
561
+ ### Patch Changes
562
+
563
+ - Updated dependencies [cf8280e]
564
+ - Updated dependencies [e86be6f]
565
+ - @ai-sdk/openai-compatible@1.0.0-canary.10
566
+ - @ai-sdk/provider@2.0.0-canary.9
567
+ - @ai-sdk/provider-utils@3.0.0-canary.10
568
+
3
569
  ## 1.0.0-canary.9
4
570
 
5
571
  ### 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,Q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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,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;A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AAEO,IAAM,YAAY,gBAAgB;","names":["import_provider_utils"]}
package/dist/index.mjs CHANGED
@@ -16,21 +16,17 @@ import {
16
16
  createJsonResponseHandler,
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;;;ACd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M,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":[]}
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,OA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ACf,CAAC,CAAC;AAAA,IACF,GAAG,QAAQ;AAAA,EACb;AASA,QAAM,uBAAuB,CAAC,eAA0C;AAAA,IACtE,UAAU,aAAa,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.1",
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.1",
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"