@ai-sdk/alibaba 2.0.0-beta.2 → 2.0.0-beta.22

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,172 @@
1
1
  # @ai-sdk/alibaba
2
2
 
3
+ ## 2.0.0-beta.22
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [e311194]
8
+ - @ai-sdk/provider@4.0.0-beta.9
9
+ - @ai-sdk/openai-compatible@3.0.0-beta.20
10
+ - @ai-sdk/provider-utils@5.0.0-beta.15
11
+
12
+ ## 2.0.0-beta.21
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [34bd95d]
17
+ - Updated dependencies [008271d]
18
+ - @ai-sdk/provider@4.0.0-beta.8
19
+ - @ai-sdk/openai-compatible@3.0.0-beta.19
20
+ - @ai-sdk/provider-utils@5.0.0-beta.14
21
+
22
+ ## 2.0.0-beta.20
23
+
24
+ ### Patch Changes
25
+
26
+ - Updated dependencies [b0c2869]
27
+ - Updated dependencies [7e26e81]
28
+ - @ai-sdk/provider-utils@5.0.0-beta.13
29
+ - @ai-sdk/openai-compatible@3.0.0-beta.18
30
+
31
+ ## 2.0.0-beta.19
32
+
33
+ ### Patch Changes
34
+
35
+ - Updated dependencies [816ff67]
36
+ - @ai-sdk/openai-compatible@3.0.0-beta.17
37
+
38
+ ## 2.0.0-beta.18
39
+
40
+ ### Patch Changes
41
+
42
+ - Updated dependencies [46d1149]
43
+ - @ai-sdk/provider-utils@5.0.0-beta.12
44
+ - @ai-sdk/openai-compatible@3.0.0-beta.16
45
+
46
+ ## 2.0.0-beta.17
47
+
48
+ ### Patch Changes
49
+
50
+ - Updated dependencies [6fd51c0]
51
+ - @ai-sdk/provider-utils@5.0.0-beta.11
52
+ - @ai-sdk/provider@4.0.0-beta.7
53
+ - @ai-sdk/openai-compatible@3.0.0-beta.15
54
+
55
+ ## 2.0.0-beta.16
56
+
57
+ ### Patch Changes
58
+
59
+ - c29a26f: feat(provider): add support for provider references and uploading files as supported per provider
60
+ - Updated dependencies [c29a26f]
61
+ - @ai-sdk/openai-compatible@3.0.0-beta.14
62
+ - @ai-sdk/provider-utils@5.0.0-beta.10
63
+ - @ai-sdk/provider@4.0.0-beta.6
64
+
65
+ ## 2.0.0-beta.15
66
+
67
+ ### Patch Changes
68
+
69
+ - 38fc777: Add AI Gateway hint to provider READMEs
70
+ - Updated dependencies [38fc777]
71
+ - @ai-sdk/openai-compatible@3.0.0-beta.13
72
+
73
+ ## 2.0.0-beta.14
74
+
75
+ ### Patch Changes
76
+
77
+ - Updated dependencies [2e17091]
78
+ - @ai-sdk/provider-utils@5.0.0-beta.9
79
+ - @ai-sdk/openai-compatible@3.0.0-beta.12
80
+
81
+ ## 2.0.0-beta.13
82
+
83
+ ### Patch Changes
84
+
85
+ - Updated dependencies [986c6fd]
86
+ - Updated dependencies [493295c]
87
+ - @ai-sdk/provider-utils@5.0.0-beta.8
88
+ - @ai-sdk/openai-compatible@3.0.0-beta.11
89
+
90
+ ## 2.0.0-beta.12
91
+
92
+ ### Patch Changes
93
+
94
+ - Updated dependencies [1f509d4]
95
+ - @ai-sdk/provider-utils@5.0.0-beta.7
96
+ - @ai-sdk/provider@4.0.0-beta.5
97
+ - @ai-sdk/openai-compatible@3.0.0-beta.10
98
+
99
+ ## 2.0.0-beta.11
100
+
101
+ ### Patch Changes
102
+
103
+ - 74d520f: feat: migrate providers to support new top-level `reasoning` parameter
104
+ - Updated dependencies [74d520f]
105
+ - @ai-sdk/openai-compatible@3.0.0-beta.9
106
+
107
+ ## 2.0.0-beta.10
108
+
109
+ ### Patch Changes
110
+
111
+ - Updated dependencies [3887c70]
112
+ - @ai-sdk/provider-utils@5.0.0-beta.6
113
+ - @ai-sdk/provider@4.0.0-beta.4
114
+ - @ai-sdk/openai-compatible@3.0.0-beta.8
115
+
116
+ ## 2.0.0-beta.9
117
+
118
+ ### Patch Changes
119
+
120
+ - Updated dependencies [776b617]
121
+ - @ai-sdk/provider-utils@5.0.0-beta.5
122
+ - @ai-sdk/provider@4.0.0-beta.3
123
+ - @ai-sdk/openai-compatible@3.0.0-beta.7
124
+
125
+ ## 2.0.0-beta.8
126
+
127
+ ### Patch Changes
128
+
129
+ - Updated dependencies [61753c3]
130
+ - @ai-sdk/provider-utils@5.0.0-beta.4
131
+ - @ai-sdk/openai-compatible@3.0.0-beta.6
132
+
133
+ ## 2.0.0-beta.7
134
+
135
+ ### Patch Changes
136
+
137
+ - 811cd8e: fix(provider/alibaba): handle single-item content array cache control
138
+
139
+ ## 2.0.0-beta.6
140
+
141
+ ### Patch Changes
142
+
143
+ - Updated dependencies [f7d4f01]
144
+ - @ai-sdk/provider-utils@5.0.0-beta.3
145
+ - @ai-sdk/provider@4.0.0-beta.2
146
+ - @ai-sdk/openai-compatible@3.0.0-beta.5
147
+
148
+ ## 2.0.0-beta.5
149
+
150
+ ### Patch Changes
151
+
152
+ - Updated dependencies [5c2a5a2]
153
+ - @ai-sdk/provider@4.0.0-beta.1
154
+ - @ai-sdk/openai-compatible@3.0.0-beta.4
155
+ - @ai-sdk/provider-utils@5.0.0-beta.2
156
+
157
+ ## 2.0.0-beta.4
158
+
159
+ ### Patch Changes
160
+
161
+ - Updated dependencies [8f3e1da]
162
+ - @ai-sdk/openai-compatible@3.0.0-beta.3
163
+
164
+ ## 2.0.0-beta.3
165
+
166
+ ### Patch Changes
167
+
168
+ - 4ab27b9: chore(alibaba): update v3 specs to v4
169
+
3
170
  ## 2.0.0-beta.2
