@ai-sdk/cohere 4.0.0-beta.20 → 4.0.0-beta.21

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/dist/index.js CHANGED
@@ -1,42 +1,29 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- VERSION: () => VERSION,
24
- cohere: () => cohere,
25
- createCohere: () => createCohere
26
- });
27
- module.exports = __toCommonJS(index_exports);
28
-
29
1
  // src/cohere-provider.ts
30
- var import_provider4 = require("@ai-sdk/provider");
31
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
2
+ import {
3
+ NoSuchModelError
4
+ } from "@ai-sdk/provider";
5
+ import {
6
+ generateId,
7
+ loadApiKey,
8
+ withoutTrailingSlash,
9
+ withUserAgentSuffix
10
+ } from "@ai-sdk/provider-utils";
32
11
 
33
12
  // src/cohere-chat-language-model.ts
34
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
35
- var import_v43 = require("zod/v4");
13
+ import {
14
+ combineHeaders,
15
+ createEventSourceResponseHandler,
16
+ createJsonResponseHandler,
17
+ isCustomReasoning,
18
+ mapReasoningToProviderBudget,
19
+ parseProviderOptions,
20
+ postJsonToApi
21
+ } from "@ai-sdk/provider-utils";
22
+ import { z as z3 } from "zod/v4";
36
23
 
37
24
  // src/cohere-chat-options.ts
