@ai-sdk/google-vertex 4.0.146 → 4.0.148

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.
@@ -26,14 +26,14 @@ __export(index_exports, {
26
26
  module.exports = __toCommonJS(index_exports);
27
27
 
28
28
  // src/edge/google-vertex-provider-edge.ts
29
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
29
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
30
30
 
31
31
  // src/google-vertex-provider.ts
32
32
  var import_internal3 = require("@ai-sdk/google/internal");
33
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
33
+ var import_provider_utils6 = require("@ai-sdk/provider-utils");
34
34
 
35
35
  // src/version.ts
36
- var VERSION = true ? "4.0.146" : "0.0.0-test";
36
+ var VERSION = true ? "4.0.148" : "0.0.0-test";
37
37
 
38
38
  // src/google-vertex-embedding-model.ts
39
39
  var import_provider = require("@ai-sdk/provider");
@@ -104,7 +104,6 @@ var googleVertexEmbeddingModelOptions = import_v42.z.object({
104
104
  var GoogleVertexEmbeddingModel = class {
105
105
  constructor(modelId, config) {
106
106
  this.specificationVersion = "v3";
107
- this.maxEmbeddingsPerCall = 2048;
108
107
  this.supportsParallelCalls = true;
109
108
  this.modelId = modelId;
110
109
  this.config = config;
@@ -112,12 +111,18 @@ var GoogleVertexEmbeddingModel = class {
112
111
  get provider() {
113
112
  return this.config.provider;
114
113
  }
114
+ // gemini-embedding-2 models only support :embedContent (one value per call),
115
+ // not the :predict batch endpoint. https://github.com/vercel/ai/issues/15853
116
+ get maxEmbeddingsPerCall() {
117
+ return usesEmbedContentEndpoint(this.modelId) ? 1 : 2048;
118
+ }
115
119
  async doEmbed({
116
120
  values,
117
121
  headers,
118
122
  abortSignal,
119
123
  providerOptions
120
124
  }) {
125
+ var _a;
121
126
  let googleOptions = await (0, import_provider_utils2.parseProviderOptions)({
122
127
  provider: "vertex",
123
128
  providerOptions,
@@ -143,6 +148,37 @@ var GoogleVertexEmbeddingModel = class {
143
148
  await (0, import_provider_utils2.resolve)(this.config.headers),
144
149
  headers
145
150
  );
151
+ if (usesEmbedContentEndpoint(this.modelId)) {
152
+ const {
153
+ responseHeaders: responseHeaders2,
154
+ value: response2,
155
+ rawValue: rawValue2
156
+ } = await (0, import_provider_utils2.postJsonToApi)({
157
+ url: `${this.config.baseURL}/models/${this.modelId}:embedContent`,
158
+ headers: mergedHeaders,
159
+ body: {
160
+ content: { parts: [{ text: values[0] }] },
161
+ embedContentConfig: {
162
+ outputDimensionality: googleOptions.outputDimensionality,
163
+ taskType: googleOptions.taskType,
164
+ title: googleOptions.title,
165
+ autoTruncate: googleOptions.autoTruncate
166
+ }
167
+ },
168
+ failedResponseHandler: googleVertexFailedResponseHandler,
169
+ successfulResponseHandler: (0, import_provider_utils2.createJsonResponseHandler)(
170
+ googleVertexEmbedContentResponseSchema
171
+ ),
172
+ abortSignal,
173
+ fetch: this.config.fetch
174
+ });
175
+ return {
176
+ warnings: [],
177
+ embeddings: [response2.embedding.values],
178
+ usage: ((_a = response2.usageMetadata) == null ? void 0 : _a.promptTokenCount) == null ? void 0 : { tokens: response2.usageMetadata.promptTokenCount },
179
+ response: { headers: responseHeaders2, body: rawValue2 }
180
+ };
181
+ }
146
182
  const url = `${this.config.baseURL}/models/${this.modelId}:predict`;
147
183
  const {
148
184
  responseHeaders,
@@ -196,6 +232,17 @@ var googleVertexTextEmbeddingResponseSchema = import_v43.z.object({
196
232
  })
197
233
  )
198
234
  });
235
+ var googleVertexEmbedContentResponseSchema = import_v43.z.object({
236
+ embedding: import_v43.z.object({
237
+ values: import_v43.z.array(import_v43.z.number())
238
+ }),
239
+ usageMetadata: import_v43.z.object({
240
+ promptTokenCount: import_v43.z.number().nullish()
241
+ }).nullish()
242
+ });
243
+ function usesEmbedContentEndpoint(modelId) {
244
+ return modelId === "gemini-embedding-2" || modelId === "gemini-embedding-2-preview";
245
+ }
199
246
 
200
247
  // src/google-vertex-image-model.ts
201
248
  var import_internal = require("@ai-sdk/google/internal");
@@ -539,10 +586,182 @@ var googleVertexTools = {
539
586
  vertexRagStore: import_internal2.googleTools.vertexRagStore
540
587
  };
541
588
 
542
- // src/google-vertex-video-model.ts
543
- var import_provider2 = require("@ai-sdk/provider");
589
+ // src/google-vertex-transcription-model.ts
544
590
  var import_provider_utils4 = require("@ai-sdk/provider-utils");
591
+ var import_v46 = require("zod/v4");
592
+
593
+ // src/google-vertex-transcription-model-options.ts
545
594
  var import_v45 = require("zod/v4");
595
+ var googleVertexTranscriptionProviderOptionsSchema = import_v45.z.object({
596
+ /**
597
+ * BCP-47 language codes to recognize (e.g. `['en-US']`), or `['auto']` to let
598
+ * Chirp auto-detect the spoken language. Defaults to `['auto']`. For
599
+ * `telephony`, pass a supported explicit language code.
600
+ */
601
+ languageCodes: import_v45.z.array(import_v45.z.string()).optional(),
602
+ /**
603
+ * Whether to add punctuation to the transcript. Defaults to `true`.
604
+ */
605
+ enableAutomaticPunctuation: import_v45.z.boolean().optional(),
606
+ /**
607
+ * Whether to include word-level timestamps. Defaults to `true` so the
608
+ * transcription result can include segments.
609
+ *
610
+ * Enabling word-level timestamps can reduce transcription quality and speed
611
+ * for Chirp models.
612
+ */
613
+ enableWordTimeOffsets: import_v45.z.boolean().optional(),
614
+ /**
615
+ * The Cloud Speech-to-Text region for the request (e.g. `'us'`, `'eu'`,
616
+ * `'us-central1'`). Defaults to the provider `location`.
617
+ *
618
+ * Note: Speech-to-Text regions differ from Vertex AI regions. Chirp is only
619
+ * available in specific Speech-to-Text regions and is not available in the
620
+ * `global` location.
621
+ */
622
+ region: import_v45.z.string().optional()
623
+ });
624
+
625
+ // src/google-vertex-transcription-model.ts
626
+ function parseDurationSeconds(value) {
627
+ if (value == null) {
628
+ return void 0;
629
+ }
630
+ const seconds = Number.parseFloat(value);
631
+ return Number.isFinite(seconds) ? seconds : void 0;
632
+ }
633
+ function convertBcp47ToIso6391(value) {
634
+ if (value == null) {
635
+ return void 0;
636
+ }
637
+ try {
638
+ const language = new Intl.Locale(value).language;
639
+ return language.length === 2 ? language : void 0;
640
+ } catch (e) {
641
+ return void 0;
642
+ }
643
+ }
644
+ var GoogleVertexTranscriptionModel = class {
645
+ constructor(modelId, config) {
646
+ this.modelId = modelId;
647
+ this.config = config;
648
+ this.specificationVersion = "v3";
649
+ }
650
+ get provider() {
651
+ return this.config.provider;
652
+ }
653
+ async doGenerate(options) {
654
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
655
+ const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
656
+ const warnings = [];
657
+ let googleOptions;
658
+ for (const provider of ["googleVertex", "vertex", "google"]) {
659
+ googleOptions = await (0, import_provider_utils4.parseProviderOptions)({
660
+ provider,
661
+ providerOptions: options.providerOptions,
662
+ schema: googleVertexTranscriptionProviderOptionsSchema
663
+ });
664
+ if (googleOptions != null) {
665
+ break;
666
+ }
667
+ }
668
+ const region = (_d = googleOptions == null ? void 0 : googleOptions.region) != null ? _d : this.config.location;
669
+ const languageCodes = (_e = googleOptions == null ? void 0 : googleOptions.languageCodes) != null ? _e : ["auto"];
670
+ const content = typeof options.audio === "string" ? options.audio : (0, import_provider_utils4.convertUint8ArrayToBase64)(options.audio);
671
+ const requestBody = {
672
+ config: {
673
+ model: this.modelId,
674
+ languageCodes,
675
+ // Let Speech-to-Text auto-detect the audio encoding (wav/mp3/flac/…).
676
+ autoDecodingConfig: {},
677
+ features: {
678
+ // Word timing populates `segments`.
679
+ enableWordTimeOffsets: (_f = googleOptions == null ? void 0 : googleOptions.enableWordTimeOffsets) != null ? _f : true,
680
+ enableAutomaticPunctuation: (_g = googleOptions == null ? void 0 : googleOptions.enableAutomaticPunctuation) != null ? _g : true
681
+ }
682
+ },
683
+ content
684
+ };
685
+ const host = region === "global" ? "speech.googleapis.com" : `${region}-speech.googleapis.com`;
686
+ const url = `https://${host}/v2/projects/${this.config.project}/locations/${region}/recognizers/_:recognize`;
687
+ const {
688
+ value: response,
689
+ responseHeaders,
690
+ rawValue: rawResponse
691
+ } = await (0, import_provider_utils4.postJsonToApi)({
692
+ url,
693
+ headers: (0, import_provider_utils4.combineHeaders)(
694
+ this.config.headers ? await (0, import_provider_utils4.resolve)(this.config.headers) : void 0,
695
+ options.headers
696
+ ),
697
+ body: requestBody,
698
+ failedResponseHandler: googleVertexFailedResponseHandler,
699
+ successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
700
+ googleVertexTranscriptionResponseSchema
701
+ ),
702
+ abortSignal: options.abortSignal,
703
+ fetch: this.config.fetch
704
+ });
705
+ const results = (_h = response.results) != null ? _h : [];
706
+ const text = results.map((result) => {
707
+ var _a2, _b2, _c2;
708
+ return (_c2 = (_b2 = (_a2 = result.alternatives) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.transcript) != null ? _c2 : "";
709
+ }).join(" ").trim();
710
+ const segments = results.flatMap(
711
+ (result) => {
712
+ var _a2, _b2, _c2, _d2;
713
+ return (_d2 = (_c2 = (_b2 = (_a2 = result.alternatives) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.words) == null ? void 0 : _c2.flatMap((word) => {
714
+ const startSecond = parseDurationSeconds(word.startOffset);
715
+ const endSecond = parseDurationSeconds(word.endOffset);
716
+ return word.word == null || startSecond == null || endSecond == null ? [] : [{ text: word.word, startSecond, endSecond }];
717
+ })) != null ? _d2 : [];
718
+ }
719
+ );
720
+ const language = convertBcp47ToIso6391((_i = results[0]) == null ? void 0 : _i.languageCode);
721
+ return {
722
+ text,
723
+ segments,
724
+ language,
725
+ durationInSeconds: parseDurationSeconds(
726
+ (_j = response.metadata) == null ? void 0 : _j.totalBilledDuration
727
+ ),
728
+ warnings,
729
+ response: {
730
+ timestamp: currentDate,
731
+ modelId: this.modelId,
732
+ headers: responseHeaders,
733
+ body: rawResponse
734
+ }
735
+ };
736
+ }
737
+ };
738
+ var googleVertexTranscriptionResponseSchema = import_v46.z.object({
739
+ results: import_v46.z.array(
740
+ import_v46.z.object({
741
+ alternatives: import_v46.z.array(
742
+ import_v46.z.object({
743
+ transcript: import_v46.z.string().nullish(),
744
+ words: import_v46.z.array(
745
+ import_v46.z.object({
746
+ word: import_v46.z.string().nullish(),
747
+ startOffset: import_v46.z.string().nullish(),
748
+ endOffset: import_v46.z.string().nullish()
749
+ })
750
+ ).nullish()
751
+ })
752
+ ).nullish(),
753
+ languageCode: import_v46.z.string().nullish()
754
+ })
755
+ ).nullish(),
756
+ metadata: import_v46.z.object({
757
+ totalBilledDuration: import_v46.z.string().nullish()
758
+ }).nullish()
759
+ });
760
+
761
+ // src/google-vertex-video-model.ts
762
+ var import_provider2 = require("@ai-sdk/provider");
763
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
764
+ var import_v47 = require("zod/v4");
546
765
  var GoogleVertexVideoModel = class {
547
766
  constructor(modelId, config) {
548
767
  this.modelId = modelId;
@@ -559,7 +778,7 @@ var GoogleVertexVideoModel = class {
559
778
  var _a, _b, _c, _d, _e, _f;
560
779
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
561
780
  const warnings = [];
562
- const vertexOptions = await (0, import_provider_utils4.parseProviderOptions)({
781
+ const vertexOptions = await (0, import_provider_utils5.parseProviderOptions)({
563
782
  provider: "vertex",
564
783
  providerOptions: options.providerOptions,
565
784
  schema: googleVertexVideoModelOptionsSchema
@@ -577,7 +796,7 @@ var GoogleVertexVideoModel = class {
577
796
  details: "Vertex AI video models require base64-encoded images or GCS URIs. URL will be ignored."
578
797
  });
579
798
  } else {
580
- const base64Data = typeof options.image.data === "string" ? options.image.data : (0, import_provider_utils4.convertUint8ArrayToBase64)(options.image.data);
799
+ const base64Data = typeof options.image.data === "string" ? options.image.data : (0, import_provider_utils5.convertUint8ArrayToBase64)(options.image.data);
581
800
  instance.image = {
582
801
  bytesBase64Encoded: base64Data,
583
802
  mimeType: options.image.mediaType
@@ -635,17 +854,17 @@ var GoogleVertexVideoModel = class {
635
854
  }
636
855
  }
637
856
  }
638
- const { value: operation } = await (0, import_provider_utils4.postJsonToApi)({
857
+ const { value: operation } = await (0, import_provider_utils5.postJsonToApi)({
639
858
  url: `${this.config.baseURL}/models/${this.modelId}:predictLongRunning`,
640
- headers: (0, import_provider_utils4.combineHeaders)(
641
- await (0, import_provider_utils4.resolve)(this.config.headers),
859
+ headers: (0, import_provider_utils5.combineHeaders)(
860
+ await (0, import_provider_utils5.resolve)(this.config.headers),
642
861
  options.headers
643
862
  ),
644
863
  body: {
645
864
  instances,
646
865
  parameters
647
866
  },
648
- successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
867
+ successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
649
868
  vertexOperationSchema
650
869
  ),
651
870
  failedResponseHandler: googleVertexFailedResponseHandler,
@@ -671,23 +890,23 @@ var GoogleVertexVideoModel = class {
671
890
  message: `Video generation timed out after ${pollTimeoutMs}ms`
672
891
  });
673
892
  }
674
- await (0, import_provider_utils4.delay)(pollIntervalMs);
893
+ await (0, import_provider_utils5.delay)(pollIntervalMs);
675
894
  if ((_f = options.abortSignal) == null ? void 0 : _f.aborted) {
676
895
  throw new import_provider2.AISDKError({
677
896
  name: "VERTEX_VIDEO_GENERATION_ABORTED",
678
897
  message: "Video generation request was aborted"
679
898
  });
680
899
  }
681
- const { value: statusOperation, responseHeaders: pollHeaders } = await (0, import_provider_utils4.postJsonToApi)({
900
+ const { value: statusOperation, responseHeaders: pollHeaders } = await (0, import_provider_utils5.postJsonToApi)({
682
901
  url: `${this.config.baseURL}/models/${this.modelId}:fetchPredictOperation`,
683
- headers: (0, import_provider_utils4.combineHeaders)(
684
- await (0, import_provider_utils4.resolve)(this.config.headers),
902
+ headers: (0, import_provider_utils5.combineHeaders)(
903
+ await (0, import_provider_utils5.resolve)(this.config.headers),
685
904
  options.headers
686
905
  ),
687
906
  body: {
688
907
  operationName
689
908
  },
690
- successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
909
+ successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
691
910
  vertexOperationSchema
692
911
  ),
693
912
  failedResponseHandler: googleVertexFailedResponseHandler,
@@ -756,38 +975,38 @@ var GoogleVertexVideoModel = class {
756
975
  };
757
976
  }
758
977
  };
759
- var vertexOperationSchema = import_v45.z.object({
760
- name: import_v45.z.string().nullish(),
761
- done: import_v45.z.boolean().nullish(),
762
- error: import_v45.z.object({
763
- code: import_v45.z.number().nullish(),
764
- message: import_v45.z.string(),
765
- status: import_v45.z.string().nullish()
978
+ var vertexOperationSchema = import_v47.z.object({
979
+ name: import_v47.z.string().nullish(),
980
+ done: import_v47.z.boolean().nullish(),
981
+ error: import_v47.z.object({
982
+ code: import_v47.z.number().nullish(),
983
+ message: import_v47.z.string(),
984
+ status: import_v47.z.string().nullish()
766
985
  }).nullish(),
767
- response: import_v45.z.object({
768
- videos: import_v45.z.array(
769
- import_v45.z.object({
770
- bytesBase64Encoded: import_v45.z.string().nullish(),
771
- gcsUri: import_v45.z.string().nullish(),
772
- mimeType: import_v45.z.string().nullish()
986
+ response: import_v47.z.object({
987
+ videos: import_v47.z.array(
988
+ import_v47.z.object({
989
+ bytesBase64Encoded: import_v47.z.string().nullish(),
990
+ gcsUri: import_v47.z.string().nullish(),
991
+ mimeType: import_v47.z.string().nullish()
773
992
  })
774
993
  ).nullish(),
775
- raiMediaFilteredCount: import_v45.z.number().nullish()
994
+ raiMediaFilteredCount: import_v47.z.number().nullish()
776
995
  }).nullish()
777
996
  });
778
- var googleVertexVideoModelOptionsSchema = (0, import_provider_utils4.lazySchema)(
779
- () => (0, import_provider_utils4.zodSchema)(
780
- import_v45.z.object({
781
- pollIntervalMs: import_v45.z.number().positive().nullish(),
782
- pollTimeoutMs: import_v45.z.number().positive().nullish(),
783
- personGeneration: import_v45.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
784
- negativePrompt: import_v45.z.string().nullish(),
785
- generateAudio: import_v45.z.boolean().nullish(),
786
- gcsOutputDirectory: import_v45.z.string().nullish(),
787
- referenceImages: import_v45.z.array(
788
- import_v45.z.object({
789
- bytesBase64Encoded: import_v45.z.string().nullish(),
790
- gcsUri: import_v45.z.string().nullish()
997
+ var googleVertexVideoModelOptionsSchema = (0, import_provider_utils5.lazySchema)(
998
+ () => (0, import_provider_utils5.zodSchema)(
999
+ import_v47.z.object({
1000
+ pollIntervalMs: import_v47.z.number().positive().nullish(),
1001
+ pollTimeoutMs: import_v47.z.number().positive().nullish(),
1002
+ personGeneration: import_v47.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
1003
+ negativePrompt: import_v47.z.string().nullish(),
1004
+ generateAudio: import_v47.z.boolean().nullish(),
1005
+ gcsOutputDirectory: import_v47.z.string().nullish(),
1006
+ referenceImages: import_v47.z.array(
1007
+ import_v47.z.object({
1008
+ bytesBase64Encoded: import_v47.z.string().nullish(),
1009
+ gcsUri: import_v47.z.string().nullish()
791
1010
  })
792
1011
  ).nullish()
793
1012
  }).passthrough()
@@ -801,7 +1020,7 @@ function createExpressModeFetch(apiKey, customFetch) {
801
1020
  const modifiedInit = {
802
1021
  ...init,
803
1022
  headers: {
804
- ...(init == null ? void 0 : init.headers) ? (0, import_provider_utils5.normalizeHeaders)(init.headers) : {},
1023
+ ...(init == null ? void 0 : init.headers) ? (0, import_provider_utils6.normalizeHeaders)(init.headers) : {},
805
1024
  "x-goog-api-key": apiKey
806
1025
  }
807
1026
  };
@@ -809,17 +1028,17 @@ function createExpressModeFetch(apiKey, customFetch) {
809
1028
  };
810
1029
  }
811
1030
  function createVertex(options = {}) {
812
- const apiKey = (0, import_provider_utils5.loadOptionalSetting)({
1031
+ const apiKey = (0, import_provider_utils6.loadOptionalSetting)({
813
1032
  settingValue: options.apiKey,
814
1033
  environmentVariableName: "GOOGLE_VERTEX_API_KEY"
815
1034
  });
816
- const loadVertexProject = () => (0, import_provider_utils5.loadSetting)({
1035
+ const loadVertexProject = () => (0, import_provider_utils6.loadSetting)({
817
1036
  settingValue: options.project,
818
1037
  settingName: "project",
819
1038
  environmentVariableName: "GOOGLE_VERTEX_PROJECT",
820
1039
  description: "Google Vertex project"
821
1040
  });
822
- const loadVertexLocation = () => (0, import_provider_utils5.loadSetting)({
1041
+ const loadVertexLocation = () => (0, import_provider_utils6.loadSetting)({
823
1042
  settingValue: options.location,
824
1043
  settingName: "location",
825
1044
  environmentVariableName: "GOOGLE_VERTEX_LOCATION",
@@ -828,7 +1047,7 @@ function createVertex(options = {}) {
828
1047
  const loadBaseURL = () => {
829
1048
  var _a, _b;
830
1049
  if (apiKey) {
831
- return (_a = (0, import_provider_utils5.withoutTrailingSlash)(options.baseURL)) != null ? _a : EXPRESS_MODE_BASE_URL;
1050
+ return (_a = (0, import_provider_utils6.withoutTrailingSlash)(options.baseURL)) != null ? _a : EXPRESS_MODE_BASE_URL;
832
1051
  }
833
1052
  const region = loadVertexLocation();
834
1053
  const project = loadVertexProject();
@@ -841,13 +1060,13 @@ function createVertex(options = {}) {
841
1060
  return `${region}-aiplatform.googleapis.com`;
842
1061
  }
843
1062
  };
844
- return (_b = (0, import_provider_utils5.withoutTrailingSlash)(options.baseURL)) != null ? _b : `https://${getHost()}/v1beta1/projects/${project}/locations/${region}/publishers/google`;
1063
+ return (_b = (0, import_provider_utils6.withoutTrailingSlash)(options.baseURL)) != null ? _b : `https://${getHost()}/v1beta1/projects/${project}/locations/${region}/publishers/google`;
845
1064
  };
846
1065
  const createConfig = (name) => {
847
1066
  const getHeaders = async () => {
848
1067
  var _a;
849
- const originalHeaders = await (0, import_provider_utils5.resolve)((_a = options.headers) != null ? _a : {});
850
- return (0, import_provider_utils5.withUserAgentSuffix)(
1068
+ const originalHeaders = await (0, import_provider_utils6.resolve)((_a = options.headers) != null ? _a : {});
1069
+ return (0, import_provider_utils6.withUserAgentSuffix)(
851
1070
  originalHeaders,
852
1071
  `ai-sdk/google-vertex/${VERSION}`
853
1072
  );
@@ -863,7 +1082,7 @@ function createVertex(options = {}) {
863
1082
  var _a;
864
1083
  return new import_internal3.GoogleGenerativeAILanguageModel(modelId, {
865
1084
  ...createConfig("chat"),
866
- generateId: (_a = options.generateId) != null ? _a : import_provider_utils5.generateId,
1085
+ generateId: (_a = options.generateId) != null ? _a : import_provider_utils6.generateId,
867
1086
  supportedUrls: () => ({
868
1087
  "*": [
869
1088
  // HTTP URLs:
@@ -879,14 +1098,29 @@ function createVertex(options = {}) {
879
1098
  var _a;
880
1099
  return new GoogleVertexImageModel(modelId, {
881
1100
  ...createConfig("image"),
882
- generateId: (_a = options.generateId) != null ? _a : import_provider_utils5.generateId
1101
+ generateId: (_a = options.generateId) != null ? _a : import_provider_utils6.generateId
883
1102
  });
884
1103
  };
885
1104
  const createVideoModel = (modelId) => {
886
1105
  var _a;
887
1106
  return new GoogleVertexVideoModel(modelId, {
888
1107
  ...createConfig("video"),
889
- generateId: (_a = options.generateId) != null ? _a : import_provider_utils5.generateId
1108
+ generateId: (_a = options.generateId) != null ? _a : import_provider_utils6.generateId
1109
+ });
1110
+ };
1111
+ const createTranscriptionModel = (modelId) => {
1112
+ if (apiKey) {
1113
+ throw new Error(
1114
+ "Google Vertex transcription models do not support Express Mode API keys. Use standard Google Cloud credentials instead."
1115
+ );
1116
+ }
1117
+ const config = createConfig("transcription");
1118
+ return new GoogleVertexTranscriptionModel(modelId, {
1119
+ provider: config.provider,
1120
+ headers: config.headers,
1121
+ fetch: config.fetch,
1122
+ project: loadVertexProject(),
1123
+ location: loadVertexLocation()
890
1124
  });
891
1125
  };
892
1126
  const provider = function(modelId) {
@@ -905,28 +1139,30 @@ function createVertex(options = {}) {
905
1139
  provider.imageModel = createImageModel;
906
1140
  provider.video = createVideoModel;
907
1141
  provider.videoModel = createVideoModel;
1142
+ provider.transcription = createTranscriptionModel;
1143
+ provider.transcriptionModel = createTranscriptionModel;
908
1144
  provider.tools = googleVertexTools;
909
1145
  return provider;
910
1146
  }
911
1147
 
912
1148
  // src/edge/google-vertex-auth-edge.ts
913
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
1149
+ var import_provider_utils7 = require("@ai-sdk/provider-utils");
914
1150
  var loadCredentials = async () => {
915
1151
  try {
916
1152
  return {
917
- clientEmail: (0, import_provider_utils6.loadSetting)({
1153
+ clientEmail: (0, import_provider_utils7.loadSetting)({
918
1154
  settingValue: void 0,
919
1155
  settingName: "clientEmail",
920
1156
  environmentVariableName: "GOOGLE_CLIENT_EMAIL",
921
1157
  description: "Google client email"
922
1158
  }),
923
- privateKey: (0, import_provider_utils6.loadSetting)({
1159
+ privateKey: (0, import_provider_utils7.loadSetting)({
924
1160
  settingValue: void 0,
925
1161
  settingName: "privateKey",
926
1162
  environmentVariableName: "GOOGLE_PRIVATE_KEY",
927
1163
  description: "Google private key"
928
1164
  }),
929
- privateKeyId: (0, import_provider_utils6.loadOptionalSetting)({
1165
+ privateKeyId: (0, import_provider_utils7.loadOptionalSetting)({
930
1166
  settingValue: void 0,
931
1167
  environmentVariableName: "GOOGLE_PRIVATE_KEY_ID"
932
1168
  })
@@ -995,10 +1231,10 @@ async function generateAuthToken(credentials) {
995
1231
  const jwt = await buildJwt(creds);
996
1232
  const response = await fetch("https://oauth2.googleapis.com/token", {
997
1233
  method: "POST",
998
- headers: (0, import_provider_utils6.withUserAgentSuffix)(
1234
+ headers: (0, import_provider_utils7.withUserAgentSuffix)(
999
1235
  { "Content-Type": "application/x-www-form-urlencoded" },
1000
1236
  `ai-sdk/google-vertex/${VERSION}`,
1001
- (0, import_provider_utils6.getRuntimeEnvironmentUserAgent)()
1237
+ (0, import_provider_utils7.getRuntimeEnvironmentUserAgent)()
1002
1238
  ),
1003
1239
  body: new URLSearchParams({
1004
1240
  grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
@@ -1017,7 +1253,7 @@ async function generateAuthToken(credentials) {
1017
1253
 
1018
1254
  // src/edge/google-vertex-provider-edge.ts
1019
1255
  function createVertex2(options = {}) {
1020
- const apiKey = (0, import_provider_utils7.loadOptionalSetting)({
1256
+ const apiKey = (0, import_provider_utils8.loadOptionalSetting)({
1021
1257
  settingValue: options.apiKey,
1022
1258
  environmentVariableName: "GOOGLE_VERTEX_API_KEY"
1023
1259
  });
@@ -1030,7 +1266,7 @@ function createVertex2(options = {}) {
1030
1266
  Authorization: `Bearer ${await generateAuthToken(
1031
1267
  options.googleCredentials
1032
1268
  )}`,
1033
- ...await (0, import_provider_utils7.resolve)(options.headers)
1269
+ ...await (0, import_provider_utils8.resolve)(options.headers)
1034
1270
  })
1035
1271
  });
1036
1272
  }