4
171
 
5
172
  ### Patch Changes
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  The **[Alibaba provider](https://ai-sdk.dev/providers/ai-sdk-providers/alibaba)** for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for [Alibaba Cloud Model Studio](https://modelstudio.console.alibabacloud.com/), including the Qwen model series with advanced reasoning capabilities.
4
4
 
5
+ > **Deploying to Vercel?** With Vercel's AI Gateway you can access Alibaba (and hundreds of models from other providers) — no additional packages, API keys, or extra cost. [Get started with AI Gateway](https://vercel.com/ai-gateway).
6
+
5
7
  ## Setup
6
8
 
7
9
  The Alibaba provider is available in the `@ai-sdk/alibaba` module. You can install it with
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod/v4';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
- import { ProviderV3, LanguageModelV3, Experimental_VideoModelV3 } from '@ai-sdk/provider';
3
+ import { ProviderV4, LanguageModelV4, Experimental_VideoModelV4 } from '@ai-sdk/provider';
4
4
 
5
5
  type AlibabaChatModelId = 'qwen3-max' | 'qwen3-max-preview' | 'qwen-plus' | 'qwen-plus-latest' | 'qwen-flash' | 'qwen-turbo' | 'qwen-turbo-latest' | 'qwen3-235b-a22b' | 'qwen3-32b' | 'qwen3-30b-a3b' | 'qwen3-14b' | 'qwen3-next-80b-a3b-thinking' | 'qwen3-235b-a22b-thinking-2507' | 'qwen3-30b-a3b-thinking-2507' | 'qwq-plus' | 'qwq-plus-latest' | 'qwq-32b' | 'qwen-coder' | 'qwen3-coder-plus' | 'qwen3-coder-flash' | (string & {});
6
6
  declare const alibabaLanguageModelOptions: z.ZodObject<{
@@ -16,24 +16,24 @@ type AlibabaCacheControl = {
16
16
 
17
17
  type AlibabaVideoModelId = 'wan2.6-t2v' | 'wan2.5-t2v-preview' | 'wan2.6-i2v' | 'wan2.6-i2v-flash' | 'wan2.6-r2v' | 'wan2.6-r2v-flash' | (string & {});
18
18
 
19
- interface AlibabaProvider extends ProviderV3 {
20
- (modelId: AlibabaChatModelId): LanguageModelV3;
19
+ interface AlibabaProvider extends ProviderV4 {
20
+ (modelId: AlibabaChatModelId): LanguageModelV4;
21
21
  /**
22
22
  * Creates a model for text generation.
23
23
  */
24
- languageModel(modelId: AlibabaChatModelId): LanguageModelV3;
24
+ languageModel(modelId: AlibabaChatModelId): LanguageModelV4;
25
25
  /**
26
26
  * Creates a chat model for text generation.
27
27
  */
28
- chatModel(modelId: AlibabaChatModelId): LanguageModelV3;
28
+ chatModel(modelId: AlibabaChatModelId): LanguageModelV4;
29
29
  /**
30
30
  * Creates a model for video generation.
31
31
  */
32
- video(modelId: AlibabaVideoModelId): Experimental_VideoModelV3;
32
+ video(modelId: AlibabaVideoModelId): Experimental_VideoModelV4;
33
33
  /**
34
34
  * Creates a model for video generation.
35
35
  */
36
- videoModel(modelId: AlibabaVideoModelId): Experimental_VideoModelV3;
36
+ videoModel(modelId: AlibabaVideoModelId): Experimental_VideoModelV4;
37
37
  }
38
38
  interface AlibabaProviderSettings {
39
39
  /**
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod/v4';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
- import { ProviderV3, LanguageModelV3, Experimental_VideoModelV3 } from '@ai-sdk/provider';
3
+ import { ProviderV4, LanguageModelV4, Experimental_VideoModelV4 } from '@ai-sdk/provider';
4
4
 
5
5
  type AlibabaChatModelId = 'qwen3-max' | 'qwen3-max-preview' | 'qwen-plus' | 'qwen-plus-latest' | 'qwen-flash' | 'qwen-turbo' | 'qwen-turbo-latest' | 'qwen3-235b-a22b' | 'qwen3-32b' | 'qwen3-30b-a3b' | 'qwen3-14b' | 'qwen3-next-80b-a3b-thinking' | 'qwen3-235b-a22b-thinking-2507' | 'qwen3-30b-a3b-thinking-2507' | 'qwq-plus' | 'qwq-plus-latest' | 'qwq-32b' | 'qwen-coder' | 'qwen3-coder-plus' | 'qwen3-coder-flash' | (string & {});
6
6
  declare const alibabaLanguageModelOptions: z.ZodObject<{
@@ -16,24 +16,24 @@ type AlibabaCacheControl = {
16
16
 
17
17
  type AlibabaVideoModelId = 'wan2.6-t2v' | 'wan2.5-t2v-preview' | 'wan2.6-i2v' | 'wan2.6-i2v-flash' | 'wan2.6-r2v' | 'wan2.6-r2v-flash' | (string & {});
18
18
 
19
- interface AlibabaProvider extends ProviderV3 {
20
- (modelId: AlibabaChatModelId): LanguageModelV3;
19
+ interface AlibabaProvider extends ProviderV4 {
20
+ (modelId: AlibabaChatModelId): LanguageModelV4;
21
21
  /**
22
22
  * Creates a model for text generation.
23
23
  */
24
- languageModel(modelId: AlibabaChatModelId): LanguageModelV3;
24
+ languageModel(modelId: AlibabaChatModelId): LanguageModelV4;
25
25
  /**
26
26
  * Creates a chat model for text generation.
27
27
  */
28
- chatModel(modelId: AlibabaChatModelId): LanguageModelV3;
28
+ chatModel(modelId: AlibabaChatModelId): LanguageModelV4;
29
29
  /**
30
30
  * Creates a model for video generation.
31
31
  */
32
- video(modelId: AlibabaVideoModelId): Experimental_VideoModelV3;
32
+ video(modelId: AlibabaVideoModelId): Experimental_VideoModelV4;
33
33
  /**
34
34
  * Creates a model for video generation.
35
35
  */
36
- videoModel(modelId: AlibabaVideoModelId): Experimental_VideoModelV3;
36
+ videoModel(modelId: AlibabaVideoModelId): Experimental_VideoModelV4;
37
37
  }
38
38
  interface AlibabaProviderSettings {
39
39
  /**
package/dist/index.js CHANGED
@@ -18,13 +18,13 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
20
  // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
23
  VERSION: () => VERSION,
24
24
  alibaba: () => alibaba,
25
25
  createAlibaba: () => createAlibaba
26
26
  });
27
- module.exports = __toCommonJS(src_exports);
27
+ module.exports = __toCommonJS(index_exports);
28
28
 
29
29
  // src/alibaba-provider.ts
30
30
  var import_provider4 = require("@ai-sdk/provider");
@@ -89,7 +89,7 @@ function convertToAlibabaChatMessages({
89
89
  prompt,
90
90
  cacheControlValidator
91
91
  }) {
92
- var _a;
92
+ var _a, _b;
93
93
  const messages = [];
94
94
  for (const { role, content, ...message } of prompt) {
95
95
  const messageCacheControl = cacheControlValidator == null ? void 0 : cacheControlValidator.getCacheControl(
@@ -114,18 +114,12 @@ function convertToAlibabaChatMessages({
114
114
  break;
115
115
  }
116
116
  case "user": {
117
- const isSinglePart = content.length === 1;
118
- if (isSinglePart && content[0].type === "text" && !messageCacheControl) {
119
- messages.push({
120
- role: "user",
121
- content: content[0].text
122
- });
123
- break;
124
- }
125
117
  messages.push({
126
118
  role: "user",
127
- content: content.map((part) => {
128
- const partCacheControl = isSinglePart ? messageCacheControl : cacheControlValidator == null ? void 0 : cacheControlValidator.getCacheControl(part.providerOptions);
119
+ content: content.map((part, index) => {
120
+ var _a2;
121
+ const isLastPart = index === content.length - 1;
122
+ const partCacheControl = (_a2 = cacheControlValidator == null ? void 0 : cacheControlValidator.getCacheControl(part.providerOptions)) != null ? _a2 : isLastPart ? messageCacheControl : void 0;
129
123
  switch (part.type) {
130
124
  case "text": {
131
125
  return {
@@ -135,6 +129,11 @@ function convertToAlibabaChatMessages({
135
129
  };
136
130
  }
137
131
  case "file": {
132
+ if ((0, import_provider_utils.isProviderReference)(part.data)) {
133
+ throw new import_provider.UnsupportedFunctionalityError({
134
+ functionality: "file parts with provider references"
135
+ });
136
+ }
138
137
  if (part.mediaType.startsWith("image/")) {
139
138
  const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
140
139
  return {
@@ -192,13 +191,13 @@ function convertToAlibabaChatMessages({
192
191
  const toolResponses = content.filter(
193
192
  (r) => r.type !== "tool-approval-response"
194
193
  );
195
- const isSinglePart = toolResponses.length === 1;
196
194
  for (let i = 0; i < toolResponses.length; i++) {
197
195
  const toolResponse = toolResponses[i];
198
196
  const output = toolResponse.output;
199
- const partCacheControl = isSinglePart ? messageCacheControl : cacheControlValidator == null ? void 0 : cacheControlValidator.getCacheControl(
197
+ const isLastPart = i === toolResponses.length - 1;
198
+ const partCacheControl = (_a = cacheControlValidator == null ? void 0 : cacheControlValidator.getCacheControl(
200
199
  toolResponse.providerOptions
201
- );
200
+ )) != null ? _a : isLastPart ? messageCacheControl : void 0;
202
201
  let contentValue;
203
202
  switch (output.type) {
204
203
  case "text":
@@ -206,7 +205,7 @@ function convertToAlibabaChatMessages({
206
205
  contentValue = output.value;
207
206
  break;
208
207
  case "execution-denied":
209
- contentValue = (_a = output.reason) != null ? _a : "Tool execution denied.";
208
+ contentValue = (_b = output.reason) != null ? _b : "Tool execution denied.";
210
209
  break;
211
210
  case "content":
212
211
  case "json":
@@ -272,7 +271,7 @@ var CacheControlValidator = class {
272
271
  // src/alibaba-chat-language-model.ts
273
272
  var AlibabaLanguageModel = class {
274
273
  constructor(modelId, config) {
275
- this.specificationVersion = "v3";
274
+ this.specificationVersion = "v4";
276
275
  this.supportedUrls = {
277
276
  "image/*": [/^https?:\/\/.*$/]
278
277
  };
@@ -297,6 +296,7 @@ var AlibabaLanguageModel = class {
297
296
  stopSequences,
298
297
  responseFormat,
299
298
  seed,
299
+ reasoning,
300
300
  providerOptions,
301
301
  tools,
302
302
  toolChoice
@@ -329,9 +329,11 @@ var AlibabaLanguageModel = class {
329
329
  description: responseFormat.description
330
330
  }
331
331
  } : { type: "json_object" } : void 0,
332
- // Alibaba-specific options
333
- ...(alibabaOptions == null ? void 0 : alibabaOptions.enableThinking) != null ? { enable_thinking: alibabaOptions.enableThinking } : {},
334
- ...(alibabaOptions == null ? void 0 : alibabaOptions.thinkingBudget) != null ? { thinking_budget: alibabaOptions.thinkingBudget } : {},
332
+ ...resolveAlibabaThinking({
333
+ reasoning,
334
+ alibabaOptions,
335
+ warnings
336
+ }),
335
337
  // Convert messages with cache control support
336
338
  messages: convertToAlibabaChatMessages({
337
339
  prompt,
@@ -626,6 +628,34 @@ var AlibabaLanguageModel = class {
626
628
  };
627
629
  }
628
630
  };
631
+ function resolveAlibabaThinking({
632
+ reasoning,
633
+ alibabaOptions,
634
+ warnings
635
+ }) {
636
+ if ((alibabaOptions == null ? void 0 : alibabaOptions.enableThinking) != null || (alibabaOptions == null ? void 0 : alibabaOptions.thinkingBudget) != null) {
637
+ return {
638
+ ...alibabaOptions.enableThinking != null ? { enable_thinking: alibabaOptions.enableThinking } : {},
639
+ ...alibabaOptions.thinkingBudget != null ? { thinking_budget: alibabaOptions.thinkingBudget } : {}
640
+ };
641
+ }
642
+ if (!(0, import_provider_utils2.isCustomReasoning)(reasoning)) {
643
+ return {};
644
+ }
645
+ if (reasoning === "none") {
646
+ return { enable_thinking: false };
647
+ }
648
+ const thinkingBudget = (0, import_provider_utils2.mapReasoningToProviderBudget)({
649
+ reasoning,
650
+ maxOutputTokens: 16384,
651
+ maxReasoningBudget: 16384,
652
+ warnings
653
+ });
654
+ return {
655
+ enable_thinking: true,
656
+ ...thinkingBudget != null ? { thinking_budget: thinkingBudget } : {}
657
+ };
658
+ }
629
659
  var alibabaUsageSchema = import_v42.z.object({
630
660
  prompt_tokens: import_v42.z.number(),
631
661
  completion_tokens: import_v42.z.number(),
@@ -763,7 +793,7 @@ var AlibabaVideoModel = class {
763
793
  constructor(modelId, config) {
764
794
  this.modelId = modelId;
765
795
  this.config = config;
766
- this.specificationVersion = "v3";
796
+ this.specificationVersion = "v4";
767
797
  this.maxVideosPerCall = 1;
768
798
  }
769
799
  get provider() {
@@ -970,7 +1000,7 @@ var AlibabaVideoModel = class {
970
1000
  };
971
1001
 
972
1002
  // src/version.ts
973
- var VERSION = "2.0.0-beta.2";
1003
+ var VERSION = "2.0.0-beta.22";
974
1004
 
975
1005
  // src/alibaba-provider.ts
976
1006
  var alibabaErrorDataSchema = import_v44.z.object({
@@ -1023,7 +1053,7 @@ function createAlibaba(options = {}) {
1023
1053
  }
1024
1054
  return createLanguageModel(modelId);
1025
1055
  };
1026
- provider.specificationVersion = "v3";
1056
+ provider.specificationVersion = "v4";
1027
1057
  provider.languageModel = createLanguageModel;
1028
1058
  provider.chatModel = createLanguageModel;
1029
1059
  provider.video = createVideoModel;