@ai-sdk/google-vertex 5.0.0-canary.98 → 5.0.0

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,5 +1,5 @@
1
1
  // src/google-vertex-provider.ts
2
- import { loadOptionalSetting as loadOptionalSetting2, resolve as resolve5 } from "@ai-sdk/provider-utils";
2
+ import { loadOptionalSetting as loadOptionalSetting2, resolve as resolve6 } from "@ai-sdk/provider-utils";
3
3
 
4
4
  // src/google-vertex-auth-google-auth-library.ts
5
5
  import { GoogleAuth } from "google-auth-library";
@@ -17,19 +17,22 @@ function createAuthTokenGenerator(options) {
17
17
  }
18
18
 
19
19
  // src/google-vertex-provider-base.ts
20
- import { GoogleLanguageModel as GoogleLanguageModel2 } from "@ai-sdk/google/internal";
20
+ import {
21
+ GoogleLanguageModel as GoogleLanguageModel2,
22
+ GoogleSpeechModel
23
+ } from "@ai-sdk/google/internal";
21
24
  import {
22
25
  generateId,
23
26
  loadOptionalSetting,
24
27
  loadSetting,
25
28
  normalizeHeaders,
26
- resolve as resolve4,
29
+ resolve as resolve5,
27
30
  withoutTrailingSlash,
28
31
  withUserAgentSuffix
29
32
  } from "@ai-sdk/provider-utils";
30
33
 
31
34
  // src/version.ts
32
- var VERSION = true ? "5.0.0-canary.98" : "0.0.0-test";
35
+ var VERSION = true ? "5.0.0" : "0.0.0-test";
33
36
 
34
37
  // src/google-vertex-embedding-model.ts
