@ai-sdk/alibaba 0.0.33 → 0.0.35

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,24 @@
1
1
  # @ai-sdk/alibaba
2
2
 
3
+ ## 0.0.35
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [a1a772f]
8
+ - @ai-sdk/provider-utils@3.0.43
9
+ - @ai-sdk/openai-compatible@1.0.60
10
+
11
+ ## 0.0.34
12
+
13
+ ### Patch Changes
14
+
15
+ - ef8266b: Defer validation schema construction until first use to reduce provider import time.
16
+ - Updated dependencies [d7b0ffa]
17
+ - Updated dependencies [9944649]
18
+ - Updated dependencies [4146790]
19
+ - @ai-sdk/provider-utils@3.0.42
20
+ - @ai-sdk/openai-compatible@1.0.59
21
+
3
22
  ## 0.0.33
4
23
 
5
24
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,34 +1,27 @@
1
- import { z } from 'zod/v4';
1
+ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
2
+ import { InferSchema, FetchFunction } from '@ai-sdk/provider-utils';
2
3
  import { ProviderV2, LanguageModelV2, EmbeddingModelV2 } from '@ai-sdk/provider';
3
- import { FetchFunction } from '@ai-sdk/provider-utils';
4
4
 
5
5
  type AlibabaChatModelId = 'qwen3.7-max' | '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
- declare const alibabaLanguageModelOptions: z.ZodObject<{
7
- enableThinking: z.ZodOptional<z.ZodBoolean>;
8
- thinkingBudget: z.ZodOptional<z.ZodNumber>;
9
- preserveThinking: z.ZodOptional<z.ZodBoolean>;
10
- parallelToolCalls: z.ZodOptional<z.ZodBoolean>;
11
- }, z.core.$strip>;
12
- type AlibabaLanguageModelOptions = z.infer<typeof alibabaLanguageModelOptions>;
6
+ declare const alibabaLanguageModelOptions: _ai_sdk_provider_utils.LazySchema<{
7
+ enableThinking?: boolean | undefined;
8
+ thinkingBudget?: number | undefined;
9
+ preserveThinking?: boolean | undefined;
10
+ parallelToolCalls?: boolean | undefined;
11
+ }>;
12
+ type AlibabaLanguageModelOptions = InferSchema<typeof alibabaLanguageModelOptions>;
13
13
 
14
14
  type AlibabaCacheControl = {
15
15
  type: string;
16
16
  };
17
17
 
18
18
  type AlibabaEmbeddingModelId = 'text-embedding-v4' | 'text-embedding-v3' | (string & {});
19
- declare const alibabaEmbeddingModelOptions: z.ZodObject<{
20
- textType: z.ZodOptional<z.ZodEnum<{
21
- query: "query";
22
- document: "document";
23
- }>>;
24
- dimension: z.ZodOptional<z.ZodNumber>;
25
- outputType: z.ZodOptional<z.ZodEnum<{
26
- dense: "dense";
27
- sparse: "sparse";
28
- "dense&sparse": "dense&sparse";
29
- }>>;
30
- }, z.core.$strip>;
31
- type AlibabaEmbeddingModelOptions = z.infer<typeof alibabaEmbeddingModelOptions>;
19
+ declare const alibabaEmbeddingModelOptions: _ai_sdk_provider_utils.LazySchema<{
20
+ textType?: "query" | "document" | undefined;
21
+ dimension?: number | undefined;
22
+ outputType?: "dense" | "sparse" | "dense&sparse" | undefined;
23
+ }>;
24
+ type AlibabaEmbeddingModelOptions = InferSchema<typeof alibabaEmbeddingModelOptions>;
32
25
 
