@ai-sdk/deepinfra 2.0.0-beta.60 → 2.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 +88 -235
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,56 @@
|
|
|
1
1
|
# @ai-sdk/deepinfra
|
|
2
2
|
|
|
3
|
+
## 2.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [29264a3]
|
|
8
|
+
- @ai-sdk/provider-utils@4.0.1
|
|
9
|
+
- @ai-sdk/openai-compatible@2.0.1
|
|
10
|
+
|
|
11
|
+
## 2.0.0
|
|
12
|
+
|
|
13
|
+
### Major Changes
|
|
14
|
+
|
|
15
|
+
- dee8b05: ai SDK 6 beta
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 78928cb: release: start 5.1 beta
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- 0c3b58b: fix(provider): add specificationVersion to ProviderV3
|
|
24
|
+
- 8d9e8ad: chore(provider): remove generics from EmbeddingModelV3
|
|
25
|
+
|
|
26
|
+
Before
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
model.textEmbeddingModel('my-model-id');
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
After
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
model.embeddingModel('my-model-id');
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
- 95f65c2: chore: use import \* from zod/v4
|
|
39
|
+
- 0c4822d: feat: `EmbeddingModelV3`
|
|
40
|
+
- ed329cb: feat: `Provider-V3`
|
|
41
|
+
- 1cad0ab: feat: add provider version to user-agent header
|
|
42
|
+
- 8dac895: feat: `LanguageModelV3`
|
|
43
|
+
- 457318b: chore(provider,ai): switch to SharedV3Warning and unified warnings
|
|
44
|
+
- 9061dc0: feat: image editing
|
|
45
|
+
- 366f50b: chore(provider): add deprecated textEmbeddingModel and textEmbedding aliases
|
|
46
|
+
- 4616b86: chore: update zod peer depenedency version
|
|
47
|
+
- 522f6b8: feat: `ImageModelV3`
|
|
48
|
+
- 10c1322: fix: moved dependency `@ai-sdk/test-server` to devDependencies
|
|
49
|
+
- Updated dependencies
|
|
50
|
+
- @ai-sdk/openai-compatible@2.0.0
|
|
51
|
+
- @ai-sdk/provider@3.0.0
|
|
52
|
+
- @ai-sdk/provider-utils@4.0.0
|
|
53
|
+
|
|
3
54
|
## 2.0.0-beta.60
|
|
4
55
|
|
|
5
56
|
### Patch Changes
|
|
@@ -440,8 +491,7 @@
|
|
|
440
491
|
### Patch Changes
|
|
441
492
|
|
|
442
493
|
- 95f65c2: chore: use import \* from zod/v4
|
|
443
|
-
- Updated dependencies
|
|
444
|
-
- Updated dependencies [95f65c2]
|
|
494
|
+
- Updated dependencies
|
|
445
495
|
- @ai-sdk/openai-compatible@2.0.0-beta.11
|
|
446
496
|
- @ai-sdk/provider-utils@4.0.0-beta.11
|
|
447
497
|
|
|
@@ -478,8 +528,7 @@
|
|
|
478
528
|
|
|
479
529
|
### Patch Changes
|
|
480
530
|
|
|
481
|
-
- Updated dependencies
|
|
482
|
-
- Updated dependencies [e8109d3]
|
|
531
|
+
- Updated dependencies
|
|
483
532
|
- @ai-sdk/provider@2.1.0-beta.5
|
|
484
533
|
- @ai-sdk/openai-compatible@1.1.0-beta.7
|
|
485
534
|
- @ai-sdk/provider-utils@3.1.0-beta.7
|
|
@@ -488,8 +537,7 @@
|
|
|
488
537
|
|
|
489
538
|
### Patch Changes
|
|
490
539
|
|
|
491
|
-
- Updated dependencies
|
|
492
|
-
- Updated dependencies [2b0caef]
|
|
540
|
+
- Updated dependencies
|
|
493
541
|
- @ai-sdk/openai-compatible@1.1.0-beta.6
|
|
494
542
|
- @ai-sdk/provider-utils@3.1.0-beta.6
|
|
495
543
|
- @ai-sdk/provider@2.1.0-beta.4
|
|
@@ -500,8 +548,7 @@
|
|
|
500
548
|
|
|
501
549
|
- 8dac895: feat: `LanguageModelV3`
|
|
502
550
|
- 10c1322: fix: moved dependency `@ai-sdk/test-server` to devDependencies
|
|
503
|
-
- Updated dependencies
|
|
504
|
-
- Updated dependencies [10c1322]
|
|
551
|
+
- Updated dependencies
|
|
505
552
|
- @ai-sdk/openai-compatible@1.1.0-beta.5
|
|
506
553
|
- @ai-sdk/provider-utils@3.1.0-beta.5
|
|
507
554
|
- @ai-sdk/provider@2.1.0-beta.3
|
|
@@ -521,8 +568,7 @@
|
|
|
521
568
|
|
|
522
569
|
- ed329cb: feat: `Provider-V3`
|
|
523
570
|
- 522f6b8: feat: `ImageModelV3`
|
|
524
|
-
- Updated dependencies
|
|
525
|
-
- Updated dependencies [522f6b8]
|
|
571
|
+
- Updated dependencies
|
|
526
572
|
- @ai-sdk/openai-compatible@1.1.0-beta.3
|
|
527
573
|
- @ai-sdk/provider@2.1.0-beta.2
|
|
528
574
|
- @ai-sdk/provider-utils@3.1.0-beta.3
|
|
@@ -542,8 +588,7 @@
|
|
|
542
588
|
|
|
543
589
|
### Patch Changes
|
|
544
590
|
|
|
545
|
-
- Updated dependencies
|
|
546
|
-
- Updated dependencies [cbb1d35]
|
|
591
|
+
- Updated dependencies
|
|
547
592
|
- @ai-sdk/test-server@1.0.0-beta.0
|
|
548
593
|
- @ai-sdk/provider-utils@3.1.0-beta.1
|
|
549
594
|
- @ai-sdk/openai-compatible@1.1.0-beta.1
|
|
@@ -648,8 +693,7 @@
|
|
|
648
693
|
|
|
649
694
|
### Patch Changes
|
|
650
695
|
|
|
651
|
-
- Updated dependencies
|
|
652
|
-
- Updated dependencies [f25040d]
|
|
696
|
+
- Updated dependencies
|
|
653
697
|
- @ai-sdk/provider-utils@3.0.3
|
|
654
698
|
- @ai-sdk/openai-compatible@1.0.7
|
|
655
699
|
|
|
@@ -665,16 +709,14 @@
|
|
|
665
709
|
|
|
666
710
|
### Patch Changes
|
|
667
711
|
|
|
668
|
-
- Updated dependencies
|
|
669
|
-
- Updated dependencies [e92b78b]
|
|
712
|
+
- Updated dependencies
|
|
670
713
|
- @ai-sdk/openai-compatible@1.0.5
|
|
671
714
|
|
|
672
715
|
## 1.0.4
|
|
673
716
|
|
|
674
717
|
### Patch Changes
|
|
675
718
|
|
|
676
|
-
- Updated dependencies
|
|
677
|
-
- Updated dependencies [da314cd]
|
|
719
|
+
- Updated dependencies
|
|
678
720
|
- @ai-sdk/openai-compatible@1.0.4
|
|
679
721
|
|
|
680
722
|
## 1.0.3
|
|
@@ -688,8 +730,7 @@
|
|
|
688
730
|
|
|
689
731
|
### Patch Changes
|
|
690
732
|
|
|
691
|
-
- Updated dependencies
|
|
692
|
-
- Updated dependencies [90d212f]
|
|
733
|
+
- Updated dependencies
|
|
693
734
|
- @ai-sdk/openai-compatible@1.0.2
|
|
694
735
|
- @ai-sdk/provider-utils@3.0.1
|
|
695
736
|
|
|
@@ -748,120 +789,7 @@
|
|
|
748
789
|
- d9209ca: fix (image-model): `specificationVersion: v1` -> `v2`
|
|
749
790
|
- 9301f86: refactor (image-model): rename `ImageModelV1` to `ImageModelV2`
|
|
750
791
|
- 205077b: fix: improve Zod compatibility
|
|
751
|
-
- Updated dependencies
|
|
752
|
-
- Updated dependencies [742b7be]
|
|
753
|
-
- Updated dependencies [e7fcc86]
|
|
754
|
-
- Updated dependencies [7cddb72]
|
|
755
|
-
- Updated dependencies [ccce59b]
|
|
756
|
-
- Updated dependencies [e2b9e4b]
|
|
757
|
-
- Updated dependencies [95857aa]
|
|
758
|
-
- Updated dependencies [45c1ea2]
|
|
759
|
-
- Updated dependencies [6f6bb89]
|
|
760
|
-
- Updated dependencies [060370c]
|
|
761
|
-
- Updated dependencies [dc714f3]
|
|
762
|
-
- Updated dependencies [b5da06a]
|
|
763
|
-
- Updated dependencies [d1a1aa1]
|
|
764
|
-
- Updated dependencies [63f9e9b]
|
|
765
|
-
- Updated dependencies [5d142ab]
|
|
766
|
-
- Updated dependencies [d5f588f]
|
|
767
|
-
- Updated dependencies [e025824]
|
|
768
|
-
- Updated dependencies [0571b98]
|
|
769
|
-
- Updated dependencies [6db02c9]
|
|
770
|
-
- Updated dependencies [b6b43c7]
|
|
771
|
-
- Updated dependencies [4fef487]
|
|
772
|
-
- Updated dependencies [48d257a]
|
|
773
|
-
- Updated dependencies [0c0c0b3]
|
|
774
|
-
- Updated dependencies [0d2c085]
|
|
775
|
-
- Updated dependencies [fa49207]
|
|
776
|
-
- Updated dependencies [40acf9b]
|
|
777
|
-
- Updated dependencies [cf8280e]
|
|
778
|
-
- Updated dependencies [9222aeb]
|
|
779
|
-
- Updated dependencies [b9a6121]
|
|
780
|
-
- Updated dependencies [e2aceaf]
|
|
781
|
-
- Updated dependencies [411e483]
|
|
782
|
-
- Updated dependencies [8ba77a7]
|
|
783
|
-
- Updated dependencies [db72adc]
|
|
784
|
-
- Updated dependencies [7b3ae3f]
|
|
785
|
-
- Updated dependencies [a166433]
|
|
786
|
-
- Updated dependencies [26735b5]
|
|
787
|
-
- Updated dependencies [443d8ec]
|
|
788
|
-
- Updated dependencies [42e32b0]
|
|
789
|
-
- Updated dependencies [a8c8bd5]
|
|
790
|
-
- Updated dependencies [abf9a79]
|
|
791
|
-
- Updated dependencies [14c9410]
|
|
792
|
-
- Updated dependencies [e86be6f]
|
|
793
|
-
- Updated dependencies [9bf7291]
|
|
794
|
-
- Updated dependencies [2e13791]
|
|
795
|
-
- Updated dependencies [7b069ed]
|
|
796
|
-
- Updated dependencies [9f95b35]
|
|
797
|
-
- Updated dependencies [66962ed]
|
|
798
|
-
- Updated dependencies [0d06df6]
|
|
799
|
-
- Updated dependencies [472524a]
|
|
800
|
-
- Updated dependencies [dd3ff01]
|
|
801
|
-
- Updated dependencies [d9209ca]
|
|
802
|
-
- Updated dependencies [d9c98f4]
|
|
803
|
-
- Updated dependencies [05d2819]
|
|
804
|
-
- Updated dependencies [9301f86]
|
|
805
|
-
- Updated dependencies [0a87932]
|
|
806
|
-
- Updated dependencies [737f1e2]
|
|
807
|
-
- Updated dependencies [c4a2fec]
|
|
808
|
-
- Updated dependencies [957b739]
|
|
809
|
-
- Updated dependencies [79457bd]
|
|
810
|
-
- Updated dependencies [a3f768e]
|
|
811
|
-
- Updated dependencies [7435eb5]
|
|
812
|
-
- Updated dependencies [8aa9e20]
|
|
813
|
-
- Updated dependencies [4617fab]
|
|
814
|
-
- Updated dependencies [516be5b]
|
|
815
|
-
- Updated dependencies [ac34802]
|
|
816
|
-
- Updated dependencies [0054544]
|
|
817
|
-
- Updated dependencies [cb68df0]
|
|
818
|
-
- Updated dependencies [ad80501]
|
|
819
|
-
- Updated dependencies [68ecf2f]
|
|
820
|
-
- Updated dependencies [9e9c809]
|
|
821
|
-
- Updated dependencies [32831c6]
|
|
822
|
-
- Updated dependencies [6dc848c]
|
|
823
|
-
- Updated dependencies [6b98118]
|
|
824
|
-
- Updated dependencies [d0f9495]
|
|
825
|
-
- Updated dependencies [63d791d]
|
|
826
|
-
- Updated dependencies [87b828f]
|
|
827
|
-
- Updated dependencies [3f2f00c]
|
|
828
|
-
- Updated dependencies [bfdca8d]
|
|
829
|
-
- Updated dependencies [0ff02bb]
|
|
830
|
-
- Updated dependencies [7979f7f]
|
|
831
|
-
- Updated dependencies [39a4fab]
|
|
832
|
-
- Updated dependencies [44f4aba]
|
|
833
|
-
- Updated dependencies [9bd5ab5]
|
|
834
|
-
- Updated dependencies [57edfcb]
|
|
835
|
-
- Updated dependencies [faf8446]
|
|
836
|
-
- Updated dependencies [7ea4132]
|
|
837
|
-
- Updated dependencies [d1a034f]
|
|
838
|
-
- Updated dependencies [5c56081]
|
|
839
|
-
- Updated dependencies [fd65bc6]
|
|
840
|
-
- Updated dependencies [023ba40]
|
|
841
|
-
- Updated dependencies [ea7a7c9]
|
|
842
|
-
- Updated dependencies [1b101e1]
|
|
843
|
-
- Updated dependencies [26535e0]
|
|
844
|
-
- Updated dependencies [e030615]
|
|
845
|
-
- Updated dependencies [5e57fae]
|
|
846
|
-
- Updated dependencies [393138b]
|
|
847
|
-
- Updated dependencies [c57e248]
|
|
848
|
-
- Updated dependencies [88a8ee5]
|
|
849
|
-
- Updated dependencies [41fa418]
|
|
850
|
-
- Updated dependencies [205077b]
|
|
851
|
-
- Updated dependencies [71f938d]
|
|
852
|
-
- Updated dependencies [3795467]
|
|
853
|
-
- Updated dependencies [28a5ed5]
|
|
854
|
-
- Updated dependencies [7182d14]
|
|
855
|
-
- Updated dependencies [c1e6647]
|
|
856
|
-
- Updated dependencies [1766ede]
|
|
857
|
-
- Updated dependencies [811dff3]
|
|
858
|
-
- Updated dependencies [f10304b]
|
|
859
|
-
- Updated dependencies [dd5fd43]
|
|
860
|
-
- Updated dependencies [33f4a6a]
|
|
861
|
-
- Updated dependencies [383cbfa]
|
|
862
|
-
- Updated dependencies [27deb4d]
|
|
863
|
-
- Updated dependencies [c4df419]
|
|
864
|
-
- Updated dependencies [281bb1c]
|
|
792
|
+
- Updated dependencies
|
|
865
793
|
- @ai-sdk/provider-utils@3.0.0
|
|
866
794
|
- @ai-sdk/provider@2.0.0
|
|
867
795
|
- @ai-sdk/openai-compatible@1.0.0
|
|
@@ -904,8 +832,7 @@
|
|
|
904
832
|
|
|
905
833
|
### Patch Changes
|
|
906
834
|
|
|
907
|
-
- Updated dependencies
|
|
908
|
-
- Updated dependencies [ac34802]
|
|
835
|
+
- Updated dependencies
|
|
909
836
|
- @ai-sdk/openai-compatible@1.0.0-beta.9
|
|
910
837
|
- @ai-sdk/provider-utils@3.0.0-beta.6
|
|
911
838
|
|
|
@@ -913,8 +840,7 @@
|
|
|
913
840
|
|
|
914
841
|
### Patch Changes
|
|
915
842
|
|
|
916
|
-
- Updated dependencies
|
|
917
|
-
- Updated dependencies [383cbfa]
|
|
843
|
+
- Updated dependencies
|
|
918
844
|
- @ai-sdk/provider-utils@3.0.0-beta.5
|
|
919
845
|
- @ai-sdk/openai-compatible@1.0.0-beta.8
|
|
920
846
|
|
|
@@ -960,9 +886,7 @@
|
|
|
960
886
|
|
|
961
887
|
### Patch Changes
|
|
962
888
|
|
|
963
|
-
- Updated dependencies
|
|
964
|
-
- Updated dependencies [39a4fab]
|
|
965
|
-
- Updated dependencies [d1a034f]
|
|
889
|
+
- Updated dependencies
|
|
966
890
|
- @ai-sdk/provider-utils@3.0.0-beta.2
|
|
967
891
|
- @ai-sdk/openai-compatible@1.0.0-beta.2
|
|
968
892
|
|
|
@@ -970,23 +894,7 @@
|
|
|
970
894
|
|
|
971
895
|
### Patch Changes
|
|
972
896
|
|
|
973
|
-
- Updated dependencies
|
|
974
|
-
- Updated dependencies [7cddb72]
|
|
975
|
-
- Updated dependencies [ccce59b]
|
|
976
|
-
- Updated dependencies [e2b9e4b]
|
|
977
|
-
- Updated dependencies [45c1ea2]
|
|
978
|
-
- Updated dependencies [e025824]
|
|
979
|
-
- Updated dependencies [0d06df6]
|
|
980
|
-
- Updated dependencies [472524a]
|
|
981
|
-
- Updated dependencies [dd3ff01]
|
|
982
|
-
- Updated dependencies [7435eb5]
|
|
983
|
-
- Updated dependencies [cb68df0]
|
|
984
|
-
- Updated dependencies [bfdca8d]
|
|
985
|
-
- Updated dependencies [44f4aba]
|
|
986
|
-
- Updated dependencies [023ba40]
|
|
987
|
-
- Updated dependencies [5e57fae]
|
|
988
|
-
- Updated dependencies [71f938d]
|
|
989
|
-
- Updated dependencies [28a5ed5]
|
|
897
|
+
- Updated dependencies
|
|
990
898
|
- @ai-sdk/provider@2.0.0-beta.1
|
|
991
899
|
- @ai-sdk/provider-utils@3.0.0-beta.1
|
|
992
900
|
- @ai-sdk/openai-compatible@1.0.0-beta.1
|
|
@@ -995,8 +903,7 @@
|
|
|
995
903
|
|
|
996
904
|
### Patch Changes
|
|
997
905
|
|
|
998
|
-
- Updated dependencies
|
|
999
|
-
- Updated dependencies [8ba77a7]
|
|
906
|
+
- Updated dependencies
|
|
1000
907
|
- @ai-sdk/provider@2.0.0-alpha.15
|
|
1001
908
|
- @ai-sdk/provider-utils@3.0.0-alpha.15
|
|
1002
909
|
- @ai-sdk/openai-compatible@1.0.0-alpha.15
|
|
@@ -1005,9 +912,7 @@
|
|
|
1005
912
|
|
|
1006
913
|
### Patch Changes
|
|
1007
914
|
|
|
1008
|
-
- Updated dependencies
|
|
1009
|
-
- Updated dependencies [63f9e9b]
|
|
1010
|
-
- Updated dependencies [2e13791]
|
|
915
|
+
- Updated dependencies
|
|
1011
916
|
- @ai-sdk/provider@2.0.0-alpha.14
|
|
1012
917
|
- @ai-sdk/openai-compatible@1.0.0-alpha.14
|
|
1013
918
|
- @ai-sdk/provider-utils@3.0.0-alpha.14
|
|
@@ -1062,8 +967,7 @@
|
|
|
1062
967
|
|
|
1063
968
|
### Patch Changes
|
|
1064
969
|
|
|
1065
|
-
- Updated dependencies
|
|
1066
|
-
- Updated dependencies [9222aeb]
|
|
970
|
+
- Updated dependencies
|
|
1067
971
|
- @ai-sdk/provider-utils@3.0.0-alpha.8
|
|
1068
972
|
- @ai-sdk/provider@2.0.0-alpha.8
|
|
1069
973
|
- @ai-sdk/openai-compatible@1.0.0-alpha.8
|
|
@@ -1177,8 +1081,7 @@
|
|
|
1177
1081
|
|
|
1178
1082
|
### Patch Changes
|
|
1179
1083
|
|
|
1180
|
-
- Updated dependencies
|
|
1181
|
-
- Updated dependencies [ea7a7c9]
|
|
1084
|
+
- Updated dependencies
|
|
1182
1085
|
- @ai-sdk/openai-compatible@1.0.0-canary.17
|
|
1183
1086
|
- @ai-sdk/provider-utils@3.0.0-canary.17
|
|
1184
1087
|
|
|
@@ -1194,10 +1097,7 @@
|
|
|
1194
1097
|
|
|
1195
1098
|
### Patch Changes
|
|
1196
1099
|
|
|
1197
|
-
- Updated dependencies
|
|
1198
|
-
- Updated dependencies [a8c8bd5]
|
|
1199
|
-
- Updated dependencies [7979f7f]
|
|
1200
|
-
- Updated dependencies [41fa418]
|
|
1100
|
+
- Updated dependencies
|
|
1201
1101
|
- @ai-sdk/provider-utils@3.0.0-canary.15
|
|
1202
1102
|
- @ai-sdk/provider@2.0.0-canary.14
|
|
1203
1103
|
- @ai-sdk/openai-compatible@1.0.0-canary.15
|
|
@@ -1206,8 +1106,7 @@
|
|
|
1206
1106
|
|
|
1207
1107
|
### Patch Changes
|
|
1208
1108
|
|
|
1209
|
-
- Updated dependencies
|
|
1210
|
-
- Updated dependencies [9bd5ab5]
|
|
1109
|
+
- Updated dependencies
|
|
1211
1110
|
- @ai-sdk/provider-utils@3.0.0-canary.14
|
|
1212
1111
|
- @ai-sdk/provider@2.0.0-canary.13
|
|
1213
1112
|
- @ai-sdk/openai-compatible@1.0.0-canary.14
|
|
@@ -1217,9 +1116,7 @@
|
|
|
1217
1116
|
### Patch Changes
|
|
1218
1117
|
|
|
1219
1118
|
- d9209ca: fix (image-model): `specificationVersion: v1` -> `v2`
|
|
1220
|
-
- Updated dependencies
|
|
1221
|
-
- Updated dependencies [d9209ca]
|
|
1222
|
-
- Updated dependencies [0ff02bb]
|
|
1119
|
+
- Updated dependencies
|
|
1223
1120
|
- @ai-sdk/provider@2.0.0-canary.12
|
|
1224
1121
|
- @ai-sdk/openai-compatible@1.0.0-canary.13
|
|
1225
1122
|
- @ai-sdk/provider-utils@3.0.0-canary.13
|
|
@@ -1228,9 +1125,7 @@
|
|
|
1228
1125
|
|
|
1229
1126
|
### Patch Changes
|
|
1230
1127
|
|
|
1231
|
-
- Updated dependencies
|
|
1232
|
-
- Updated dependencies [4617fab]
|
|
1233
|
-
- Updated dependencies [e030615]
|
|
1128
|
+
- Updated dependencies
|
|
1234
1129
|
- @ai-sdk/provider@2.0.0-canary.11
|
|
1235
1130
|
- @ai-sdk/openai-compatible@1.0.0-canary.12
|
|
1236
1131
|
- @ai-sdk/provider-utils@3.0.0-canary.12
|
|
@@ -1240,11 +1135,7 @@
|
|
|
1240
1135
|
### Patch Changes
|
|
1241
1136
|
|
|
1242
1137
|
- 9301f86: refactor (image-model): rename `ImageModelV1` to `ImageModelV2`
|
|
1243
|
-
- Updated dependencies
|
|
1244
|
-
- Updated dependencies [42e32b0]
|
|
1245
|
-
- Updated dependencies [66962ed]
|
|
1246
|
-
- Updated dependencies [9301f86]
|
|
1247
|
-
- Updated dependencies [a3f768e]
|
|
1138
|
+
- Updated dependencies
|
|
1248
1139
|
- @ai-sdk/openai-compatible@1.0.0-canary.11
|
|
1249
1140
|
- @ai-sdk/provider-utils@3.0.0-canary.11
|
|
1250
1141
|
- @ai-sdk/provider@2.0.0-canary.10
|
|
@@ -1253,8 +1144,7 @@
|
|
|
1253
1144
|
|
|
1254
1145
|
### Patch Changes
|
|
1255
1146
|
|
|
1256
|
-
- Updated dependencies
|
|
1257
|
-
- Updated dependencies [e86be6f]
|
|
1147
|
+
- Updated dependencies
|
|
1258
1148
|
- @ai-sdk/openai-compatible@1.0.0-canary.10
|
|
1259
1149
|
- @ai-sdk/provider@2.0.0-canary.9
|
|
1260
1150
|
- @ai-sdk/provider-utils@3.0.0-canary.10
|
|
@@ -1263,8 +1153,7 @@
|
|
|
1263
1153
|
|
|
1264
1154
|
### Patch Changes
|
|
1265
1155
|
|
|
1266
|
-
- Updated dependencies
|
|
1267
|
-
- Updated dependencies [7ea4132]
|
|
1156
|
+
- Updated dependencies
|
|
1268
1157
|
- @ai-sdk/provider@2.0.0-canary.8
|
|
1269
1158
|
- @ai-sdk/openai-compatible@1.0.0-canary.9
|
|
1270
1159
|
- @ai-sdk/provider-utils@3.0.0-canary.9
|
|
@@ -1273,11 +1162,7 @@
|
|
|
1273
1162
|
|
|
1274
1163
|
### Patch Changes
|
|
1275
1164
|
|
|
1276
|
-
- Updated dependencies
|
|
1277
|
-
- Updated dependencies [b6b43c7]
|
|
1278
|
-
- Updated dependencies [b9a6121]
|
|
1279
|
-
- Updated dependencies [8aa9e20]
|
|
1280
|
-
- Updated dependencies [3795467]
|
|
1165
|
+
- Updated dependencies
|
|
1281
1166
|
- @ai-sdk/provider-utils@3.0.0-canary.8
|
|
1282
1167
|
- @ai-sdk/provider@2.0.0-canary.7
|
|
1283
1168
|
- @ai-sdk/openai-compatible@1.0.0-canary.8
|
|
@@ -1288,19 +1173,7 @@
|
|
|
1288
1173
|
|
|
1289
1174
|
- fa49207: feat(providers/openai-compatible): convert to providerOptions
|
|
1290
1175
|
- 26735b5: chore(embedding-model): add v2 interface
|
|
1291
|
-
- Updated dependencies
|
|
1292
|
-
- Updated dependencies [26735b5]
|
|
1293
|
-
- Updated dependencies [443d8ec]
|
|
1294
|
-
- Updated dependencies [14c9410]
|
|
1295
|
-
- Updated dependencies [d9c98f4]
|
|
1296
|
-
- Updated dependencies [c4a2fec]
|
|
1297
|
-
- Updated dependencies [0054544]
|
|
1298
|
-
- Updated dependencies [9e9c809]
|
|
1299
|
-
- Updated dependencies [32831c6]
|
|
1300
|
-
- Updated dependencies [d0f9495]
|
|
1301
|
-
- Updated dependencies [fd65bc6]
|
|
1302
|
-
- Updated dependencies [393138b]
|
|
1303
|
-
- Updated dependencies [7182d14]
|
|
1176
|
+
- Updated dependencies
|
|
1304
1177
|
- @ai-sdk/openai-compatible@1.0.0-canary.7
|
|
1305
1178
|
- @ai-sdk/provider@2.0.0-canary.6
|
|
1306
1179
|
- @ai-sdk/provider-utils@3.0.0-canary.7
|
|
@@ -1309,12 +1182,7 @@
|
|
|
1309
1182
|
|
|
1310
1183
|
### Patch Changes
|
|
1311
1184
|
|
|
1312
|
-
- Updated dependencies
|
|
1313
|
-
- Updated dependencies [411e483]
|
|
1314
|
-
- Updated dependencies [79457bd]
|
|
1315
|
-
- Updated dependencies [ad80501]
|
|
1316
|
-
- Updated dependencies [1766ede]
|
|
1317
|
-
- Updated dependencies [f10304b]
|
|
1185
|
+
- Updated dependencies
|
|
1318
1186
|
- @ai-sdk/openai-compatible@1.0.0-canary.6
|
|
1319
1187
|
- @ai-sdk/provider@2.0.0-canary.5
|
|
1320
1188
|
- @ai-sdk/provider-utils@3.0.0-canary.6
|
|
@@ -1341,11 +1209,7 @@
|
|
|
1341
1209
|
|
|
1342
1210
|
### Patch Changes
|
|
1343
1211
|
|
|
1344
|
-
- Updated dependencies
|
|
1345
|
-
- Updated dependencies [abf9a79]
|
|
1346
|
-
- Updated dependencies [9f95b35]
|
|
1347
|
-
- Updated dependencies [0a87932]
|
|
1348
|
-
- Updated dependencies [6dc848c]
|
|
1212
|
+
- Updated dependencies
|
|
1349
1213
|
- @ai-sdk/provider-utils@3.0.0-canary.3
|
|
1350
1214
|
- @ai-sdk/provider@2.0.0-canary.2
|
|
1351
1215
|
- @ai-sdk/openai-compatible@1.0.0-canary.3
|
|
@@ -1355,8 +1219,7 @@
|
|
|
1355
1219
|
### Patch Changes
|
|
1356
1220
|
|
|
1357
1221
|
- 7677477: feat (providers/deepinfra): add llama 4 models
|
|
1358
|
-
- Updated dependencies
|
|
1359
|
-
- Updated dependencies [33f4a6a]
|
|
1222
|
+
- Updated dependencies
|
|
1360
1223
|
- @ai-sdk/provider@2.0.0-canary.1
|
|
1361
1224
|
- @ai-sdk/openai-compatible@1.0.0-canary.2
|
|
1362
1225
|
- @ai-sdk/provider-utils@3.0.0-canary.2
|
|
@@ -1365,9 +1228,7 @@
|
|
|
1365
1228
|
|
|
1366
1229
|
### Patch Changes
|
|
1367
1230
|
|
|
1368
|
-
- Updated dependencies
|
|
1369
|
-
- Updated dependencies [0c0c0b3]
|
|
1370
|
-
- Updated dependencies [63d791d]
|
|
1231
|
+
- Updated dependencies
|
|
1371
1232
|
- @ai-sdk/provider-utils@3.0.0-canary.1
|
|
1372
1233
|
- @ai-sdk/openai-compatible@1.0.0-canary.1
|
|
1373
1234
|
|
|
@@ -1570,8 +1431,7 @@
|
|
|
1570
1431
|
|
|
1571
1432
|
### Patch Changes
|
|
1572
1433
|
|
|
1573
|
-
- Updated dependencies
|
|
1574
|
-
- Updated dependencies [3a58a2e]
|
|
1434
|
+
- Updated dependencies
|
|
1575
1435
|
- @ai-sdk/openai-compatible@0.1.2
|
|
1576
1436
|
- @ai-sdk/provider-utils@2.1.2
|
|
1577
1437
|
- @ai-sdk/provider@1.0.6
|
|
@@ -1580,8 +1440,7 @@
|
|
|
1580
1440
|
|
|
1581
1441
|
### Patch Changes
|
|
1582
1442
|
|
|
1583
|
-
- Updated dependencies
|
|
1584
|
-
- Updated dependencies [0a699f1]
|
|
1443
|
+
- Updated dependencies
|
|
1585
1444
|
- @ai-sdk/provider-utils@2.1.1
|
|
1586
1445
|
- @ai-sdk/openai-compatible@0.1.1
|
|
1587
1446
|
- @ai-sdk/provider@1.0.5
|
|
@@ -1624,9 +1483,7 @@
|
|
|
1624
1483
|
|
|
1625
1484
|
### Patch Changes
|
|
1626
1485
|
|
|
1627
|
-
- Updated dependencies
|
|
1628
|
-
- Updated dependencies [e6dfef4]
|
|
1629
|
-
- Updated dependencies [6636db6]
|
|
1486
|
+
- Updated dependencies
|
|
1630
1487
|
- @ai-sdk/provider-utils@2.0.7
|
|
1631
1488
|
- @ai-sdk/openai-compatible@0.0.15
|
|
1632
1489
|
|
|
@@ -1634,10 +1491,7 @@
|
|
|
1634
1491
|
|
|
1635
1492
|
### Patch Changes
|
|
1636
1493
|
|
|
1637
|
-
- Updated dependencies
|
|
1638
|
-
- Updated dependencies [19a2ce7]
|
|
1639
|
-
- Updated dependencies [43b37f7]
|
|
1640
|
-
- Updated dependencies [6337688]
|
|
1494
|
+
- Updated dependencies
|
|
1641
1495
|
- @ai-sdk/provider@1.0.4
|
|
1642
1496
|
- @ai-sdk/provider-utils@2.0.6
|
|
1643
1497
|
- @ai-sdk/openai-compatible@0.0.14
|
|
@@ -1667,8 +1521,7 @@
|
|
|
1667
1521
|
### Patch Changes
|
|
1668
1522
|
|
|
1669
1523
|
- 5ed5e45: chore (config): Use ts-library.json tsconfig for no-UI libs.
|
|
1670
|
-
- Updated dependencies
|
|
1671
|
-
- Updated dependencies [307c247]
|
|
1524
|
+
- Updated dependencies
|
|
1672
1525
|
- @ai-sdk/openai-compatible@0.0.11
|
|
1673
1526
|
- @ai-sdk/provider-utils@2.0.5
|
|
1674
1527
|
- @ai-sdk/provider@1.0.3
|
package/dist/index.js
CHANGED
|
@@ -161,7 +161,7 @@ async function fileToBlob(file) {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
// src/version.ts
|
|
164
|
-
var VERSION = true ? "2.0.
|
|
164
|
+
var VERSION = true ? "2.0.1" : "0.0.0-test";
|
|
165
165
|
|
|
166
166
|
// src/deepinfra-provider.ts
|
|
167
167
|
function createDeepInfra(options = {}) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/deepinfra-provider.ts","../src/deepinfra-image-model.ts","../src/version.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';\nexport { VERSION } from './version';\n","import {\n LanguageModelV3,\n EmbeddingModelV3,\n ProviderV3,\n ImageModelV3,\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 withUserAgentSuffix,\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';\nimport { VERSION } from './version';\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 ProviderV3 {\n /**\nCreates a model for text generation.\n*/\n (modelId: DeepInfraChatModelId): LanguageModelV3;\n\n /**\nCreates a chat model for text generation.\n*/\n chatModel(modelId: DeepInfraChatModelId): LanguageModelV3;\n\n /**\nCreates a model for image generation.\n */\n image(modelId: DeepInfraImageModelId): ImageModelV3;\n\n /**\nCreates a model for image generation.\n */\n imageModel(modelId: DeepInfraImageModelId): ImageModelV3;\n\n /**\nCreates a chat model for text generation.\n*/\n languageModel(modelId: DeepInfraChatModelId): LanguageModelV3;\n\n /**\nCreates a completion model for text generation.\n*/\n completionModel(modelId: DeepInfraCompletionModelId): LanguageModelV3;\n\n /**\nCreates a embedding model for text generation.\n*/\n embeddingModel(modelId: DeepInfraEmbeddingModelId): EmbeddingModelV3;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: DeepInfraEmbeddingModelId): EmbeddingModelV3;\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 withUserAgentSuffix(\n {\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 `ai-sdk/deepinfra/${VERSION}`,\n );\n\n interface CommonModelConfig {\n provider: string;\n url: ({ path }: { path: string }) => string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n }\n\n const getCommonModelConfig = (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 createEmbeddingModel = (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.specificationVersion = 'v3' as const;\n provider.completionModel = createCompletionModel;\n provider.chatModel = createChatModel;\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n provider.languageModel = createChatModel;\n provider.embeddingModel = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n\n return provider;\n}\n\nexport const deepinfra = createDeepInfra();\n","import {\n ImageModelV3,\n ImageModelV3File,\n SharedV3Warning,\n} from '@ai-sdk/provider';\nimport {\n combineHeaders,\n convertBase64ToUint8Array,\n convertToFormData,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n downloadBlob,\n FetchFunction,\n postFormDataToApi,\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 ImageModelV3 {\n readonly specificationVersion = 'v3';\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 files,\n mask,\n }: Parameters<ImageModelV3['doGenerate']>[0]): Promise<\n Awaited<ReturnType<ImageModelV3['doGenerate']>>\n > {\n const warnings: Array<SharedV3Warning> = [];\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n\n // Image editing mode - use OpenAI-compatible /images/edits endpoint\n if (files != null && files.length > 0) {\n const { value: response, responseHeaders } = await postFormDataToApi({\n url: this.getEditUrl(),\n headers: combineHeaders(this.config.headers(), headers),\n formData: convertToFormData<DeepInfraFormDataInput>(\n {\n model: this.modelId,\n prompt,\n image: await Promise.all(files.map(file => fileToBlob(file))),\n mask: mask != null ? await fileToBlob(mask) : undefined,\n n,\n size,\n ...(providerOptions.deepinfra ?? {}),\n },\n { useArrayBrackets: false },\n ),\n failedResponseHandler: createJsonErrorResponseHandler({\n errorSchema: deepInfraEditErrorSchema,\n errorToMessage: error => error.error?.message ?? 'Unknown error',\n }),\n successfulResponseHandler: createJsonResponseHandler(\n deepInfraEditResponseSchema,\n ),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n images: response.data.map(item => item.b64_json),\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n },\n };\n }\n\n // Standard image generation mode\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 const splitSize = size?.split('x');\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 private getEditUrl(): string {\n // Use OpenAI-compatible endpoint for image editing\n // baseURL is typically https://api.deepinfra.com/v1/inference\n // We need to use https://api.deepinfra.com/v1/openai/images/edits\n const baseUrl = this.config.baseURL.replace('/inference', '/openai');\n return `${baseUrl}/images/edits`;\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\n// Schema for OpenAI-compatible image edit endpoint errors\nexport const deepInfraEditErrorSchema = z.object({\n error: z\n .object({\n message: z.string(),\n })\n .optional(),\n});\n\n// Schema for OpenAI-compatible image edit endpoint response\nexport const deepInfraEditResponseSchema = z.object({\n data: z.array(z.object({ b64_json: z.string() })),\n});\n\ntype DeepInfraFormDataInput = {\n model: string;\n prompt: string | undefined;\n image: Blob | Blob[];\n mask?: Blob;\n n: number;\n size: `${number}x${number}` | undefined;\n [key: string]: unknown;\n};\n\nasync function fileToBlob(file: ImageModelV3File): Promise<Blob> {\n if (file.type === 'url') {\n return downloadBlob(file.url);\n }\n\n const data =\n file.data instanceof Uint8Array\n ? file.data\n : convertBase64ToUint8Array(file.data);\n\n return new Blob([data as BlobPart], { type: file.mediaType });\n}\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,+BAIO;AAC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K,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,uBAAuB,CAAC,YAC5B,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,uBAAuB;AAChC,WAAS,kBAAkB;AAC3B,WAAS,YAAY;AACrB,WAAS,QAAQ;AACjB,WAAS,aAAa;AACtB,WAAS,gBAAgB;AACzB,WAAS,iBAAiB;AAC1B,WAAS,qBAAqB;AAE9B,SAAO;AACT;AAEO,IAAM,YAAY,gBAAgB;","names":["import_provider_utils","response","responseHeaders","_a","_b"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/deepinfra-provider.ts","../src/deepinfra-image-model.ts","../src/version.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';\nexport { VERSION } from './version';\n","import {\n LanguageModelV3,\n EmbeddingModelV3,\n ProviderV3,\n ImageModelV3,\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 withUserAgentSuffix,\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';\nimport { VERSION } from './version';\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 ProviderV3 {\n /**\nCreates a model for text generation.\n*/\n (modelId: DeepInfraChatModelId): LanguageModelV3;\n\n /**\nCreates a chat model for text generation.\n*/\n chatModel(modelId: DeepInfraChatModelId): LanguageModelV3;\n\n /**\nCreates a model for image generation.\n */\n image(modelId: DeepInfraImageModelId): ImageModelV3;\n\n /**\nCreates a model for image generation.\n */\n imageModel(modelId: DeepInfraImageModelId): ImageModelV3;\n\n /**\nCreates a chat model for text generation.\n*/\n languageModel(modelId: DeepInfraChatModelId): LanguageModelV3;\n\n /**\nCreates a completion model for text generation.\n*/\n completionModel(modelId: DeepInfraCompletionModelId): LanguageModelV3;\n\n /**\nCreates a embedding model for text generation.\n*/\n embeddingModel(modelId: DeepInfraEmbeddingModelId): EmbeddingModelV3;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: DeepInfraEmbeddingModelId): EmbeddingModelV3;\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 withUserAgentSuffix(\n {\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 `ai-sdk/deepinfra/${VERSION}`,\n );\n\n interface CommonModelConfig {\n provider: string;\n url: ({ path }: { path: string }) => string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n }\n\n const getCommonModelConfig = (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 createEmbeddingModel = (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.specificationVersion = 'v3' as const;\n provider.completionModel = createCompletionModel;\n provider.chatModel = createChatModel;\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n provider.languageModel = createChatModel;\n provider.embeddingModel = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n\n return provider;\n}\n\nexport const deepinfra = createDeepInfra();\n","import {\n ImageModelV3,\n ImageModelV3File,\n SharedV3Warning,\n} from '@ai-sdk/provider';\nimport {\n combineHeaders,\n convertBase64ToUint8Array,\n convertToFormData,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n downloadBlob,\n FetchFunction,\n postFormDataToApi,\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 ImageModelV3 {\n readonly specificationVersion = 'v3';\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 files,\n mask,\n }: Parameters<ImageModelV3['doGenerate']>[0]): Promise<\n Awaited<ReturnType<ImageModelV3['doGenerate']>>\n > {\n const warnings: Array<SharedV3Warning> = [];\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n\n // Image editing mode - use OpenAI-compatible /images/edits endpoint\n if (files != null && files.length > 0) {\n const { value: response, responseHeaders } = await postFormDataToApi({\n url: this.getEditUrl(),\n headers: combineHeaders(this.config.headers(), headers),\n formData: convertToFormData<DeepInfraFormDataInput>(\n {\n model: this.modelId,\n prompt,\n image: await Promise.all(files.map(file => fileToBlob(file))),\n mask: mask != null ? await fileToBlob(mask) : undefined,\n n,\n size,\n ...(providerOptions.deepinfra ?? {}),\n },\n { useArrayBrackets: false },\n ),\n failedResponseHandler: createJsonErrorResponseHandler({\n errorSchema: deepInfraEditErrorSchema,\n errorToMessage: error => error.error?.message ?? 'Unknown error',\n }),\n successfulResponseHandler: createJsonResponseHandler(\n deepInfraEditResponseSchema,\n ),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n images: response.data.map(item => item.b64_json),\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n },\n };\n }\n\n // Standard image generation mode\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 const splitSize = size?.split('x');\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 private getEditUrl(): string {\n // Use OpenAI-compatible endpoint for image editing\n // baseURL is typically https://api.deepinfra.com/v1/inference\n // We need to use https://api.deepinfra.com/v1/openai/images/edits\n const baseUrl = this.config.baseURL.replace('/inference', '/openai');\n return `${baseUrl}/images/edits`;\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\n// Schema for OpenAI-compatible image edit endpoint errors\nexport const deepInfraEditErrorSchema = z.object({\n error: z\n .object({\n message: z.string(),\n })\n .optional(),\n});\n\n// Schema for OpenAI-compatible image edit endpoint response\nexport const deepInfraEditResponseSchema = z.object({\n data: z.array(z.object({ b64_json: z.string() })),\n});\n\ntype DeepInfraFormDataInput = {\n model: string;\n prompt: string | undefined;\n image: Blob | Blob[];\n mask?: Blob;\n n: number;\n size: `${number}x${number}` | undefined;\n [key: string]: unknown;\n};\n\nasync function fileToBlob(file: ImageModelV3File): Promise<Blob> {\n if (file.type === 'url') {\n return downloadBlob(file.url);\n }\n\n const data =\n file.data instanceof Uint8Array\n ? file.data\n : convertBase64ToUint8Array(file.data);\n\n return new Blob([data as BlobPart], { type: file.mediaType });\n}\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,+BAIO;AACP,IAAAA,yBAKO;;;ACXP,4BAUO;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;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAEE;AAvDJ;AAwDI,UAAM,WAAmC,CAAC;AAC1C,UAAM,eAAc,sBAAK,OAAO,cAAZ,mBAAuB,gBAAvB,4CAA0C,oBAAI,KAAK;AAGvE,QAAI,SAAS,QAAQ,MAAM,SAAS,GAAG;AACrC,YAAM,EAAE,OAAOC,WAAU,iBAAAC,iBAAgB,IAAI,UAAM,yCAAkB;AAAA,QACnE,KAAK,KAAK,WAAW;AAAA,QACrB,aAAS,sCAAe,KAAK,OAAO,QAAQ,GAAG,OAAO;AAAA,QACtD,cAAU;AAAA,UACR;AAAA,YACE,OAAO,KAAK;AAAA,YACZ;AAAA,YACA,OAAO,MAAM,QAAQ,IAAI,MAA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":["import_provider_utils","response","responseHeaders","_a","_b"]}
|
package/dist/index.mjs
CHANGED
|
@@ -150,7 +150,7 @@ async function fileToBlob(file) {
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
// src/version.ts
|
|
153
|
-
var VERSION = true ? "2.0.
|
|
153
|
+
var VERSION = true ? "2.0.1" : "0.0.0-test";
|
|
154
154
|
|
|
155
155
|
// src/deepinfra-provider.ts
|
|
156
156
|
function createDeepInfra(options = {}) {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/deepinfra-provider.ts","../src/deepinfra-image-model.ts","../src/version.ts"],"sourcesContent":["import {\n LanguageModelV3,\n EmbeddingModelV3,\n ProviderV3,\n ImageModelV3,\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 withUserAgentSuffix,\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';\nimport { VERSION } from './version';\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 ProviderV3 {\n /**\nCreates a model for text generation.\n*/\n (modelId: DeepInfraChatModelId): LanguageModelV3;\n\n /**\nCreates a chat model for text generation.\n*/\n chatModel(modelId: DeepInfraChatModelId): LanguageModelV3;\n\n /**\nCreates a model for image generation.\n */\n image(modelId: DeepInfraImageModelId): ImageModelV3;\n\n /**\nCreates a model for image generation.\n */\n imageModel(modelId: DeepInfraImageModelId): ImageModelV3;\n\n /**\nCreates a chat model for text generation.\n*/\n languageModel(modelId: DeepInfraChatModelId): LanguageModelV3;\n\n /**\nCreates a completion model for text generation.\n*/\n completionModel(modelId: DeepInfraCompletionModelId): LanguageModelV3;\n\n /**\nCreates a embedding model for text generation.\n*/\n embeddingModel(modelId: DeepInfraEmbeddingModelId): EmbeddingModelV3;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: DeepInfraEmbeddingModelId): EmbeddingModelV3;\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 withUserAgentSuffix(\n {\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 `ai-sdk/deepinfra/${VERSION}`,\n );\n\n interface CommonModelConfig {\n provider: string;\n url: ({ path }: { path: string }) => string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n }\n\n const getCommonModelConfig = (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 createEmbeddingModel = (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.specificationVersion = 'v3' as const;\n provider.completionModel = createCompletionModel;\n provider.chatModel = createChatModel;\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n provider.languageModel = createChatModel;\n provider.embeddingModel = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n\n return provider;\n}\n\nexport const deepinfra = createDeepInfra();\n","import {\n ImageModelV3,\n ImageModelV3File,\n SharedV3Warning,\n} from '@ai-sdk/provider';\nimport {\n combineHeaders,\n convertBase64ToUint8Array,\n convertToFormData,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n downloadBlob,\n FetchFunction,\n postFormDataToApi,\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 ImageModelV3 {\n readonly specificationVersion = 'v3';\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 files,\n mask,\n }: Parameters<ImageModelV3['doGenerate']>[0]): Promise<\n Awaited<ReturnType<ImageModelV3['doGenerate']>>\n > {\n const warnings: Array<SharedV3Warning> = [];\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n\n // Image editing mode - use OpenAI-compatible /images/edits endpoint\n if (files != null && files.length > 0) {\n const { value: response, responseHeaders } = await postFormDataToApi({\n url: this.getEditUrl(),\n headers: combineHeaders(this.config.headers(), headers),\n formData: convertToFormData<DeepInfraFormDataInput>(\n {\n model: this.modelId,\n prompt,\n image: await Promise.all(files.map(file => fileToBlob(file))),\n mask: mask != null ? await fileToBlob(mask) : undefined,\n n,\n size,\n ...(providerOptions.deepinfra ?? {}),\n },\n { useArrayBrackets: false },\n ),\n failedResponseHandler: createJsonErrorResponseHandler({\n errorSchema: deepInfraEditErrorSchema,\n errorToMessage: error => error.error?.message ?? 'Unknown error',\n }),\n successfulResponseHandler: createJsonResponseHandler(\n deepInfraEditResponseSchema,\n ),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n images: response.data.map(item => item.b64_json),\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n },\n };\n }\n\n // Standard image generation mode\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 const splitSize = size?.split('x');\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 private getEditUrl(): string {\n // Use OpenAI-compatible endpoint for image editing\n // baseURL is typically https://api.deepinfra.com/v1/inference\n // We need to use https://api.deepinfra.com/v1/openai/images/edits\n const baseUrl = this.config.baseURL.replace('/inference', '/openai');\n return `${baseUrl}/images/edits`;\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\n// Schema for OpenAI-compatible image edit endpoint errors\nexport const deepInfraEditErrorSchema = z.object({\n error: z\n .object({\n message: z.string(),\n })\n .optional(),\n});\n\n// Schema for OpenAI-compatible image edit endpoint response\nexport const deepInfraEditResponseSchema = z.object({\n data: z.array(z.object({ b64_json: z.string() })),\n});\n\ntype DeepInfraFormDataInput = {\n model: string;\n prompt: string | undefined;\n image: Blob | Blob[];\n mask?: Blob;\n n: number;\n size: `${number}x${number}` | undefined;\n [key: string]: unknown;\n};\n\nasync function fileToBlob(file: ImageModelV3File): Promise<Blob> {\n if (file.type === 'url') {\n return downloadBlob(file.url);\n }\n\n const data =\n file.data instanceof Uint8Array\n ? file.data\n : convertBase64ToUint8Array(file.data);\n\n return new Blob([data as BlobPart], { type: file.mediaType });\n}\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n"],"mappings":";AAMA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACXP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,SAAS;AAYX,IAAM,sBAAN,MAAkD;AAAA,EAQvD,YACW,SACD,QACR;AAFS;AACD;AATV,SAAS,uBAAuB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kC;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,uBAAuB,CAAC,YAC5B,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,uBAAuB;AAChC,WAAS,kBAAkB;AAC3B,WAAS,YAAY;AACrB,WAAS,QAAQ;AACjB,WAAS,aAAa;AACtB,WAAS,gBAAgB;AACzB,WAAS,iBAAiB;AAC1B,WAAS,qBAAqB;AAE9B,SAAO;AACT;AAEO,IAAM,YAAY,gBAAgB;","names":["response","responseHeaders","_a","_b"]}
|
|
1
|
+
{"version":3,"sources":["../src/deepinfra-provider.ts","../src/deepinfra-image-model.ts","../src/version.ts"],"sourcesContent":["import {\n LanguageModelV3,\n EmbeddingModelV3,\n ProviderV3,\n ImageModelV3,\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 withUserAgentSuffix,\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';\nimport { VERSION } from './version';\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 ProviderV3 {\n /**\nCreates a model for text generation.\n*/\n (modelId: DeepInfraChatModelId): LanguageModelV3;\n\n /**\nCreates a chat model for text generation.\n*/\n chatModel(modelId: DeepInfraChatModelId): LanguageModelV3;\n\n /**\nCreates a model for image generation.\n */\n image(modelId: DeepInfraImageModelId): ImageModelV3;\n\n /**\nCreates a model for image generation.\n */\n imageModel(modelId: DeepInfraImageModelId): ImageModelV3;\n\n /**\nCreates a chat model for text generation.\n*/\n languageModel(modelId: DeepInfraChatModelId): LanguageModelV3;\n\n /**\nCreates a completion model for text generation.\n*/\n completionModel(modelId: DeepInfraCompletionModelId): LanguageModelV3;\n\n /**\nCreates a embedding model for text generation.\n*/\n embeddingModel(modelId: DeepInfraEmbeddingModelId): EmbeddingModelV3;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: DeepInfraEmbeddingModelId): EmbeddingModelV3;\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 withUserAgentSuffix(\n {\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 `ai-sdk/deepinfra/${VERSION}`,\n );\n\n interface CommonModelConfig {\n provider: string;\n url: ({ path }: { path: string }) => string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n }\n\n const getCommonModelConfig = (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 createEmbeddingModel = (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.specificationVersion = 'v3' as const;\n provider.completionModel = createCompletionModel;\n provider.chatModel = createChatModel;\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n provider.languageModel = createChatModel;\n provider.embeddingModel = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n\n return provider;\n}\n\nexport const deepinfra = createDeepInfra();\n","import {\n ImageModelV3,\n ImageModelV3File,\n SharedV3Warning,\n} from '@ai-sdk/provider';\nimport {\n combineHeaders,\n convertBase64ToUint8Array,\n convertToFormData,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n downloadBlob,\n FetchFunction,\n postFormDataToApi,\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 ImageModelV3 {\n readonly specificationVersion = 'v3';\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 files,\n mask,\n }: Parameters<ImageModelV3['doGenerate']>[0]): Promise<\n Awaited<ReturnType<ImageModelV3['doGenerate']>>\n > {\n const warnings: Array<SharedV3Warning> = [];\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n\n // Image editing mode - use OpenAI-compatible /images/edits endpoint\n if (files != null && files.length > 0) {\n const { value: response, responseHeaders } = await postFormDataToApi({\n url: this.getEditUrl(),\n headers: combineHeaders(this.config.headers(), headers),\n formData: convertToFormData<DeepInfraFormDataInput>(\n {\n model: this.modelId,\n prompt,\n image: await Promise.all(files.map(file => fileToBlob(file))),\n mask: mask != null ? await fileToBlob(mask) : undefined,\n n,\n size,\n ...(providerOptions.deepinfra ?? {}),\n },\n { useArrayBrackets: false },\n ),\n failedResponseHandler: createJsonErrorResponseHandler({\n errorSchema: deepInfraEditErrorSchema,\n errorToMessage: error => error.error?.message ?? 'Unknown error',\n }),\n successfulResponseHandler: createJsonResponseHandler(\n deepInfraEditResponseSchema,\n ),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n images: response.data.map(item => item.b64_json),\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n },\n };\n }\n\n // Standard image generation mode\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 const splitSize = size?.split('x');\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 private getEditUrl(): string {\n // Use OpenAI-compatible endpoint for image editing\n // baseURL is typically https://api.deepinfra.com/v1/inference\n // We need to use https://api.deepinfra.com/v1/openai/images/edits\n const baseUrl = this.config.baseURL.replace('/inference', '/openai');\n return `${baseUrl}/images/edits`;\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\n// Schema for OpenAI-compatible image edit endpoint errors\nexport const deepInfraEditErrorSchema = z.object({\n error: z\n .object({\n message: z.string(),\n })\n .optional(),\n});\n\n// Schema for OpenAI-compatible image edit endpoint response\nexport const deepInfraEditResponseSchema = z.object({\n data: z.array(z.object({ b64_json: z.string() })),\n});\n\ntype DeepInfraFormDataInput = {\n model: string;\n prompt: string | undefined;\n image: Blob | Blob[];\n mask?: Blob;\n n: number;\n size: `${number}x${number}` | undefined;\n [key: string]: unknown;\n};\n\nasync function fileToBlob(file: ImageModelV3File): Promise<Blob> {\n if (file.type === 'url') {\n return downloadBlob(file.url);\n }\n\n const data =\n file.data instanceof Uint8Array\n ? file.data\n : convertBase64ToUint8Array(file.data);\n\n return new Blob([data as BlobPart], { type: file.mediaType });\n}\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKA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AChB,yBAAyB;AAAA,QACzB,aAAa;AAAA,MACf,CAAC,CAAC;AAAA,MACF,GAAG,QAAQ;AAAA,IACb;AAAA,IACA,oBAAoB,OAAO;AAAA,EAC7B;AASF,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,uBAAuB,CAAC,YAC5B,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,uBAAuB;AAChC,WAAS,kBAAkB;AAC3B,WAAS,YAAY;AACrB,WAAS,QAAQ;AACjB,WAAS,aAAa;AACtB,WAAS,gBAAgB;AACzB,WAAS,iBAAiB;AAC1B,WAAS,qBAAqB;AAE9B,SAAO;AACT;AAEO,IAAM,YAAY,gBAAgB;","names":["response","responseHeaders","_a","_b"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/deepinfra",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,16 +20,16 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@ai-sdk/openai-compatible": "2.0.
|
|
24
|
-
"@ai-sdk/provider": "3.0.0
|
|
25
|
-
"@ai-sdk/provider-utils": "4.0.
|
|
23
|
+
"@ai-sdk/openai-compatible": "2.0.1",
|
|
24
|
+
"@ai-sdk/provider": "3.0.0",
|
|
25
|
+
"@ai-sdk/provider-utils": "4.0.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "20.17.24",
|
|
29
29
|
"tsup": "^8",
|
|
30
30
|
"typescript": "5.8.3",
|
|
31
31
|
"zod": "3.25.76",
|
|
32
|
-
"@ai-sdk/test-server": "1.0.0
|
|
32
|
+
"@ai-sdk/test-server": "1.0.0",
|
|
33
33
|
"@vercel/ai-tsconfig": "0.0.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|