35
38
  import {
@@ -111,7 +114,6 @@ var googleVertexEmbeddingModelOptions = z2.object({
111
114
  var GoogleVertexEmbeddingModel = class _GoogleVertexEmbeddingModel {
112
115
  constructor(modelId, config) {
113
116
  this.specificationVersion = "v4";
114
- this.maxEmbeddingsPerCall = 2048;
115
117
  this.supportsParallelCalls = true;
116
118
  this.modelId = modelId;
117
119
  this.config = config;
@@ -128,12 +130,18 @@ var GoogleVertexEmbeddingModel = class _GoogleVertexEmbeddingModel {
128
130
  get provider() {
129
131
  return this.config.provider;
130
132
  }
133
+ // gemini-embedding-2 models only support :embedContent (one value per call),
134
+ // not the :predict batch endpoint. https://github.com/vercel/ai/issues/15853
135
+ get maxEmbeddingsPerCall() {
136
+ return usesEmbedContentEndpoint(this.modelId) ? 1 : 2048;
137
+ }
131
138
  async doEmbed({
132
139
  values,
133
140
  headers,
134
141
  abortSignal,
135
142
  providerOptions
136
143
  }) {
144
+ var _a;
137
145
  let googleOptions = await parseProviderOptions({
138
146
  provider: "googleVertex",
139
147
  providerOptions,
@@ -166,6 +174,37 @@ var GoogleVertexEmbeddingModel = class _GoogleVertexEmbeddingModel {
166
174
  this.config.headers ? await resolve(this.config.headers) : void 0,
167
175
  headers
168
176
  );
177
+ if (usesEmbedContentEndpoint(this.modelId)) {
178
+ const {
179
+ responseHeaders: responseHeaders2,
180
+ value: response2,
181
+ rawValue: rawValue2
182
+ } = await postJsonToApi({
183
+ url: `${this.config.baseURL}/models/${this.modelId}:embedContent`,
184
+ headers: mergedHeaders,
185
+ body: {
186
+ content: { parts: [{ text: values[0] }] },
187
+ embedContentConfig: {
188
+ outputDimensionality: googleOptions.outputDimensionality,
189
+ taskType: googleOptions.taskType,
190
+ title: googleOptions.title,
191
+ autoTruncate: googleOptions.autoTruncate
192
+ }
193
+ },
194
+ failedResponseHandler: googleVertexFailedResponseHandler,
195
+ successfulResponseHandler: createJsonResponseHandler(
196
+ googleVertexEmbedContentResponseSchema
197
+ ),
198
+ abortSignal,
199
+ fetch: this.config.fetch
200
+ });
201
+ return {
202
+ warnings: [],
203
+ embeddings: [response2.embedding.values],
204
+ usage: ((_a = response2.usageMetadata) == null ? void 0 : _a.promptTokenCount) == null ? void 0 : { tokens: response2.usageMetadata.promptTokenCount },
205
+ response: { headers: responseHeaders2, body: rawValue2 }
206
+ };
207
+ }
169
208
  const url = `${this.config.baseURL}/models/${this.modelId}:predict`;
170
209
  const {
171
210
  responseHeaders,
@@ -219,6 +258,17 @@ var googleVertexTextEmbeddingResponseSchema = z3.object({
219
258
  })
220
259
  )
221
260
  });
261
+ var googleVertexEmbedContentResponseSchema = z3.object({
262
+ embedding: z3.object({
263
+ values: z3.array(z3.number())
264
+ }),
265
+ usageMetadata: z3.object({
266
+ promptTokenCount: z3.number().nullish()
267
+ }).nullish()
268
+ });
269
+ function usesEmbedContentEndpoint(modelId) {
270
+ return modelId === "gemini-embedding-2" || modelId === "gemini-embedding-2-preview";
271
+ }
222
272
 
223
273
  // src/google-vertex-image-model.ts
224
274
  import { GoogleLanguageModel } from "@ai-sdk/google/internal";
@@ -605,37 +655,228 @@ var googleVertexTools = {
605
655
  vertexRagStore: googleTools.vertexRagStore
606
656
  };
607
657
 
608
- // src/google-vertex-video-model.ts
609
- import {
610
- AISDKError
611
- } from "@ai-sdk/provider";
658
+ // src/google-vertex-transcription-model.ts
612
659
  import {
613
660
  combineHeaders as combineHeaders3,
614
661
  convertUint8ArrayToBase64 as convertUint8ArrayToBase642,
615
662
  createJsonResponseHandler as createJsonResponseHandler3,
616
- delay,
617
663
  parseProviderOptions as parseProviderOptions3,
618
664
  postJsonToApi as postJsonToApi3,
619
- resolve as resolve3
665
+ resolve as resolve3,
666
+ serializeModelOptions as serializeModelOptions3,
667
+ WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE3,
668
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE3
620
669
  } from "@ai-sdk/provider-utils";
621
670
  import { z as z7 } from "zod/v4";
622
671
 
672
+ // src/google-vertex-transcription-model-options.ts
673
+ import { z as z6 } from "zod/v4";
674
+ var googleVertexTranscriptionProviderOptionsSchema = z6.object({
675
+ /**
676
+ * BCP-47 language codes to recognize (e.g. `['en-US']`), or `['auto']` to let
677
+ * Chirp auto-detect the spoken language. Defaults to `['auto']`. For
678
+ * `telephony`, pass a supported explicit language code.
679
+ */
680
+ languageCodes: z6.array(z6.string()).optional(),
681
+ /**
682
+ * Whether to add punctuation to the transcript. Defaults to `true`.
683
+ */
684
+ enableAutomaticPunctuation: z6.boolean().optional(),
685
+ /**
686
+ * Whether to include word-level timestamps. Defaults to `true` so the
687
+ * transcription result can include segments.
688
+ *
689
+ * Enabling word-level timestamps can reduce transcription quality and speed
690
+ * for Chirp models.
691
+ */
692
+ enableWordTimeOffsets: z6.boolean().optional(),
693
+ /**
694
+ * The Cloud Speech-to-Text region for the request (e.g. `'us'`, `'eu'`,
695
+ * `'us-central1'`). Defaults to the provider `location`.
696
+ *
697
+ * Note: Speech-to-Text regions differ from Vertex AI regions. Chirp is only
698
+ * available in specific Speech-to-Text regions and is not available in the
699
+ * `global` location.
700
+ */
701
+ region: z6.string().optional()
702
+ });
703
+
704
+ // src/google-vertex-transcription-model.ts
705
+ function parseDurationSeconds(value) {
706
+ if (value == null) {
707
+ return void 0;
708
+ }
709
+ const seconds = Number.parseFloat(value);
710
+ return Number.isFinite(seconds) ? seconds : void 0;
711
+ }
712
+ function convertBcp47ToIso6391(value) {
713
+ if (value == null) {
714
+ return void 0;
715
+ }
716
+ try {
717
+ const language = new Intl.Locale(value).language;
718
+ return language.length === 2 ? language : void 0;
719
+ } catch (e) {
720
+ return void 0;
721
+ }
722
+ }
723
+ var GoogleVertexTranscriptionModel = class _GoogleVertexTranscriptionModel {
724
+ constructor(modelId, config) {
725
+ this.modelId = modelId;
726
+ this.config = config;
727
+ this.specificationVersion = "v4";
728
+ }
729
+ static [WORKFLOW_SERIALIZE3](model) {
730
+ return serializeModelOptions3({
731
+ modelId: model.modelId,
732
+ config: model.config
733
+ });
734
+ }
735
+ static [WORKFLOW_DESERIALIZE3](options) {
736
+ return new _GoogleVertexTranscriptionModel(options.modelId, options.config);
737
+ }
738
+ get provider() {
739
+ return this.config.provider;
740
+ }
741
+ async doGenerate(options) {
742
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
743
+ const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
744
+ const warnings = [];
745
+ let googleOptions;
746
+ for (const provider of ["googleVertex", "vertex", "google"]) {
747
+ googleOptions = await parseProviderOptions3({
748
+ provider,
749
+ providerOptions: options.providerOptions,
750
+ schema: googleVertexTranscriptionProviderOptionsSchema
751
+ });
752
+ if (googleOptions != null) {
753
+ break;
754
+ }
755
+ }
756
+ const region = (_d = googleOptions == null ? void 0 : googleOptions.region) != null ? _d : this.config.location;
757
+ const languageCodes = (_e = googleOptions == null ? void 0 : googleOptions.languageCodes) != null ? _e : ["auto"];
758
+ const content = typeof options.audio === "string" ? options.audio : convertUint8ArrayToBase642(options.audio);
759
+ const requestBody = {
760
+ config: {
761
+ model: this.modelId,
762
+ languageCodes,
763
+ // Let Speech-to-Text auto-detect the audio encoding (wav/mp3/flac/…).
764
+ autoDecodingConfig: {},
765
+ features: {
766
+ // Word timing populates `segments`.
767
+ enableWordTimeOffsets: (_f = googleOptions == null ? void 0 : googleOptions.enableWordTimeOffsets) != null ? _f : true,
768
+ enableAutomaticPunctuation: (_g = googleOptions == null ? void 0 : googleOptions.enableAutomaticPunctuation) != null ? _g : true
769
+ }
770
+ },
771
+ content
772
+ };
773
+ const host = region === "global" ? "speech.googleapis.com" : `${region}-speech.googleapis.com`;
774
+ const url = `https://${host}/v2/projects/${this.config.project}/locations/${region}/recognizers/_:recognize`;
775
+ const {
776
+ value: response,
777
+ responseHeaders,
778
+ rawValue: rawResponse
779
+ } = await postJsonToApi3({
780
+ url,
781
+ headers: combineHeaders3(
782
+ this.config.headers ? await resolve3(this.config.headers) : void 0,
783
+ options.headers
784
+ ),
785
+ body: requestBody,
786
+ failedResponseHandler: googleVertexFailedResponseHandler,
787
+ successfulResponseHandler: createJsonResponseHandler3(
788
+ googleVertexTranscriptionResponseSchema
789
+ ),
790
+ abortSignal: options.abortSignal,
791
+ fetch: this.config.fetch
792
+ });
793
+ const results = (_h = response.results) != null ? _h : [];
794
+ const text = results.map((result) => {
795
+ var _a2, _b2, _c2;
796
+ return (_c2 = (_b2 = (_a2 = result.alternatives) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.transcript) != null ? _c2 : "";
797
+ }).join(" ").trim();
798
+ const segments = results.flatMap(
799
+ (result) => {
800
+ var _a2, _b2, _c2, _d2;
801
+ return (_d2 = (_c2 = (_b2 = (_a2 = result.alternatives) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.words) == null ? void 0 : _c2.flatMap((word) => {
802
+ const startSecond = parseDurationSeconds(word.startOffset);
803
+ const endSecond = parseDurationSeconds(word.endOffset);
804
+ return word.word == null || startSecond == null || endSecond == null ? [] : [{ text: word.word, startSecond, endSecond }];
805
+ })) != null ? _d2 : [];
806
+ }
807
+ );
808
+ const language = convertBcp47ToIso6391((_i = results[0]) == null ? void 0 : _i.languageCode);
809
+ return {
810
+ text,
811
+ segments,
812
+ language,
813
+ durationInSeconds: parseDurationSeconds(
814
+ (_j = response.metadata) == null ? void 0 : _j.totalBilledDuration
815
+ ),
816
+ warnings,
817
+ response: {
818
+ timestamp: currentDate,
819
+ modelId: this.modelId,
820
+ headers: responseHeaders,
821
+ body: rawResponse
822
+ }
823
+ };
824
+ }
825
+ };
826
+ var googleVertexTranscriptionResponseSchema = z7.object({
827
+ results: z7.array(
828
+ z7.object({
829
+ alternatives: z7.array(
830
+ z7.object({
831
+ transcript: z7.string().nullish(),
832
+ words: z7.array(
833
+ z7.object({
834
+ word: z7.string().nullish(),
835
+ startOffset: z7.string().nullish(),
836
+ endOffset: z7.string().nullish()
837
+ })
838
+ ).nullish()
839
+ })
840
+ ).nullish(),
841
+ languageCode: z7.string().nullish()
842
+ })
843
+ ).nullish(),
844
+ metadata: z7.object({
845
+ totalBilledDuration: z7.string().nullish()
846
+ }).nullish()
847
+ });
848
+
849
+ // src/google-vertex-video-model.ts
850
+ import {
851
+ AISDKError
852
+ } from "@ai-sdk/provider";
853
+ import {
854
+ combineHeaders as combineHeaders4,
855
+ convertUint8ArrayToBase64 as convertUint8ArrayToBase643,
856
+ createJsonResponseHandler as createJsonResponseHandler4,
857
+ delay,
858
+ parseProviderOptions as parseProviderOptions4,
859
+ postJsonToApi as postJsonToApi4,
860
+ resolve as resolve4
861
+ } from "@ai-sdk/provider-utils";
862
+ import { z as z9 } from "zod/v4";
863
+
623
864
  // src/google-vertex-video-model-options.ts
624
865
  import { lazySchema, zodSchema } from "@ai-sdk/provider-utils";
625
- import { z as z6 } from "zod/v4";
866
+ import { z as z8 } from "zod/v4";
626
867
  var googleVertexVideoModelOptionsSchema = lazySchema(
627
868
  () => zodSchema(
628
- z6.object({
629
- pollIntervalMs: z6.number().positive().nullish(),
630
- pollTimeoutMs: z6.number().positive().nullish(),
631
- personGeneration: z6.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
632
- negativePrompt: z6.string().nullish(),
633
- generateAudio: z6.boolean().nullish(),
634
- gcsOutputDirectory: z6.string().nullish(),
635
- referenceImages: z6.array(
636
- z6.object({
637
- bytesBase64Encoded: z6.string().nullish(),
638
- gcsUri: z6.string().nullish()
869
+ z8.object({
870
+ pollIntervalMs: z8.number().positive().nullish(),
871
+ pollTimeoutMs: z8.number().positive().nullish(),
872
+ personGeneration: z8.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
873
+ negativePrompt: z8.string().nullish(),
874
+ generateAudio: z8.boolean().nullish(),
875
+ gcsOutputDirectory: z8.string().nullish(),
876
+ referenceImages: z8.array(
877
+ z8.object({
878
+ bytesBase64Encoded: z8.string().nullish(),
879
+ gcsUri: z8.string().nullish()
639
880
  })
640
881
  ).nullish()
641
882
  }).passthrough()
@@ -656,14 +897,14 @@ var GoogleVertexVideoModel = class {
656
897
  return 4;
657
898
  }
658
899
  async doGenerate(options) {
659
- var _a, _b, _c, _d, _e, _f, _g;
900
+ var _a, _b, _c, _d, _e, _f, _g, _h;
660
901
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
661
902
  const warnings = [];
662
- const googleVertexOptions = (_d = await parseProviderOptions3({
903
+ const googleVertexOptions = (_d = await parseProviderOptions4({
663
904
  provider: "googleVertex",
664
905
  providerOptions: options.providerOptions,
665
906
  schema: googleVertexVideoModelOptionsSchema
666
- })) != null ? _d : await parseProviderOptions3({
907
+ })) != null ? _d : await parseProviderOptions4({
667
908
  provider: "vertex",
668
909
  providerOptions: options.providerOptions,
669
910
  schema: googleVertexVideoModelOptionsSchema
@@ -681,7 +922,7 @@ var GoogleVertexVideoModel = class {
681
922
  details: "Vertex AI video models require base64-encoded images or GCS URIs. URL will be ignored."
682
923
  });
683
924
  } else {
684
- const base64Data = typeof options.image.data === "string" ? options.image.data : convertUint8ArrayToBase642(options.image.data);
925
+ const base64Data = typeof options.image.data === "string" ? options.image.data : convertUint8ArrayToBase643(options.image.data);
685
926
  instance.image = {
686
927
  bytesBase64Encoded: base64Data,
687
928
  mimeType: options.image.mediaType
@@ -711,6 +952,10 @@ var GoogleVertexVideoModel = class {
711
952
  if (options.seed) {
712
953
  parameters.seed = options.seed;
713
954
  }
955
+ const generateAudio = (_e = options.generateAudio) != null ? _e : googleVertexOptions == null ? void 0 : googleVertexOptions.generateAudio;
956
+ if (generateAudio != null) {
957
+ parameters.generateAudio = generateAudio;
958
+ }
714
959
  if (googleVertexOptions != null) {
715
960
  const opts = googleVertexOptions;
716
961
  if (opts.personGeneration !== void 0 && opts.personGeneration !== null) {
@@ -719,9 +964,6 @@ var GoogleVertexVideoModel = class {
719
964
  if (opts.negativePrompt !== void 0 && opts.negativePrompt !== null) {
720
965
  parameters.negativePrompt = opts.negativePrompt;
721
966
  }
722
- if (opts.generateAudio !== void 0 && opts.generateAudio !== null) {
723
- parameters.generateAudio = opts.generateAudio;
724
- }
725
967
  if (opts.gcsOutputDirectory !== void 0 && opts.gcsOutputDirectory !== null) {
726
968
  parameters.gcsOutputDirectory = opts.gcsOutputDirectory;
727
969
  }
@@ -739,17 +981,17 @@ var GoogleVertexVideoModel = class {
739
981
  }
740
982
  }
741
983
  }
742
- const { value: operation } = await postJsonToApi3({
984
+ const { value: operation } = await postJsonToApi4({
743
985
  url: `${this.config.baseURL}/models/${this.modelId}:predictLongRunning`,
744
- headers: combineHeaders3(
745
- await resolve3(this.config.headers),
986
+ headers: combineHeaders4(
987
+ await resolve4(this.config.headers),
746
988
  options.headers
747
989
  ),
748
990
  body: {
749
991
  instances,
750
992
  parameters
751
993
  },
752
- successfulResponseHandler: createJsonResponseHandler3(
994
+ successfulResponseHandler: createJsonResponseHandler4(
753
995
  googleVertexOperationSchema
754
996
  ),
755
997
  failedResponseHandler: googleVertexFailedResponseHandler,
@@ -763,8 +1005,8 @@ var GoogleVertexVideoModel = class {
763
1005
  message: "No operation name returned from API"
764
1006
  });
765
1007
  }
766
- const pollIntervalMs = (_e = googleVertexOptions == null ? void 0 : googleVertexOptions.pollIntervalMs) != null ? _e : 1e4;
767
- const pollTimeoutMs = (_f = googleVertexOptions == null ? void 0 : googleVertexOptions.pollTimeoutMs) != null ? _f : 6e5;
1008
+ const pollIntervalMs = (_f = googleVertexOptions == null ? void 0 : googleVertexOptions.pollIntervalMs) != null ? _f : 1e4;
1009
+ const pollTimeoutMs = (_g = googleVertexOptions == null ? void 0 : googleVertexOptions.pollTimeoutMs) != null ? _g : 6e5;
768
1010
  const startTime = Date.now();
769
1011
  let finalOperation = operation;
770
1012
  let responseHeaders;
@@ -776,22 +1018,22 @@ var GoogleVertexVideoModel = class {
776
1018
  });
777
1019
  }
778
1020
  await delay(pollIntervalMs);
779
- if ((_g = options.abortSignal) == null ? void 0 : _g.aborted) {
1021
+ if ((_h = options.abortSignal) == null ? void 0 : _h.aborted) {
780
1022
  throw new AISDKError({
781
1023
  name: "VERTEX_VIDEO_GENERATION_ABORTED",
782
1024
  message: "Video generation request was aborted"
783
1025
  });
784
1026
  }
785
- const { value: statusOperation, responseHeaders: pollHeaders } = await postJsonToApi3({
1027
+ const { value: statusOperation, responseHeaders: pollHeaders } = await postJsonToApi4({
786
1028
  url: `${this.config.baseURL}/models/${this.modelId}:fetchPredictOperation`,
787
- headers: combineHeaders3(
788
- await resolve3(this.config.headers),
1029
+ headers: combineHeaders4(
1030
+ await resolve4(this.config.headers),
789
1031
  options.headers
790
1032
  ),
791
1033
  body: {
792
1034
  operationName
793
1035
  },
794
- successfulResponseHandler: createJsonResponseHandler3(
1036
+ successfulResponseHandler: createJsonResponseHandler4(
795
1037
  googleVertexOperationSchema
796
1038
  ),
797
1039
  failedResponseHandler: googleVertexFailedResponseHandler,
@@ -864,23 +1106,23 @@ var GoogleVertexVideoModel = class {
864
1106
  };
865
1107
  }
866
1108
  };
867
- var googleVertexOperationSchema = z7.object({
868
- name: z7.string().nullish(),
869
- done: z7.boolean().nullish(),
870
- error: z7.object({
871
- code: z7.number().nullish(),
872
- message: z7.string(),
873
- status: z7.string().nullish()
1109
+ var googleVertexOperationSchema = z9.object({
1110
+ name: z9.string().nullish(),
1111
+ done: z9.boolean().nullish(),
1112
+ error: z9.object({
1113
+ code: z9.number().nullish(),
1114
+ message: z9.string(),
1115
+ status: z9.string().nullish()
874
1116
  }).nullish(),
875
- response: z7.object({
876
- videos: z7.array(
877
- z7.object({
878
- bytesBase64Encoded: z7.string().nullish(),
879
- gcsUri: z7.string().nullish(),
880
- mimeType: z7.string().nullish()
1117
+ response: z9.object({
1118
+ videos: z9.array(
1119
+ z9.object({
1120
+ bytesBase64Encoded: z9.string().nullish(),
1121
+ gcsUri: z9.string().nullish(),
1122
+ mimeType: z9.string().nullish()
881
1123
  })
882
1124
  ).nullish(),
883
- raiMediaFilteredCount: z7.number().nullish()
1125
+ raiMediaFilteredCount: z9.number().nullish()
884
1126
  }).nullish()
885
1127
  });
886
1128
 
@@ -922,13 +1164,21 @@ function createGoogleVertex(options = {}) {
922
1164
  }
923
1165
  const region = loadGoogleVertexLocation();
924
1166
  const project = loadGoogleVertexProject();
925
- const baseHost = `${region === "global" ? "" : region + "-"}aiplatform.googleapis.com`;
926
- return (_b = withoutTrailingSlash(options.baseURL)) != null ? _b : `https://${baseHost}/v1beta1/projects/${project}/locations/${region}/publishers/google`;
1167
+ const getHost = () => {
1168
+ if (region === "global") {
1169
+ return "aiplatform.googleapis.com";
1170
+ } else if (region === "eu" || region === "us") {
1171
+ return `aiplatform.${region}.rep.googleapis.com`;
1172
+ } else {
1173
+ return `${region}-aiplatform.googleapis.com`;
1174
+ }
1175
+ };
1176
+ return (_b = withoutTrailingSlash(options.baseURL)) != null ? _b : `https://${getHost()}/v1beta1/projects/${project}/locations/${region}/publishers/google`;
927
1177
  };
928
1178
  const createConfig = (name) => {
929
1179
  const getHeaders = async () => {
930
1180
  var _a;
931
- const originalHeaders = await resolve4((_a = options.headers) != null ? _a : {});
1181
+ const originalHeaders = await resolve5((_a = options.headers) != null ? _a : {});
932
1182
  return withUserAgentSuffix(
933
1183
  originalHeaders,
934
1184
  `ai-sdk/google-vertex/${VERSION}`
@@ -971,6 +1221,22 @@ function createGoogleVertex(options = {}) {
971
1221
  generateId: (_a = options.generateId) != null ? _a : generateId
972
1222
  });
973
1223
  };
1224
+ const createSpeechModel = (modelId) => new GoogleSpeechModel(modelId, createConfig("speech"));
1225
+ const createTranscriptionModel = (modelId) => {
1226
+ if (apiKey) {
1227
+ throw new Error(
1228
+ "Google Vertex transcription models do not support Express Mode API keys. Use standard Google Cloud credentials instead."
1229
+ );
1230
+ }
1231
+ const config = createConfig("transcription");
1232
+ return new GoogleVertexTranscriptionModel(modelId, {
1233
+ provider: config.provider,
1234
+ headers: config.headers,
1235
+ fetch: config.fetch,
1236
+ project: loadGoogleVertexProject(),
1237
+ location: loadGoogleVertexLocation()
1238
+ });
1239
+ };
974
1240
  const provider = function(modelId) {
975
1241
  if (new.target) {
976
1242
  throw new Error(
@@ -987,6 +1253,10 @@ function createGoogleVertex(options = {}) {
987
1253
  provider.imageModel = createImageModel;
988
1254
  provider.video = createVideoModel;
989
1255
  provider.videoModel = createVideoModel;
1256
+ provider.speech = createSpeechModel;
1257
+ provider.speechModel = createSpeechModel;
1258
+ provider.transcription = createTranscriptionModel;
1259
+ provider.transcriptionModel = createTranscriptionModel;
990
1260
  provider.tools = googleVertexTools;
991
1261
  return provider;
992
1262
  }
@@ -1009,7 +1279,7 @@ function createGoogleVertex2(options = {}) {
1009
1279
  ...options,
1010
1280
  headers: async () => ({
1011
1281
  Authorization: `Bearer ${await generateAuthToken()}`,
1012
- ...await resolve5(options.headers)
1282
+ ...await resolve6(options.headers)
1013
1283
  })
1014
1284
  });
1015
1285
  }