38
- var import_v4 = require("zod/v4");
39
- var cohereLanguageModelOptions = import_v4.z.object({
25
+ import { z } from "zod/v4";
26
+ var cohereLanguageModelOptions = z.object({
40
27
  /**
41
28
  * Configuration for reasoning features (optional)
42
29
  *
@@ -45,25 +32,27 @@ var cohereLanguageModelOptions = import_v4.z.object({
45
32
  *
46
33
  * @see https://docs.cohere.com/reference/chat#request.body.thinking
47
34
  */
48
- thinking: import_v4.z.object({
49
- type: import_v4.z.enum(["enabled", "disabled"]).optional(),
50
- tokenBudget: import_v4.z.number().optional()
35
+ thinking: z.object({
36
+ type: z.enum(["enabled", "disabled"]).optional(),
37
+ tokenBudget: z.number().optional()
51
38
  }).optional()
52
39
  });
53
40
 
54
41
  // src/cohere-error.ts
55
- var import_provider_utils = require("@ai-sdk/provider-utils");
56
- var import_v42 = require("zod/v4");
57
- var cohereErrorDataSchema = import_v42.z.object({
58
- message: import_v42.z.string()
42
+ import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
43
+ import { z as z2 } from "zod/v4";
44
+ var cohereErrorDataSchema = z2.object({
45
+ message: z2.string()
59
46
  });
60
- var cohereFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
47
+ var cohereFailedResponseHandler = createJsonErrorResponseHandler({
61
48
  errorSchema: cohereErrorDataSchema,
62
49
  errorToMessage: (data) => data.message
63
50
  });
64
51
 
65
52
  // src/cohere-prepare-tools.ts
66
- var import_provider = require("@ai-sdk/provider");
53
+ import {
54
+ UnsupportedFunctionalityError
55
+ } from "@ai-sdk/provider";
67
56
  function prepareTools({
68
57
  tools,
69
58
  toolChoice
@@ -112,7 +101,7 @@ function prepareTools({
112
101
  };
113
102
  default: {
114
103
  const _exhaustiveCheck = type;
115
- throw new import_provider.UnsupportedFunctionalityError({
104
+ throw new UnsupportedFunctionalityError({
116
105
  functionality: `tool choice type: ${_exhaustiveCheck}`
117
106
  });
118
107
  }
@@ -156,8 +145,10 @@ function convertCohereUsage(tokens) {
156
145
  }
157
146
 
158
147
  // src/convert-to-cohere-chat-prompt.ts
159
- var import_provider2 = require("@ai-sdk/provider");
160
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
148
+ import {
149
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError2
150
+ } from "@ai-sdk/provider";
151
+ import { isProviderReference } from "@ai-sdk/provider-utils";
161
152
  function convertToCohereChatPrompt(prompt) {
162
153
  const messages = [];
163
154
  const documents = [];
@@ -178,8 +169,8 @@ function convertToCohereChatPrompt(prompt) {
178
169
  return part.text;
179
170
  }
180
171
  case "file": {
181
- if ((0, import_provider_utils2.isProviderReference)(part.data)) {
182
- throw new import_provider2.UnsupportedFunctionalityError({
172
+ if (isProviderReference(part.data)) {
173
+ throw new UnsupportedFunctionalityError2({
183
174
  functionality: "file parts with provider references"
184
175
  });
185
176
  }
@@ -188,14 +179,14 @@ function convertToCohereChatPrompt(prompt) {
188
179
  textContent = part.data;
189
180
  } else if (part.data instanceof Uint8Array) {
190
181
  if (!(((_a = part.mediaType) == null ? void 0 : _a.startsWith("text/")) || part.mediaType === "application/json")) {
191
- throw new import_provider2.UnsupportedFunctionalityError({
182
+ throw new UnsupportedFunctionalityError2({
192
183
  functionality: `document media type: ${part.mediaType}`,
193
184
  message: `Media type '${part.mediaType}' is not supported. Supported media types are: text/* and application/json.`
194
185
  });
195
186
  }
196
187
  textContent = new TextDecoder().decode(part.data);
197
188
  } else {
198
- throw new import_provider2.UnsupportedFunctionalityError({
189
+ throw new UnsupportedFunctionalityError2({
199
190
  functionality: "File URL data",
200
191
  message: "URLs should be downloaded by the AI SDK and not reach this point. This indicates a configuration issue."
201
192
  });
@@ -329,7 +320,7 @@ var CohereChatLanguageModel = class {
329
320
  }) {
330
321
  var _a;
331
322
  const warnings = [];
332
- const cohereOptions = (_a = await (0, import_provider_utils3.parseProviderOptions)({
323
+ const cohereOptions = (_a = await parseProviderOptions({
333
324
  provider: "cohere",
334
325
  providerOptions,
335
326
  schema: cohereLanguageModelOptions
@@ -384,12 +375,12 @@ var CohereChatLanguageModel = class {
384
375
  responseHeaders,
385
376
  value: response,
386
377
  rawValue: rawResponse
387
- } = await (0, import_provider_utils3.postJsonToApi)({
378
+ } = await postJsonToApi({
388
379
  url: `${this.config.baseURL}/chat`,
389
- headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
380
+ headers: combineHeaders(this.config.headers(), options.headers),
390
381
  body: args,
391
382
  failedResponseHandler: cohereFailedResponseHandler,
392
- successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
383
+ successfulResponseHandler: createJsonResponseHandler(
393
384
  cohereChatResponseSchema
394
385
  ),
395
386
  abortSignal: options.abortSignal,
@@ -453,12 +444,12 @@ var CohereChatLanguageModel = class {
453
444
  }
454
445
  async doStream(options) {
455
446
  const { args, warnings } = await this.getArgs(options);
456
- const { responseHeaders, value: response } = await (0, import_provider_utils3.postJsonToApi)({
447
+ const { responseHeaders, value: response } = await postJsonToApi({
457
448
  url: `${this.config.baseURL}/chat`,
458
- headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
449
+ headers: combineHeaders(this.config.headers(), options.headers),
459
450
  body: { ...args, stream: true },
460
451
  failedResponseHandler: cohereFailedResponseHandler,
461
- successfulResponseHandler: (0, import_provider_utils3.createEventSourceResponseHandler)(
452
+ successfulResponseHandler: createEventSourceResponseHandler(
462
453
  cohereChatChunkSchema
463
454
  ),
464
455
  abortSignal: options.abortSignal,
@@ -639,13 +630,13 @@ function resolveCohereThinking({
639
630
  }
640
631
  };
641
632
  }
642
- if (!(0, import_provider_utils3.isCustomReasoning)(reasoning)) {
633
+ if (!isCustomReasoning(reasoning)) {
643
634
  return {};
644
635
  }
645
636
  if (reasoning === "none") {
646
637
  return { thinking: { type: "disabled" } };
647
638
  }
648
- const tokenBudget = (0, import_provider_utils3.mapReasoningToProviderBudget)({
639
+ const tokenBudget = mapReasoningToProviderBudget({
649
640
  reasoning,
650
641
  maxOutputTokens: 32768,
651
642
  maxReasoningBudget: 32768,
@@ -656,145 +647,145 @@ function resolveCohereThinking({
656
647
  }
657
648
  return { thinking: { type: "enabled", token_budget: tokenBudget } };
658
649
  }
659
- var cohereChatResponseSchema = import_v43.z.object({
660
- generation_id: import_v43.z.string().nullish(),
661
- message: import_v43.z.object({
662
- role: import_v43.z.string(),
663
- content: import_v43.z.array(
664
- import_v43.z.union([
665
- import_v43.z.object({
666
- type: import_v43.z.literal("text"),
667
- text: import_v43.z.string()
650
+ var cohereChatResponseSchema = z3.object({
651
+ generation_id: z3.string().nullish(),
652
+ message: z3.object({
653
+ role: z3.string(),
654
+ content: z3.array(
655
+ z3.union([
656
+ z3.object({
657
+ type: z3.literal("text"),
658
+ text: z3.string()
668
659
  }),
669
- import_v43.z.object({
670
- type: import_v43.z.literal("thinking"),
671
- thinking: import_v43.z.string()
660
+ z3.object({
661
+ type: z3.literal("thinking"),
662
+ thinking: z3.string()
672
663
  })
673
664
  ])
674
665
  ).nullish(),
675
- tool_plan: import_v43.z.string().nullish(),
676
- tool_calls: import_v43.z.array(
677
- import_v43.z.object({
678
- id: import_v43.z.string(),
679
- type: import_v43.z.literal("function"),
680
- function: import_v43.z.object({
681
- name: import_v43.z.string(),
682
- arguments: import_v43.z.string()
666
+ tool_plan: z3.string().nullish(),
667
+ tool_calls: z3.array(
668
+ z3.object({
669
+ id: z3.string(),
670
+ type: z3.literal("function"),
671
+ function: z3.object({
672
+ name: z3.string(),
673
+ arguments: z3.string()
683
674
  })
684
675
  })
685
676
  ).nullish(),
686
- citations: import_v43.z.array(
687
- import_v43.z.object({
688
- start: import_v43.z.number(),
689
- end: import_v43.z.number(),
690
- text: import_v43.z.string(),
691
- sources: import_v43.z.array(
692
- import_v43.z.object({
693
- type: import_v43.z.string().optional(),
694
- id: import_v43.z.string().optional(),
695
- document: import_v43.z.object({
696
- id: import_v43.z.string().optional(),
697
- text: import_v43.z.string(),
698
- title: import_v43.z.string()
677
+ citations: z3.array(
678
+ z3.object({
679
+ start: z3.number(),
680
+ end: z3.number(),
681
+ text: z3.string(),
682
+ sources: z3.array(
683
+ z3.object({
684
+ type: z3.string().optional(),
685
+ id: z3.string().optional(),
686
+ document: z3.object({
687
+ id: z3.string().optional(),
688
+ text: z3.string(),
689
+ title: z3.string()
699
690
  })
700
691
  })
701
692
  ),
702
- type: import_v43.z.string().optional()
693
+ type: z3.string().optional()
703
694
  })
704
695
  ).nullish()
705
696
  }),
706
- finish_reason: import_v43.z.string(),
707
- usage: import_v43.z.object({
708
- billed_units: import_v43.z.object({
709
- input_tokens: import_v43.z.number(),
710
- output_tokens: import_v43.z.number()
697
+ finish_reason: z3.string(),
698
+ usage: z3.object({
699
+ billed_units: z3.object({
700
+ input_tokens: z3.number(),
701
+ output_tokens: z3.number()
711
702
  }),
712
- tokens: import_v43.z.object({
713
- input_tokens: import_v43.z.number(),
714
- output_tokens: import_v43.z.number()
703
+ tokens: z3.object({
704
+ input_tokens: z3.number(),
705
+ output_tokens: z3.number()
715
706
  })
716
707
  })
717
708
  });
718
- var cohereChatChunkSchema = import_v43.z.discriminatedUnion("type", [
719
- import_v43.z.object({
720
- type: import_v43.z.literal("citation-start")
709
+ var cohereChatChunkSchema = z3.discriminatedUnion("type", [
710
+ z3.object({
711
+ type: z3.literal("citation-start")
721
712
  }),
722
- import_v43.z.object({
723
- type: import_v43.z.literal("citation-end")
713
+ z3.object({
714
+ type: z3.literal("citation-end")
724
715
  }),
725
- import_v43.z.object({
726
- type: import_v43.z.literal("content-start"),
727
- index: import_v43.z.number(),
728
- delta: import_v43.z.object({
729
- message: import_v43.z.object({
730
- content: import_v43.z.union([
731
- import_v43.z.object({
732
- type: import_v43.z.literal("text"),
733
- text: import_v43.z.string()
716
+ z3.object({
717
+ type: z3.literal("content-start"),
718
+ index: z3.number(),
719
+ delta: z3.object({
720
+ message: z3.object({
721
+ content: z3.union([
722
+ z3.object({
723
+ type: z3.literal("text"),
724
+ text: z3.string()
734
725
  }),
735
- import_v43.z.object({
736
- type: import_v43.z.literal("thinking"),
737
- thinking: import_v43.z.string()
726
+ z3.object({
727
+ type: z3.literal("thinking"),
728
+ thinking: z3.string()
738
729
  })
739
730
  ])
740
731
  })
741
732
  })
742
733
  }),
743
- import_v43.z.object({
744
- type: import_v43.z.literal("content-delta"),
745
- index: import_v43.z.number(),
746
- delta: import_v43.z.object({
747
- message: import_v43.z.object({
748
- content: import_v43.z.union([
749
- import_v43.z.object({
750
- text: import_v43.z.string()
734
+ z3.object({
735
+ type: z3.literal("content-delta"),
736
+ index: z3.number(),
737
+ delta: z3.object({
738
+ message: z3.object({
739
+ content: z3.union([
740
+ z3.object({
741
+ text: z3.string()
751
742
  }),
752
- import_v43.z.object({
753
- thinking: import_v43.z.string()
743
+ z3.object({
744
+ thinking: z3.string()
754
745
  })
755
746
  ])
756
747
  })
757
748
  })
758
749
  }),
759
- import_v43.z.object({
760
- type: import_v43.z.literal("content-end"),
761
- index: import_v43.z.number()
750
+ z3.object({
751
+ type: z3.literal("content-end"),
752
+ index: z3.number()
762
753
  }),
763
- import_v43.z.object({
764
- type: import_v43.z.literal("message-start"),
765
- id: import_v43.z.string().nullish()
754
+ z3.object({
755
+ type: z3.literal("message-start"),
756
+ id: z3.string().nullish()
766
757
  }),
767
- import_v43.z.object({
768
- type: import_v43.z.literal("message-end"),
769
- delta: import_v43.z.object({
770
- finish_reason: import_v43.z.string(),
771
- usage: import_v43.z.object({
772
- tokens: import_v43.z.object({
773
- input_tokens: import_v43.z.number(),
774
- output_tokens: import_v43.z.number()
758
+ z3.object({
759
+ type: z3.literal("message-end"),
760
+ delta: z3.object({
761
+ finish_reason: z3.string(),
762
+ usage: z3.object({
763
+ tokens: z3.object({
764
+ input_tokens: z3.number(),
765
+ output_tokens: z3.number()
775
766
  })
776
767
  })
777
768
  })
778
769
  }),
779
770
  // https://docs.cohere.com/v2/docs/streaming#tool-use-stream-events-for-tool-calling
780
- import_v43.z.object({
781
- type: import_v43.z.literal("tool-plan-delta"),
782
- delta: import_v43.z.object({
783
- message: import_v43.z.object({
784
- tool_plan: import_v43.z.string()
771
+ z3.object({
772
+ type: z3.literal("tool-plan-delta"),
773
+ delta: z3.object({
774
+ message: z3.object({
775
+ tool_plan: z3.string()
785
776
  })
786
777
  })
787
778
  }),
788
- import_v43.z.object({
789
- type: import_v43.z.literal("tool-call-start"),
790
- delta: import_v43.z.object({
791
- message: import_v43.z.object({
792
- tool_calls: import_v43.z.object({
793
- id: import_v43.z.string(),
794
- type: import_v43.z.literal("function"),
795
- function: import_v43.z.object({
796
- name: import_v43.z.string(),
797
- arguments: import_v43.z.string()
779
+ z3.object({
780
+ type: z3.literal("tool-call-start"),
781
+ delta: z3.object({
782
+ message: z3.object({
783
+ tool_calls: z3.object({
784
+ id: z3.string(),
785
+ type: z3.literal("function"),
786
+ function: z3.object({
787
+ name: z3.string(),
788
+ arguments: z3.string()
798
789
  })
799
790
  })
800
791
  })
@@ -803,31 +794,38 @@ var cohereChatChunkSchema = import_v43.z.discriminatedUnion("type", [
803
794
  // A single tool call's `arguments` stream in chunks and must be accumulated
804
795
  // in a string and so the full tool object info can only be parsed once we see
805
796
  // `tool-call-end`.
806
- import_v43.z.object({
807
- type: import_v43.z.literal("tool-call-delta"),
808
- delta: import_v43.z.object({
809
- message: import_v43.z.object({
810
- tool_calls: import_v43.z.object({
811
- function: import_v43.z.object({
812
- arguments: import_v43.z.string()
797
+ z3.object({
798
+ type: z3.literal("tool-call-delta"),
799
+ delta: z3.object({
800
+ message: z3.object({
801
+ tool_calls: z3.object({
802
+ function: z3.object({
803
+ arguments: z3.string()
813
804
  })
814
805
  })
815
806
  })
816
807
  })
817
808
  }),
818
- import_v43.z.object({
819
- type: import_v43.z.literal("tool-call-end")
809
+ z3.object({
810
+ type: z3.literal("tool-call-end")
820
811
  })
821
812
  ]);
822
813
 
823
814
  // src/cohere-embedding-model.ts
824
- var import_provider3 = require("@ai-sdk/provider");
825
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
826
- var import_v45 = require("zod/v4");
815
+ import {
816
+ TooManyEmbeddingValuesForCallError
817
+ } from "@ai-sdk/provider";
818
+ import {
819
+ combineHeaders as combineHeaders2,
820
+ createJsonResponseHandler as createJsonResponseHandler2,
821
+ parseProviderOptions as parseProviderOptions2,
822
+ postJsonToApi as postJsonToApi2
823
+ } from "@ai-sdk/provider-utils";
824
+ import { z as z5 } from "zod/v4";
827
825
 
828
826
  // src/cohere-embedding-options.ts
829
- var import_v44 = require("zod/v4");
830
- var cohereEmbeddingModelOptions = import_v44.z.object({
827
+ import { z as z4 } from "zod/v4";
828
+ var cohereEmbeddingModelOptions = z4.object({
831
829
  /**
832
830
  * Specifies the type of input passed to the model. Default is `search_query`.
833
831
  *
@@ -836,7 +834,7 @@ var cohereEmbeddingModelOptions = import_v44.z.object({
836
834
  * - "classification": Used for embeddings passed through a text classifier.
837
835
  * - "clustering": Used for embeddings run through a clustering algorithm.
838
836
  */
839
- inputType: import_v44.z.enum(["search_document", "search_query", "classification", "clustering"]).optional(),
837
+ inputType: z4.enum(["search_document", "search_query", "classification", "clustering"]).optional(),
840
838
  /**
841
839
  * Specifies how the API will handle inputs longer than the maximum token length.
842
840
  * Default is `END`.
@@ -845,7 +843,7 @@ var cohereEmbeddingModelOptions = import_v44.z.object({
845
843
  * - "START": Will discard the start of the input until the remaining input is exactly the maximum input token length for the model.
846
844
  * - "END": Will discard the end of the input until the remaining input is exactly the maximum input token length for the model.
847
845
  */
848
- truncate: import_v44.z.enum(["NONE", "START", "END"]).optional(),
846
+ truncate: z4.enum(["NONE", "START", "END"]).optional(),
849
847
  /**
850
848
  * The number of dimensions of the output embedding.
851
849
  * Only available for `embed-v4.0` and newer models.
@@ -853,7 +851,7 @@ var cohereEmbeddingModelOptions = import_v44.z.object({
853
851
  * Possible values are `256`, `512`, `1024`, and `1536`.
854
852
  * The default is `1536`.
855
853
  */
856
- outputDimension: import_v44.z.union([import_v44.z.literal(256), import_v44.z.literal(512), import_v44.z.literal(1024), import_v44.z.literal(1536)]).optional()
854
+ outputDimension: z4.union([z4.literal(256), z4.literal(512), z4.literal(1024), z4.literal(1536)]).optional()
857
855
  });
858
856
 
859
857
  // src/cohere-embedding-model.ts
@@ -875,13 +873,13 @@ var CohereEmbeddingModel = class {
875
873
  providerOptions
876
874
  }) {
877
875
  var _a;
878
- const embeddingOptions = await (0, import_provider_utils4.parseProviderOptions)({
876
+ const embeddingOptions = await parseProviderOptions2({
879
877
  provider: "cohere",
880
878
  providerOptions,
881
879
  schema: cohereEmbeddingModelOptions
882
880
  });
883
881
  if (values.length > this.maxEmbeddingsPerCall) {
884
- throw new import_provider3.TooManyEmbeddingValuesForCallError({
882
+ throw new TooManyEmbeddingValuesForCallError({
885
883
  provider: this.provider,
886
884
  modelId: this.modelId,
887
885
  maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
@@ -892,9 +890,9 @@ var CohereEmbeddingModel = class {
892
890
  responseHeaders,
893
891
  value: response,
894
892
  rawValue
895
- } = await (0, import_provider_utils4.postJsonToApi)({
893
+ } = await postJsonToApi2({
896
894
  url: `${this.config.baseURL}/embed`,
897
- headers: (0, import_provider_utils4.combineHeaders)(this.config.headers(), headers),
895
+ headers: combineHeaders2(this.config.headers(), headers),
898
896
  body: {
899
897
  model: this.modelId,
900
898
  // The AI SDK only supports 'float' embeddings. Note that the Cohere API
@@ -907,7 +905,7 @@ var CohereEmbeddingModel = class {
907
905
  output_dimension: embeddingOptions == null ? void 0 : embeddingOptions.outputDimension
908
906
  },
909
907
  failedResponseHandler: cohereFailedResponseHandler,
910
- successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
908
+ successfulResponseHandler: createJsonResponseHandler2(
911
909
  cohereTextEmbeddingResponseSchema
912
910
  ),
913
911
  abortSignal,
@@ -921,46 +919,51 @@ var CohereEmbeddingModel = class {
921
919
  };
922
920
  }
923
921
  };
924
- var cohereTextEmbeddingResponseSchema = import_v45.z.object({
925
- embeddings: import_v45.z.object({
926
- float: import_v45.z.array(import_v45.z.array(import_v45.z.number()))
922
+ var cohereTextEmbeddingResponseSchema = z5.object({
923
+ embeddings: z5.object({
924
+ float: z5.array(z5.array(z5.number()))
927
925
  }),
928
- meta: import_v45.z.object({
929
- billed_units: import_v45.z.object({
930
- input_tokens: import_v45.z.number()
926
+ meta: z5.object({
927
+ billed_units: z5.object({
928
+ input_tokens: z5.number()
931
929
  })
932
930
  })
933
931
  });
934
932
 
935
933
  // src/reranking/cohere-reranking-model.ts
936
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
934
+ import {
935
+ combineHeaders as combineHeaders3,
936
+ createJsonResponseHandler as createJsonResponseHandler3,
937
+ parseProviderOptions as parseProviderOptions3,
938
+ postJsonToApi as postJsonToApi3
939
+ } from "@ai-sdk/provider-utils";
937
940
 
938
941
  // src/reranking/cohere-reranking-api.ts
939
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
940
- var import_v46 = require("zod/v4");
941
- var cohereRerankingResponseSchema = (0, import_provider_utils5.lazySchema)(
942
- () => (0, import_provider_utils5.zodSchema)(
943
- import_v46.z.object({
944
- id: import_v46.z.string().nullish(),
945
- results: import_v46.z.array(
946
- import_v46.z.object({
947
- index: import_v46.z.number(),
948
- relevance_score: import_v46.z.number()
942
+ import { lazySchema, zodSchema } from "@ai-sdk/provider-utils";
943
+ import { z as z6 } from "zod/v4";
944
+ var cohereRerankingResponseSchema = lazySchema(
945
+ () => zodSchema(
946
+ z6.object({
947
+ id: z6.string().nullish(),
948
+ results: z6.array(
949
+ z6.object({
950
+ index: z6.number(),
951
+ relevance_score: z6.number()
949
952
  })
950
953
  ),
951
- meta: import_v46.z.any()
954
+ meta: z6.any()
952
955
  })
953
956
  )
954
957
  );
955
958
 
956
959
  // src/reranking/cohere-reranking-options.ts
957
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
958
- var import_v47 = require("zod/v4");
959
- var cohereRerankingModelOptionsSchema = (0, import_provider_utils6.lazySchema)(
960
- () => (0, import_provider_utils6.zodSchema)(
961
- import_v47.z.object({
962
- maxTokensPerDoc: import_v47.z.number().optional(),
963
- priority: import_v47.z.number().optional()
960
+ import { lazySchema as lazySchema2, zodSchema as zodSchema2 } from "@ai-sdk/provider-utils";
961
+ import { z as z7 } from "zod/v4";
962
+ var cohereRerankingModelOptionsSchema = lazySchema2(
963
+ () => zodSchema2(
964
+ z7.object({
965
+ maxTokensPerDoc: z7.number().optional(),
966
+ priority: z7.number().optional()
964
967
  })
965
968
  )
966
969
  );
@@ -985,7 +988,7 @@ var CohereRerankingModel = class {
985
988
  providerOptions
986
989
  }) {
987
990
  var _a;
988
- const rerankingOptions = await (0, import_provider_utils7.parseProviderOptions)({
991
+ const rerankingOptions = await parseProviderOptions3({
989
992
  provider: "cohere",
990
993
  providerOptions,
991
994
  schema: cohereRerankingModelOptionsSchema
@@ -1002,9 +1005,9 @@ var CohereRerankingModel = class {
1002
1005
  responseHeaders,
1003
1006
  value: response,
1004
1007
  rawValue
1005
- } = await (0, import_provider_utils7.postJsonToApi)({
1008
+ } = await postJsonToApi3({
1006
1009
  url: `${this.config.baseURL}/rerank`,
1007
- headers: (0, import_provider_utils7.combineHeaders)(this.config.headers(), headers),
1010
+ headers: combineHeaders3(this.config.headers(), headers),
1008
1011
  body: {
1009
1012
  model: this.modelId,
1010
1013
  query,
@@ -1014,7 +1017,7 @@ var CohereRerankingModel = class {
1014
1017
  priority: rerankingOptions == null ? void 0 : rerankingOptions.priority
1015
1018
  },
1016
1019
  failedResponseHandler: cohereFailedResponseHandler,
1017
- successfulResponseHandler: (0, import_provider_utils7.createJsonResponseHandler)(
1020
+ successfulResponseHandler: createJsonResponseHandler3(
1018
1021
  cohereRerankingResponseSchema
1019
1022
  ),
1020
1023
  abortSignal,
@@ -1036,15 +1039,15 @@ var CohereRerankingModel = class {
1036
1039
  };
1037
1040
 
1038
1041
  // src/version.ts
1039
- var VERSION = true ? "4.0.0-beta.20" : "0.0.0-test";
1042
+ var VERSION = true ? "4.0.0-beta.21" : "0.0.0-test";
1040
1043
 
1041
1044
  // src/cohere-provider.ts
1042
1045
  function createCohere(options = {}) {
1043
1046
  var _a;
1044
- const baseURL = (_a = (0, import_provider_utils8.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.cohere.com/v2";
1045
- const getHeaders = () => (0, import_provider_utils8.withUserAgentSuffix)(
1047
+ const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : "https://api.cohere.com/v2";
1048
+ const getHeaders = () => withUserAgentSuffix(
1046
1049
  {
1047
- Authorization: `Bearer ${(0, import_provider_utils8.loadApiKey)({
1050
+ Authorization: `Bearer ${loadApiKey({
1048
1051
  apiKey: options.apiKey,
1049
1052
  environmentVariableName: "COHERE_API_KEY",
1050
1053
  description: "Cohere"
@@ -1060,7 +1063,7 @@ function createCohere(options = {}) {
1060
1063
  baseURL,
1061
1064
  headers: getHeaders,
1062
1065
  fetch: options.fetch,
1063
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils8.generateId
1066
+ generateId: (_a2 = options.generateId) != null ? _a2 : generateId
1064
1067
  });
1065
1068
  };
1066
1069
  const createEmbeddingModel = (modelId) => new CohereEmbeddingModel(modelId, {
@@ -1092,15 +1095,14 @@ function createCohere(options = {}) {
1092
1095
  provider.reranking = createRerankingModel;
1093
1096
  provider.rerankingModel = createRerankingModel;
1094
1097
  provider.imageModel = (modelId) => {
1095
- throw new import_provider4.NoSuchModelError({ modelId, modelType: "imageModel" });
1098
+ throw new NoSuchModelError({ modelId, modelType: "imageModel" });
1096
1099
  };
1097
1100
  return provider;
1098
1101
  }
1099
1102
  var cohere = createCohere();
1100
- // Annotate the CommonJS export names for ESM import in node:
1101
- 0 && (module.exports = {
1103
+ export {
1102
1104
  VERSION,
1103
1105
  cohere,
1104
1106
  createCohere
1105
- });
1107
+ };
1106
1108
  //# sourceMappingURL=index.js.map