33
26
  interface AlibabaProvider extends ProviderV2 {
34
27
  (modelId: AlibabaChatModelId): LanguageModelV2;
package/dist/index.d.ts CHANGED
@@ -1,34 +1,27 @@
1
- import { z } from 'zod/v4';
1
+ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
2
+ import { InferSchema, FetchFunction } from '@ai-sdk/provider-utils';
2
3
  import { ProviderV2, LanguageModelV2, EmbeddingModelV2 } from '@ai-sdk/provider';
3
- import { FetchFunction } from '@ai-sdk/provider-utils';
4
4
 
5
5
  type AlibabaChatModelId = 'qwen3.7-max' | '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
- declare const alibabaLanguageModelOptions: z.ZodObject<{
7
- enableThinking: z.ZodOptional<z.ZodBoolean>;
8
- thinkingBudget: z.ZodOptional<z.ZodNumber>;
9
- preserveThinking: z.ZodOptional<z.ZodBoolean>;
10
- parallelToolCalls: z.ZodOptional<z.ZodBoolean>;
11
- }, z.core.$strip>;
12
- type AlibabaLanguageModelOptions = z.infer<typeof alibabaLanguageModelOptions>;
6
+ declare const alibabaLanguageModelOptions: _ai_sdk_provider_utils.LazySchema<{
7
+ enableThinking?: boolean | undefined;
8
+ thinkingBudget?: number | undefined;
9
+ preserveThinking?: boolean | undefined;
10
+ parallelToolCalls?: boolean | undefined;
11
+ }>;
12
+ type AlibabaLanguageModelOptions = InferSchema<typeof alibabaLanguageModelOptions>;
13
13
 
14
14
  type AlibabaCacheControl = {
15
15
  type: string;
16
16
  };
17
17
 
18
18
  type AlibabaEmbeddingModelId = 'text-embedding-v4' | 'text-embedding-v3' | (string & {});
19
- declare const alibabaEmbeddingModelOptions: z.ZodObject<{
20
- textType: z.ZodOptional<z.ZodEnum<{
21
- query: "query";
22
- document: "document";
23
- }>>;
24
- dimension: z.ZodOptional<z.ZodNumber>;
25
- outputType: z.ZodOptional<z.ZodEnum<{
26
- dense: "dense";
27
- sparse: "sparse";
28
- "dense&sparse": "dense&sparse";
29
- }>>;
30
- }, z.core.$strip>;
31
- type AlibabaEmbeddingModelOptions = z.infer<typeof alibabaEmbeddingModelOptions>;
19
+ declare const alibabaEmbeddingModelOptions: _ai_sdk_provider_utils.LazySchema<{
20
+ textType?: "query" | "document" | undefined;
21
+ dimension?: number | undefined;
22
+ outputType?: "dense" | "sparse" | "dense&sparse" | undefined;
23
+ }>;
24
+ type AlibabaEmbeddingModelOptions = InferSchema<typeof alibabaEmbeddingModelOptions>;
32
25
 
33
26
  interface AlibabaProvider extends ProviderV2 {
34
27
  (modelId: AlibabaChatModelId): LanguageModelV2;
package/dist/index.js CHANGED
@@ -28,56 +28,65 @@ module.exports = __toCommonJS(index_exports);
28
28
 
29
29
  // src/alibaba-provider.ts
30
30
  var import_provider5 = require("@ai-sdk/provider");
31
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
31
+ var import_provider_utils7 = require("@ai-sdk/provider-utils");
32
32
 
33
33
  // src/alibaba-chat-language-model.ts
34
34
  var import_internal = require("@ai-sdk/openai-compatible/internal");
35
35
  var import_provider3 = require("@ai-sdk/provider");
36
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
36
+ var import_provider_utils4 = require("@ai-sdk/provider-utils");
37
37
  var import_v43 = require("zod/v4");
38
38
 
39
39
  // src/alibaba-chat-options.ts
40
+ var import_provider_utils = require("@ai-sdk/provider-utils");
40
41
  var import_v4 = require("zod/v4");
41
- var alibabaLanguageModelOptions = import_v4.z.object({
42
- /**
43
- * Enable thinking/reasoning mode for supported models.
44
- * When enabled, the model generates reasoning content before the response.
45
- *
46
- * @default false
47
- */
48
- enableThinking: import_v4.z.boolean().optional(),
49
- /**
50
- * Maximum number of reasoning tokens to generate.
51
- */
52
- thinkingBudget: import_v4.z.number().positive().optional(),
53
- /**
54
- * Whether to preserve reasoning from previous assistant messages.
55
- *
56
- * When enabled, historical reasoning is sent separately as
57
- * `reasoning_content` and Alibaba receives `preserve_thinking: true`.
58
- * Defaults to `true` for models that support preserved thinking; set to
59
- * `false` to opt out.
60
- */
61
- preserveThinking: import_v4.z.boolean().optional(),
62
- /**
63
- * Whether to enable parallel function calling during tool use.
64
- *
65
- * @default true
66
- */
67
- parallelToolCalls: import_v4.z.boolean().optional()
68
- });
42
+ var alibabaLanguageModelOptions = (0, import_provider_utils.lazySchema)(
43
+ () => (0, import_provider_utils.zodSchema)(
44
+ import_v4.z.object({
45
+ /**
46
+ * Enable thinking/reasoning mode for supported models.
47
+ * When enabled, the model generates reasoning content before the response.
48
+ *
49
+ * @default false
50
+ */
51
+ enableThinking: import_v4.z.boolean().optional(),
52
+ /**
53
+ * Maximum number of reasoning tokens to generate.
54
+ */
55
+ thinkingBudget: import_v4.z.number().positive().optional(),
56
+ /**
57
+ * Whether to preserve reasoning from previous assistant messages.
58
+ *
59
+ * When enabled, historical reasoning is sent separately as
60
+ * `reasoning_content` and Alibaba receives `preserve_thinking: true`.
61
+ * Defaults to `true` for models that support preserved thinking; set to
62
+ * `false` to opt out.
63
+ */
64
+ preserveThinking: import_v4.z.boolean().optional(),
65
+ /**
66
+ * Whether to enable parallel function calling during tool use.
67
+ *
68
+ * @default true
69
+ */
70
+ parallelToolCalls: import_v4.z.boolean().optional()
71
+ })
72
+ )
73
+ );
69
74
 
70
75
  // src/alibaba-error.ts
71
- var import_provider_utils = require("@ai-sdk/provider-utils");
76
+ var import_provider_utils2 = require("@ai-sdk/provider-utils");
72
77
  var import_v42 = require("zod/v4");
73
- var alibabaErrorDataSchema = import_v42.z.object({
74
- error: import_v42.z.object({
75
- message: import_v42.z.string(),
76
- code: import_v42.z.string().nullish(),
77
- type: import_v42.z.string().nullish()
78
- })
79
- });
80
- var alibabaFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
78
+ var alibabaErrorDataSchema = (0, import_provider_utils2.lazySchema)(
79
+ () => (0, import_provider_utils2.zodSchema)(
80
+ import_v42.z.object({
81
+ error: import_v42.z.object({
82
+ message: import_v42.z.string(),
83
+ code: import_v42.z.string().nullish(),
84
+ type: import_v42.z.string().nullish()
85
+ })
86
+ })
87
+ )
88
+ );
89
+ var alibabaFailedResponseHandler = (0, import_provider_utils2.createJsonErrorResponseHandler)({
81
90
  errorSchema: alibabaErrorDataSchema,
82
91
  errorToMessage: (data) => data.error.message
83
92
  });
@@ -96,12 +105,12 @@ function convertAlibabaUsage(usage) {
96
105
 
97
106
  // src/convert-to-alibaba-chat-messages.ts
98
107
  var import_provider = require("@ai-sdk/provider");
99
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
108
+ var import_provider_utils3 = require("@ai-sdk/provider-utils");
100
109
  function formatImageUrl({
101
110
  data,
102
111
  mediaType
103
112
  }) {
104
- return data instanceof URL ? data.toString() : `data:${mediaType};base64,${(0, import_provider_utils2.convertToBase64)(data)}`;
113
+ return data instanceof URL ? data.toString() : `data:${mediaType};base64,${(0, import_provider_utils3.convertToBase64)(data)}`;
105
114
  }
106
115
  function convertToAlibabaChatMessages({
107
116
  prompt,
@@ -417,7 +426,7 @@ var AlibabaLanguageModel = class {
417
426
  var _a, _b;
418
427
  const warnings = [];
419
428
  const cacheControlValidator = new CacheControlValidator();
420
- const alibabaOptions = await (0, import_provider_utils3.parseProviderOptions)({
429
+ const alibabaOptions = await (0, import_provider_utils4.parseProviderOptions)({
421
430
  provider: "alibaba",
422
431
  providerOptions,
423
432
  schema: alibabaLanguageModelOptions
@@ -438,7 +447,7 @@ var AlibabaLanguageModel = class {
438
447
  details: `Alibaba does not support JSON Schema output for model ${this.modelId}. JSON Object mode is used instead. The schema was injected into the system message and will only be validated locally.`
439
448
  });
440
449
  }
441
- const resolvedPrompt = useJsonObject ? (0, import_provider_utils3.injectJsonInstructionIntoMessages)({
450
+ const resolvedPrompt = useJsonObject ? (0, import_provider_utils4.injectJsonInstructionIntoMessages)({
442
451
  messages: prompt,
443
452
  schema: responseFormat.schema
444
453
  }) : prompt;
@@ -493,12 +502,12 @@ var AlibabaLanguageModel = class {
493
502
  responseHeaders,
494
503
  value: response,
495
504
  rawValue: rawResponse
496
- } = await (0, import_provider_utils3.postJsonToApi)({
505
+ } = await (0, import_provider_utils4.postJsonToApi)({
497
506
  url: `${this.config.baseURL}/chat/completions`,
498
- headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
507
+ headers: (0, import_provider_utils4.combineHeaders)(this.config.headers(), options.headers),
499
508
  body: args,
500
509
  failedResponseHandler: alibabaFailedResponseHandler,
501
- successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
510
+ successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
502
511
  alibabaChatResponseSchema
503
512
  ),
504
513
  abortSignal: options.abortSignal,
@@ -552,12 +561,12 @@ var AlibabaLanguageModel = class {
552
561
  stream: true,
553
562
  stream_options: this.config.includeUsage ? { include_usage: true } : void 0
554
563
  };
555
- const { responseHeaders, value: response } = await (0, import_provider_utils3.postJsonToApi)({
564
+ const { responseHeaders, value: response } = await (0, import_provider_utils4.postJsonToApi)({
556
565
  url: `${this.config.baseURL}/chat/completions`,
557
- headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
566
+ headers: (0, import_provider_utils4.combineHeaders)(this.config.headers(), options.headers),
558
567
  body,
559
568
  failedResponseHandler: alibabaFailedResponseHandler,
560
- successfulResponseHandler: (0, import_provider_utils3.createEventSourceResponseHandler)(
569
+ successfulResponseHandler: (0, import_provider_utils4.createEventSourceResponseHandler)(
561
570
  alibabaChatChunkSchema
562
571
  ),
563
572
  abortSignal: options.abortSignal,
@@ -606,7 +615,7 @@ var AlibabaLanguageModel = class {
606
615
  controller.enqueue({ type: "text-end", id: "0" });
607
616
  activeText = false;
608
617
  }
609
- activeReasoningId = (0, import_provider_utils3.generateId)();
618
+ activeReasoningId = (0, import_provider_utils4.generateId)();
610
619
  controller.enqueue({
611
620
  type: "reasoning-start",
612
621
  id: activeReasoningId
@@ -685,7 +694,7 @@ var AlibabaLanguageModel = class {
685
694
  delta: toolCall2.function.arguments
686
695
  });
687
696
  }
688
- if ((0, import_provider_utils3.isParsableJson)(toolCall2.function.arguments)) {
697
+ if ((0, import_provider_utils4.isParsableJson)(toolCall2.function.arguments)) {
689
698
  controller.enqueue({
690
699
  type: "tool-input-end",
691
700
  id: toolCall2.id
@@ -712,7 +721,7 @@ var AlibabaLanguageModel = class {
712
721
  delta: toolCallDelta.function.arguments
713
722
  });
714
723
  }
715
- if ((0, import_provider_utils3.isParsableJson)(toolCall.function.arguments)) {
724
+ if ((0, import_provider_utils4.isParsableJson)(toolCall.function.arguments)) {
716
725
  controller.enqueue({
717
726
  type: "tool-input-end",
718
727
  id: toolCall.id
@@ -762,7 +771,7 @@ var AlibabaLanguageModel = class {
762
771
  };
763
772
  }
764
773
  };
765
- var alibabaUsageSchema = import_v43.z.object({
774
+ var alibabaUsageSchema = () => import_v43.z.object({
766
775
  prompt_tokens: import_v43.z.number(),
767
776
  completion_tokens: import_v43.z.number(),
768
777
  total_tokens: import_v43.z.number(),
@@ -774,96 +783,109 @@ var alibabaUsageSchema = import_v43.z.object({
774
783
  reasoning_tokens: import_v43.z.number().nullish()
775
784
  }).nullish()
776
785
  });
777
- var alibabaChatResponseSchema = import_v43.z.object({
778
- id: import_v43.z.string().nullish(),
779
- created: import_v43.z.number().nullish(),
780
- model: import_v43.z.string().nullish(),
781
- choices: import_v43.z.array(
786
+ var alibabaChatResponseSchema = (0, import_provider_utils4.lazySchema)(
787
+ () => (0, import_provider_utils4.zodSchema)(
782
788
  import_v43.z.object({
783
- message: import_v43.z.object({
784
- role: import_v43.z.literal("assistant").nullish(),
785
- content: import_v43.z.string().nullish(),
786
- reasoning_content: import_v43.z.string().nullish(),
787
- // Alibaba thinking mode
788
- tool_calls: import_v43.z.array(
789
- import_v43.z.object({
790
- id: import_v43.z.string(),
791
- type: import_v43.z.literal("function"),
792
- function: import_v43.z.object({
793
- name: import_v43.z.string(),
794
- arguments: import_v43.z.string()
795
- })
796
- })
797
- ).nullish()
798
- }),
799
- finish_reason: import_v43.z.string().nullish(),
800
- index: import_v43.z.number()
789
+ id: import_v43.z.string().nullish(),
790
+ created: import_v43.z.number().nullish(),
791
+ model: import_v43.z.string().nullish(),
792
+ choices: import_v43.z.array(
793
+ import_v43.z.object({
794
+ message: import_v43.z.object({
795
+ role: import_v43.z.literal("assistant").nullish(),
796
+ content: import_v43.z.string().nullish(),
797
+ reasoning_content: import_v43.z.string().nullish(),
798
+ // Alibaba thinking mode
799
+ tool_calls: import_v43.z.array(
800
+ import_v43.z.object({
801
+ id: import_v43.z.string(),
802
+ type: import_v43.z.literal("function"),
803
+ function: import_v43.z.object({
804
+ name: import_v43.z.string(),
805
+ arguments: import_v43.z.string()
806
+ })
807
+ })
808
+ ).nullish()
809
+ }),
810
+ finish_reason: import_v43.z.string().nullish(),
811
+ index: import_v43.z.number()
812
+ })
813
+ ),
814
+ usage: alibabaUsageSchema().nullish()
801
815
  })
802
- ),
803
- usage: alibabaUsageSchema.nullish()
804
- });
805
- var alibabaChatChunkSchema = import_v43.z.object({
806
- id: import_v43.z.string().nullish(),
807
- created: import_v43.z.number().nullish(),
808
- model: import_v43.z.string().nullish(),
809
- choices: import_v43.z.array(
816
+ )
817
+ );
818
+ var alibabaChatChunkSchema = (0, import_provider_utils4.lazySchema)(
819
+ () => (0, import_provider_utils4.zodSchema)(
810
820
  import_v43.z.object({
811
- delta: import_v43.z.object({
812
- role: import_v43.z.enum(["assistant"]).nullish(),
813
- content: import_v43.z.string().nullish(),
814
- reasoning_content: import_v43.z.string().nullish(),
815
- // Alibaba thinking mode delta
816
- tool_calls: import_v43.z.array(
817
- import_v43.z.object({
818
- index: import_v43.z.number().nullish(),
819
- // Index for accumulating tool calls
820
- id: import_v43.z.string().nullish(),
821
- type: import_v43.z.literal("function").nullish(),
822
- function: import_v43.z.object({
823
- name: import_v43.z.string().nullish(),
824
- arguments: import_v43.z.string().nullish()
825
- }).nullish()
826
- })
827
- ).nullish()
828
- }),
829
- finish_reason: import_v43.z.string().nullish(),
830
- index: import_v43.z.number()
821
+ id: import_v43.z.string().nullish(),
822
+ created: import_v43.z.number().nullish(),
823
+ model: import_v43.z.string().nullish(),
824
+ choices: import_v43.z.array(
825
+ import_v43.z.object({
826
+ delta: import_v43.z.object({
827
+ role: import_v43.z.enum(["assistant"]).nullish(),
828
+ content: import_v43.z.string().nullish(),
829
+ reasoning_content: import_v43.z.string().nullish(),
830
+ // Alibaba thinking mode delta
831
+ tool_calls: import_v43.z.array(
832
+ import_v43.z.object({
833
+ index: import_v43.z.number().nullish(),
834
+ // Index for accumulating tool calls
835
+ id: import_v43.z.string().nullish(),
836
+ type: import_v43.z.literal("function").nullish(),
837
+ function: import_v43.z.object({
838
+ name: import_v43.z.string().nullish(),
839
+ arguments: import_v43.z.string().nullish()
840
+ }).nullish()
841
+ })
842
+ ).nullish()
843
+ }),
844
+ finish_reason: import_v43.z.string().nullish(),
845
+ index: import_v43.z.number()
846
+ })
847
+ ),
848
+ usage: alibabaUsageSchema().nullish()
849
+ // Usage only appears in final chunk
831
850
  })
832
- ),
833
- usage: alibabaUsageSchema.nullish()
834
- // Usage only appears in final chunk
835
- });
851
+ )
852
+ );
836
853
 
837
854
  // src/alibaba-embedding-model.ts
838
855
  var import_provider4 = require("@ai-sdk/provider");
839
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
856
+ var import_provider_utils6 = require("@ai-sdk/provider-utils");
840
857
  var import_v45 = require("zod/v4");
841
858
 
842
859
  // src/alibaba-embedding-options.ts
860
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
843
861
  var import_v44 = require("zod/v4");
844
- var alibabaEmbeddingModelOptions = import_v44.z.object({
845
- /**
846
- * Differentiates query text from document text for asymmetric retrieval tasks.
847
- * Defaults to `document`.
848
- */
849
- textType: import_v44.z.enum(["query", "document"]).optional(),
850
- /**
851
- * The dimension of the output embedding vectors. Defaults to 1024.
852
- *
853
- * `text-embedding-v4` also supports 1536 and 2048 dimensions.
854
- */
855
- dimension: import_v44.z.number().optional(),
856
- /**
857
- * The output vector type. Defaults to `dense`.
858
- *
859
- * Sparse-only output is not supported by the AI SDK embedding interface,
860
- * which requires dense number arrays.
861
- */
862
- outputType: import_v44.z.enum(["dense", "sparse", "dense&sparse"]).optional()
863
- });
862
+ var alibabaEmbeddingModelOptions = (0, import_provider_utils5.lazySchema)(
863
+ () => (0, import_provider_utils5.zodSchema)(
864
+ import_v44.z.object({
865
+ /**
866
+ * Differentiates query text from document text for asymmetric retrieval tasks.
867
+ * Defaults to `document`.
868
+ */
869
+ textType: import_v44.z.enum(["query", "document"]).optional(),
870
+ /**
871
+ * The dimension of the output embedding vectors. Defaults to 1024.
872
+ *
873
+ * `text-embedding-v4` also supports 1536 and 2048 dimensions.
874
+ */
875
+ dimension: import_v44.z.number().optional(),
876
+ /**
877
+ * The output vector type. Defaults to `dense`.
878
+ *
879
+ * Sparse-only output is not supported by the AI SDK embedding interface,
880
+ * which requires dense number arrays.
881
+ */
882
+ outputType: import_v44.z.enum(["dense", "sparse", "dense&sparse"]).optional()
883
+ })
884
+ )
885
+ );
864
886
 
865
887
  // src/alibaba-embedding-model.ts
866
- var alibabaEmbeddingFailedResponseHandler = (0, import_provider_utils4.createJsonErrorResponseHandler)({
888
+ var alibabaEmbeddingFailedResponseHandler = (0, import_provider_utils6.createJsonErrorResponseHandler)({
867
889
  errorSchema: import_v45.z.object({
868
890
  code: import_v45.z.string().nullish(),
869
891
  message: import_v45.z.string(),
@@ -896,7 +918,7 @@ var AlibabaEmbeddingModel = class {
896
918
  values
897
919
  });
898
920
  }
899
- const alibabaOptions = await (0, import_provider_utils4.parseProviderOptions)({
921
+ const alibabaOptions = await (0, import_provider_utils6.parseProviderOptions)({
900
922
  provider: "alibaba",
901
923
  providerOptions,
902
924
  schema: alibabaEmbeddingModelOptions
@@ -911,9 +933,9 @@ var AlibabaEmbeddingModel = class {
911
933
  responseHeaders,
912
934
  value: response,
913
935
  rawValue
914
- } = await (0, import_provider_utils4.postJsonToApi)({
936
+ } = await (0, import_provider_utils6.postJsonToApi)({
915
937
  url: `${this.config.baseURL}/services/embeddings/text-embedding/text-embedding`,
916
- headers: (0, import_provider_utils4.combineHeaders)(this.config.headers(), headers),
938
+ headers: (0, import_provider_utils6.combineHeaders)(this.config.headers(), headers),
917
939
  body: {
918
940
  model: this.modelId,
919
941
  input: {
@@ -926,7 +948,7 @@ var AlibabaEmbeddingModel = class {
926
948
  }
927
949
  },
928
950
  failedResponseHandler: alibabaEmbeddingFailedResponseHandler,
929
- successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
951
+ successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(
930
952
  alibabaTextEmbeddingResponseSchema
931
953
  ),
932
954
  abortSignal,
@@ -957,37 +979,41 @@ var AlibabaEmbeddingModel = class {
957
979
  };
958
980
  }
959
981
  };
960
- var alibabaTextEmbeddingSparseEmbeddingSchema = import_v45.z.object({
982
+ var alibabaTextEmbeddingSparseEmbeddingSchema = () => import_v45.z.object({
961
983
  index: import_v45.z.number(),
962
984
  value: import_v45.z.number(),
963
985
  token: import_v45.z.string().nullish()
964
986
  });
965
- var alibabaTextEmbeddingResponseSchema = import_v45.z.object({
966
- output: import_v45.z.object({
967
- embeddings: import_v45.z.array(
968
- import_v45.z.object({
969
- embedding: import_v45.z.array(import_v45.z.number()),
970
- text_index: import_v45.z.number(),
971
- sparse_embedding: import_v45.z.array(alibabaTextEmbeddingSparseEmbeddingSchema).nullish()
972
- })
973
- )
974
- }),
975
- usage: import_v45.z.object({
976
- total_tokens: import_v45.z.number()
977
- }).nullish()
978
- });
987
+ var alibabaTextEmbeddingResponseSchema = (0, import_provider_utils6.lazySchema)(
988
+ () => (0, import_provider_utils6.zodSchema)(
989
+ import_v45.z.object({
990
+ output: import_v45.z.object({
991
+ embeddings: import_v45.z.array(
992
+ import_v45.z.object({
993
+ embedding: import_v45.z.array(import_v45.z.number()),
994
+ text_index: import_v45.z.number(),
995
+ sparse_embedding: import_v45.z.array(alibabaTextEmbeddingSparseEmbeddingSchema()).nullish()
996
+ })
997
+ )
998
+ }),
999
+ usage: import_v45.z.object({
1000
+ total_tokens: import_v45.z.number()
1001
+ }).nullish()
1002
+ })
1003
+ )
1004
+ );
979
1005
 
980
1006
  // src/version.ts
981
- var VERSION = true ? "0.0.33" : "0.0.0-test";
1007
+ var VERSION = true ? "0.0.35" : "0.0.0-test";
982
1008
 
983
1009
  // src/alibaba-provider.ts
984
1010
  function createAlibaba(options = {}) {
985
1011
  var _a, _b;
986
- const baseURL = (_a = (0, import_provider_utils5.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://dashscope-intl.aliyuncs.com/compatible-mode/v1";
987
- const embeddingBaseURL = (_b = (0, import_provider_utils5.withoutTrailingSlash)(options.embeddingBaseURL)) != null ? _b : "https://dashscope-intl.aliyuncs.com/api/v1";
988
- const getHeaders = () => (0, import_provider_utils5.withUserAgentSuffix)(
1012
+ const baseURL = (_a = (0, import_provider_utils7.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://dashscope-intl.aliyuncs.com/compatible-mode/v1";
1013
+ const embeddingBaseURL = (_b = (0, import_provider_utils7.withoutTrailingSlash)(options.embeddingBaseURL)) != null ? _b : "https://dashscope-intl.aliyuncs.com/api/v1";
1014
+ const getHeaders = () => (0, import_provider_utils7.withUserAgentSuffix)(
989
1015
  {
990
- Authorization: `Bearer ${(0, import_provider_utils5.loadApiKey)({
1016
+ Authorization: `Bearer ${(0, import_provider_utils7.loadApiKey)({
991
1017
  apiKey: options.apiKey,
992
1018
  environmentVariableName: "ALIBABA_API_KEY",
993
1019
  description: "Alibaba Cloud (DashScope)"