@ai-sdk/google-vertex 4.0.189 → 4.0.191

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.mjs CHANGED
@@ -1,5 +1,235 @@
1
+ // src/gemini-transcription/google-vertex-gemini-transcription-model.ts
2
+ import {
3
+ InvalidArgumentError
4
+ } from "@ai-sdk/provider";
5
+ import {
6
+ combineHeaders,
7
+ convertToBase64,
8
+ createJsonResponseHandler,
9
+ parseProviderOptions,
10
+ postJsonToApi,
11
+ resolve
12
+ } from "@ai-sdk/provider-utils";
13
+ import { z as z3 } from "zod/v4";
14
+
15
+ // src/google-vertex-error.ts
16
+ import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
17
+ import { z } from "zod/v4";
18
+ var googleVertexErrorDataSchema = z.object({
19
+ error: z.object({
20
+ code: z.number().nullable(),
21
+ message: z.string(),
22
+ status: z.string()
23
+ })
24
+ });
25
+ var googleVertexFailedResponseHandler = createJsonErrorResponseHandler(
26
+ {
27
+ errorSchema: googleVertexErrorDataSchema,
28
+ errorToMessage: (data) => data.error.message
29
+ }
30
+ );
31
+
32
+ // src/gemini-transcription/google-vertex-gemini-transcription-model-options.ts
33
+ import { z as z2 } from "zod/v4";
34
+ var googleVertexGeminiTranscriptionModelOptions = z2.object({
35
+ /**
36
+ * BCP-47 language codes providing hints about the languages present in the
37
+ * audio. If omitted or empty, defaults to automatic language detection.
38
+ */
39
+ languageCodes: z2.array(z2.string()).optional(),
40
+ /**
41
+ * Custom vocabulary phrases, which bias the speech recognition model
42
+ * toward recognizing specific terms.
43
+ */
44
+ customVocabulary: z2.array(z2.string()).optional(),
45
+ /**
46
+ * Enables word-level timestamp generation.
47
+ */
48
+ wordTimestamp: z2.boolean().optional(),
49
+ /**
50
+ * Enables speaker diarization.
51
+ */
52
+ diarization: z2.boolean().optional(),
53
+ /**
54
+ * Transcription output formatting mode.
55
+ *
56
+ * - `VERBATIM` (default): exact literal transcript preserving filler
57
+ * words, repetitions, and false starts.
58
+ * - `SMART`: cleans up and structures the transcript in real time —
59
+ * disfluency removal, inline self-corrections, structured formatting
60
+ * (lists, numbers, dates, paragraph breaks), and grammar/casing polish.
61
+ */
62
+ mode: z2.enum(["SMART", "VERBATIM"]).optional()
63
+ });
64
+
65
+ // src/gemini-transcription/google-vertex-gemini-transcription-model.ts
66
+ function isLiveTranscriptionModelId(modelId) {
67
+ return modelId.includes("-live");
68
+ }
69
+ var GoogleVertexGeminiTranscriptionModel = class {
70
+ constructor(modelId, config) {
71
+ this.modelId = modelId;
72
+ this.config = config;
73
+ this.specificationVersion = "v3";
74
+ }
75
+ get provider() {
76
+ return this.config.provider;
77
+ }
78
+ async parseOptions(providerOptions) {
79
+ for (const provider of ["googleVertex", "vertex", "google"]) {
80
+ const parsed = await parseProviderOptions({
81
+ provider,
82
+ providerOptions,
83
+ schema: googleVertexGeminiTranscriptionModelOptions
84
+ });
85
+ if (parsed != null) return parsed;
86
+ }
87
+ return void 0;
88
+ }
89
+ async doGenerate(options) {
90
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
91
+ if (isLiveTranscriptionModelId(this.modelId)) {
92
+ throw new InvalidArgumentError({
93
+ argument: "modelId",
94
+ message: `Model '${this.modelId}' only supports streaming transcription, which requires AI SDK v7. Use a unary model such as 'gemini-3.5-transcribe'.`
95
+ });
96
+ }
97
+ const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
98
+ const warnings = [];
99
+ const googleOptions = await this.parseOptions(options.providerOptions);
100
+ const audioTranscriptionConfig = buildAudioTranscriptionConfig(googleOptions);
101
+ const requestBody = {
102
+ contents: [
103
+ {
104
+ role: "user",
105
+ parts: [
106
+ {
107
+ inlineData: {
108
+ mimeType: options.mediaType,
109
+ data: convertToBase64(options.audio)
110
+ }
111
+ }
112
+ ]
113
+ }
114
+ ],
115
+ ...audioTranscriptionConfig != null ? { generationConfig: { audioTranscriptionConfig } } : {}
116
+ };
117
+ const {
118
+ value: response,
119
+ responseHeaders,
120
+ rawValue: rawResponse
121
+ } = await postJsonToApi({
122
+ url: `${this.config.baseURL}/models/${this.modelId}:generateContent`,
123
+ headers: combineHeaders(
124
+ this.config.headers ? await resolve(this.config.headers) : void 0,
125
+ options.headers
126
+ ),
127
+ body: requestBody,
128
+ failedResponseHandler: googleVertexFailedResponseHandler,
129
+ successfulResponseHandler: createJsonResponseHandler(
130
+ googleVertexGeminiTranscriptionResponseSchema
131
+ ),
132
+ abortSignal: options.abortSignal,
133
+ fetch: this.config.fetch
134
+ });
135
+ const parts = (_g = (_f = (_e = (_d = response.candidates) == null ? void 0 : _d[0]) == null ? void 0 : _e.content) == null ? void 0 : _f.parts) != null ? _g : [];
136
+ const plainText = parts.map((part) => {
137
+ var _a2;
138
+ return (_a2 = part.text) != null ? _a2 : "";
139
+ }).join("");
140
+ const transcriptionText = parts.map((part) => {
141
+ var _a2, _b2;
142
+ return (_b2 = (_a2 = part.audioTranscription) == null ? void 0 : _a2.text) != null ? _b2 : "";
143
+ }).join("");
144
+ const text = plainText !== "" ? plainText : transcriptionText;
145
+ let language;
146
+ const segments = [];
147
+ for (const part of parts) {
148
+ const transcription = part.audioTranscription;
149
+ if (transcription == null) continue;
150
+ language != null ? language : language = (_h = transcription.languageCode) != null ? _h : void 0;
151
+ for (const word of (_i = transcription.words) != null ? _i : []) {
152
+ const startSecond = parseOffsetSeconds(word.startOffset);
153
+ const endSecond = parseOffsetSeconds(word.endOffset);
154
+ if (word.word == null || startSecond == null || endSecond == null) {
155
+ continue;
156
+ }
157
+ segments.push({ text: word.word, startSecond, endSecond });
158
+ }
159
+ }
160
+ return {
161
+ text,
162
+ segments,
163
+ language,
164
+ durationInSeconds: void 0,
165
+ warnings,
166
+ response: {
167
+ timestamp: currentDate,
168
+ modelId: this.modelId,
169
+ headers: responseHeaders,
170
+ body: rawResponse
171
+ },
172
+ ...response.usageMetadata != null ? {
173
+ providerMetadata: {
174
+ google: { usageMetadata: response.usageMetadata }
175
+ }
176
+ } : {}
177
+ };
178
+ }
179
+ };
180
+ function buildAudioTranscriptionConfig(options) {
181
+ if (options == null) return void 0;
182
+ const config = {};
183
+ if (options.languageCodes != null) {
184
+ config.languageCodes = options.languageCodes;
185
+ }
186
+ if (options.customVocabulary != null) {
187
+ config.customVocabulary = options.customVocabulary;
188
+ }
189
+ if (options.wordTimestamp != null) {
190
+ config.wordTimestamp = options.wordTimestamp;
191
+ }
192
+ if (options.diarization != null) {
193
+ config.diarization = options.diarization;
194
+ }
195
+ if (options.mode != null) {
196
+ config.mode = options.mode;
197
+ }
198
+ return Object.keys(config).length > 0 ? config : void 0;
199
+ }
200
+ function parseOffsetSeconds(offset) {
201
+ if (offset == null) return void 0;
202
+ const parsed = Number.parseFloat(offset);
203
+ return Number.isFinite(parsed) ? parsed : void 0;
204
+ }
205
+ var googleVertexGeminiTranscriptionWordSchema = z3.object({
206
+ word: z3.string().nullish(),
207
+ startOffset: z3.string().nullish(),
208
+ endOffset: z3.string().nullish()
209
+ });
210
+ var googleVertexGeminiTranscriptionResponseSchema = z3.object({
211
+ candidates: z3.array(
212
+ z3.object({
213
+ content: z3.object({
214
+ parts: z3.array(
215
+ z3.object({
216
+ text: z3.string().nullish(),
217
+ audioTranscription: z3.object({
218
+ text: z3.string().nullish(),
219
+ languageCode: z3.string().nullish(),
220
+ speakerLabel: z3.string().nullish(),
221
+ words: z3.array(googleVertexGeminiTranscriptionWordSchema).nullish()
222
+ }).nullish()
223
+ })
224
+ ).nullish()
225
+ }).nullish()
226
+ })
227
+ ).nullish(),
228
+ usageMetadata: z3.record(z3.string(), z3.unknown()).nullish()
229
+ });
230
+
1
231
  // src/google-vertex-provider-node.ts
2
- import { loadOptionalSetting as loadOptionalSetting2, resolve as resolve6 } from "@ai-sdk/provider-utils";
232
+ import { loadOptionalSetting as loadOptionalSetting2, resolve as resolve7 } from "@ai-sdk/provider-utils";
3
233
 
4
234
  // src/google-vertex-auth-google-auth-library.ts
5
235
  import { GoogleAuth } from "google-auth-library";
@@ -26,52 +256,35 @@ import {
26
256
  loadOptionalSetting,
27
257
  loadSetting,
28
258
  normalizeHeaders,
29
- resolve as resolve5,
259
+ resolve as resolve6,
30
260
  withoutTrailingSlash,
31
261
  withUserAgentSuffix
32
262
  } from "@ai-sdk/provider-utils";
33
263
 
34
264
  // src/version.ts
35
- var VERSION = true ? "4.0.189" : "0.0.0-test";
265
+ var VERSION = true ? "4.0.191" : "0.0.0-test";
36
266
 
37
267
  // src/google-vertex-embedding-model.ts
38
268
  import {
39
269
  TooManyEmbeddingValuesForCallError
40
270
  } from "@ai-sdk/provider";
41
271
  import {
42
- combineHeaders,
43
- createJsonResponseHandler,
44
- postJsonToApi,
45
- resolve,
46
- parseProviderOptions
272
+ combineHeaders as combineHeaders2,
273
+ createJsonResponseHandler as createJsonResponseHandler2,
274
+ postJsonToApi as postJsonToApi2,
275
+ resolve as resolve2,
276
+ parseProviderOptions as parseProviderOptions2
47
277
  } from "@ai-sdk/provider-utils";
48
- import { z as z3 } from "zod/v4";
49
-
50
- // src/google-vertex-error.ts
51
- import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
52
- import { z } from "zod/v4";
53
- var googleVertexErrorDataSchema = z.object({
54
- error: z.object({
55
- code: z.number().nullable(),
56
- message: z.string(),
57
- status: z.string()
58
- })
59
- });
60
- var googleVertexFailedResponseHandler = createJsonErrorResponseHandler(
61
- {
62
- errorSchema: googleVertexErrorDataSchema,
63
- errorToMessage: (data) => data.error.message
64
- }
65
- );
278
+ import { z as z5 } from "zod/v4";
66
279
 
67
280
  // src/google-vertex-embedding-options.ts
68
- import { z as z2 } from "zod/v4";
69
- var googleVertexEmbeddingModelOptions = z2.object({
281
+ import { z as z4 } from "zod/v4";
282
+ var googleVertexEmbeddingModelOptions = z4.object({
70
283
  /**
71
284
  * Optional. Optional reduced dimension for the output embedding.
72
285
  * If set, excessive values in the output embedding are truncated from the end.
73
286
  */
74
- outputDimensionality: z2.number().optional(),
287
+ outputDimensionality: z4.number().optional(),
75
288
  /**
76
289
  * Optional. Specifies the task type for generating embeddings.
77
290
  * Supported task types:
@@ -84,7 +297,7 @@ var googleVertexEmbeddingModelOptions = z2.object({
84
297
  * - FACT_VERIFICATION: Optimized for verifying factual information.
85
298
  * - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.
86
299
  */
87
- taskType: z2.enum([
300
+ taskType: z4.enum([
88
301
  "SEMANTIC_SIMILARITY",
89
302
  "CLASSIFICATION",
90
303
  "CLUSTERING",
@@ -99,12 +312,12 @@ var googleVertexEmbeddingModelOptions = z2.object({
99
312
  * Only valid when task_type is set to 'RETRIEVAL_DOCUMENT'.
100
313
  * Helps the model produce better embeddings by providing additional context.
101
314
  */
102
- title: z2.string().optional(),
315
+ title: z4.string().optional(),
103
316
  /**
104
317
  * Optional. When set to true, input text will be truncated. When set to false,
105
318
  * an error is returned if the input text is longer than the maximum length supported by the model. Defaults to true.
106
319
  */
107
- autoTruncate: z2.boolean().optional()
320
+ autoTruncate: z4.boolean().optional()
108
321
  });
109
322
 
110
323
  // src/google-vertex-embedding-model.ts
@@ -130,13 +343,13 @@ var GoogleVertexEmbeddingModel = class {
130
343
  providerOptions
131
344
  }) {
132
345
  var _a;
133
- let googleOptions = await parseProviderOptions({
346
+ let googleOptions = await parseProviderOptions2({
134
347
  provider: "vertex",
135
348
  providerOptions,
136
349
  schema: googleVertexEmbeddingModelOptions
137
350
  });
138
351
  if (googleOptions == null) {
139
- googleOptions = await parseProviderOptions({
352
+ googleOptions = await parseProviderOptions2({
140
353
  provider: "google",
141
354
  providerOptions,
142
355
  schema: googleVertexEmbeddingModelOptions
@@ -151,8 +364,8 @@ var GoogleVertexEmbeddingModel = class {
151
364
  values
152
365
  });
153
366
  }
154
- const mergedHeaders = combineHeaders(
155
- await resolve(this.config.headers),
367
+ const mergedHeaders = combineHeaders2(
368
+ await resolve2(this.config.headers),
156
369
  headers
157
370
  );
158
371
  if (usesEmbedContentEndpoint(this.modelId)) {
@@ -160,7 +373,7 @@ var GoogleVertexEmbeddingModel = class {
160
373
  responseHeaders: responseHeaders2,
161
374
  value: response2,
162
375
  rawValue: rawValue2
163
- } = await postJsonToApi({
376
+ } = await postJsonToApi2({
164
377
  url: `${this.config.baseURL}/models/${this.modelId}:embedContent`,
165
378
  headers: mergedHeaders,
166
379
  body: {
@@ -173,7 +386,7 @@ var GoogleVertexEmbeddingModel = class {
173
386
  }
174
387
  },
175
388
  failedResponseHandler: googleVertexFailedResponseHandler,
176
- successfulResponseHandler: createJsonResponseHandler(
389
+ successfulResponseHandler: createJsonResponseHandler2(
177
390
  googleVertexEmbedContentResponseSchema
178
391
  ),
179
392
  abortSignal,
@@ -191,7 +404,7 @@ var GoogleVertexEmbeddingModel = class {
191
404
  responseHeaders,
192
405
  value: response,
193
406
  rawValue
194
- } = await postJsonToApi({
407
+ } = await postJsonToApi2({
195
408
  url,
196
409
  headers: mergedHeaders,
197
410
  body: {
@@ -206,7 +419,7 @@ var GoogleVertexEmbeddingModel = class {
206
419
  }
207
420
  },
208
421
  failedResponseHandler: googleVertexFailedResponseHandler,
209
- successfulResponseHandler: createJsonResponseHandler(
422
+ successfulResponseHandler: createJsonResponseHandler2(
210
423
  googleVertexTextEmbeddingResponseSchema
211
424
  ),
212
425
  abortSignal,
@@ -227,24 +440,24 @@ var GoogleVertexEmbeddingModel = class {
227
440
  };
228
441
  }
229
442
  };
230
- var googleVertexTextEmbeddingResponseSchema = z3.object({
231
- predictions: z3.array(
232
- z3.object({
233
- embeddings: z3.object({
234
- values: z3.array(z3.number()),
235
- statistics: z3.object({
236
- token_count: z3.number()
443
+ var googleVertexTextEmbeddingResponseSchema = z5.object({
444
+ predictions: z5.array(
445
+ z5.object({
446
+ embeddings: z5.object({
447
+ values: z5.array(z5.number()),
448
+ statistics: z5.object({
449
+ token_count: z5.number()
237
450
  })
238
451
  })
239
452
  })
240
453
  )
241
454
  });
242
- var googleVertexEmbedContentResponseSchema = z3.object({
243
- embedding: z3.object({
244
- values: z3.array(z3.number())
455
+ var googleVertexEmbedContentResponseSchema = z5.object({
456
+ embedding: z5.object({
457
+ values: z5.array(z5.number())
245
458
  }),
246
- usageMetadata: z3.object({
247
- promptTokenCount: z3.number().nullish()
459
+ usageMetadata: z5.object({
460
+ promptTokenCount: z5.number().nullish()
248
461
  }).nullish()
249
462
  });
250
463
  function usesEmbedContentEndpoint(modelId) {
@@ -254,16 +467,16 @@ function usesEmbedContentEndpoint(modelId) {
254
467
  // src/google-vertex-image-model.ts
255
468
  import { GoogleGenerativeAILanguageModel } from "@ai-sdk/google/internal";
256
469
  import {
257
- combineHeaders as combineHeaders2,
258
- convertToBase64,
470
+ combineHeaders as combineHeaders3,
471
+ convertToBase64 as convertToBase642,
259
472
  convertUint8ArrayToBase64,
260
- createJsonResponseHandler as createJsonResponseHandler2,
473
+ createJsonResponseHandler as createJsonResponseHandler3,
261
474
  generateId as defaultGenerateId,
262
- parseProviderOptions as parseProviderOptions2,
263
- postJsonToApi as postJsonToApi2,
264
- resolve as resolve2
475
+ parseProviderOptions as parseProviderOptions3,
476
+ postJsonToApi as postJsonToApi3,
477
+ resolve as resolve3
265
478
  } from "@ai-sdk/provider-utils";
266
- import { z as z4 } from "zod/v4";
479
+ import { z as z6 } from "zod/v4";
267
480
  var GoogleVertexImageModel = class {
268
481
  constructor(modelId, config) {
269
482
  this.modelId = modelId;
@@ -306,7 +519,7 @@ var GoogleVertexImageModel = class {
306
519
  details: "This model does not support the `size` option. Use `aspectRatio` instead."
307
520
  });
308
521
  }
309
- const vertexImageOptions = await parseProviderOptions2({
522
+ const vertexImageOptions = await parseProviderOptions3({
310
523
  provider: "vertex",
311
524
  providerOptions,
312
525
  schema: googleVertexImageModelOptionsSchema
@@ -368,12 +581,12 @@ var GoogleVertexImageModel = class {
368
581
  };
369
582
  }
370
583
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
371
- const { value: response, responseHeaders } = await postJsonToApi2({
584
+ const { value: response, responseHeaders } = await postJsonToApi3({
372
585
  url: `${this.config.baseURL}/models/${this.modelId}:predict`,
373
- headers: combineHeaders2(await resolve2(this.config.headers), headers),
586
+ headers: combineHeaders3(await resolve3(this.config.headers), headers),
374
587
  body,
375
588
  failedResponseHandler: googleVertexFailedResponseHandler,
376
- successfulResponseHandler: createJsonResponseHandler2(
589
+ successfulResponseHandler: createJsonResponseHandler3(
377
590
  vertexImageResponseSchema
378
591
  ),
379
592
  abortSignal,
@@ -486,7 +699,7 @@ var GoogleVertexImageModel = class {
486
699
  const images = [];
487
700
  for (const part of result.content) {
488
701
  if (part.type === "file" && part.mediaType.startsWith("image/")) {
489
- images.push(convertToBase64(part.data));
702
+ images.push(convertToBase642(part.data));
490
703
  }
491
704
  }
492
705
  return {
@@ -513,41 +726,41 @@ var GoogleVertexImageModel = class {
513
726
  function isGeminiModel(modelId) {
514
727
  return modelId.startsWith("gemini-");
515
728
  }
516
- var vertexImageResponseSchema = z4.object({
517
- predictions: z4.array(
518
- z4.object({
519
- bytesBase64Encoded: z4.string(),
520
- mimeType: z4.string(),
521
- prompt: z4.string().nullish()
729
+ var vertexImageResponseSchema = z6.object({
730
+ predictions: z6.array(
731
+ z6.object({
732
+ bytesBase64Encoded: z6.string(),
733
+ mimeType: z6.string(),
734
+ prompt: z6.string().nullish()
522
735
  })
523
736
  ).nullish()
524
737
  });
525
- var googleVertexImageModelOptionsSchema = z4.object({
526
- negativePrompt: z4.string().nullish(),
527
- personGeneration: z4.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
528
- safetySetting: z4.enum([
738
+ var googleVertexImageModelOptionsSchema = z6.object({
739
+ negativePrompt: z6.string().nullish(),
740
+ personGeneration: z6.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
741
+ safetySetting: z6.enum([
529
742
  "block_low_and_above",
530
743
  "block_medium_and_above",
531
744
  "block_only_high",
532
745
  "block_none"
533
746
  ]).nullish(),
534
- addWatermark: z4.boolean().nullish(),
535
- storageUri: z4.string().nullish(),
536
- sampleImageSize: z4.enum(["1K", "2K"]).nullish(),
747
+ addWatermark: z6.boolean().nullish(),
748
+ storageUri: z6.string().nullish(),
749
+ sampleImageSize: z6.enum(["1K", "2K"]).nullish(),
537
750
  /**
538
751
  * Configuration for image editing operations
539
752
  */
540
- edit: z4.object({
753
+ edit: z6.object({
541
754
  /**
542
755
  * An integer that represents the number of sampling steps.
543
756
  * A higher value offers better image quality, a lower value offers better latency.
544
757
  * Try 35 steps to start. If the quality doesn't meet your requirements,
545
758
  * increase the value towards an upper limit of 75.
546
759
  */
547
- baseSteps: z4.number().nullish(),
760
+ baseSteps: z6.number().nullish(),
548
761
  // Edit mode options
549
762
  // https://cloud.google.com/vertex-ai/generative-ai/docs/image/edit-insert-objects
550
- mode: z4.enum([
763
+ mode: z6.enum([
551
764
  "EDIT_MODE_INPAINT_INSERTION",
552
765
  "EDIT_MODE_INPAINT_REMOVAL",
553
766
  "EDIT_MODE_OUTPAINT",
@@ -563,7 +776,7 @@ var googleVertexImageModelOptionsSchema = z4.object({
563
776
  * - `MASK_MODE_CLOTHING_AREA` - Masks from segmenting the clothing area with open-vocab segmentation.
564
777
  * - `MASK_MODE_PARSED_PERSON` - Masks from segmenting the person body and clothing using the person-parsing model.
565
778
  */
566
- maskMode: z4.enum([
779
+ maskMode: z6.enum([
567
780
  "MASK_MODE_DEFAULT",
568
781
  "MASK_MODE_USER_PROVIDED",
569
782
  "MASK_MODE_DETECTION_BOX",
@@ -575,7 +788,7 @@ var googleVertexImageModelOptionsSchema = z4.object({
575
788
  * percentage of the image width to grow the mask by. Using dilation helps
576
789
  * compensate for imprecise masks. We recommend a value of 0.01.
577
790
  */
578
- maskDilation: z4.number().nullish()
791
+ maskDilation: z6.number().nullish()
579
792
  }).nullish()
580
793
  });
581
794
  function getBase64Data(file) {
@@ -604,28 +817,28 @@ var googleVertexTools = {
604
817
 
605
818
  // src/google-vertex-transcription-model.ts
606
819
  import {
607
- combineHeaders as combineHeaders3,
820
+ combineHeaders as combineHeaders4,
608
821
  convertUint8ArrayToBase64 as convertUint8ArrayToBase642,
609
- createJsonResponseHandler as createJsonResponseHandler3,
610
- parseProviderOptions as parseProviderOptions3,
611
- postJsonToApi as postJsonToApi3,
612
- resolve as resolve3
822
+ createJsonResponseHandler as createJsonResponseHandler4,
823
+ parseProviderOptions as parseProviderOptions4,
824
+ postJsonToApi as postJsonToApi4,
825
+ resolve as resolve4
613
826
  } from "@ai-sdk/provider-utils";
614
- import { z as z6 } from "zod/v4";
827
+ import { z as z8 } from "zod/v4";
615
828
 
616
829
  // src/google-vertex-transcription-model-options.ts
617
- import { z as z5 } from "zod/v4";
618
- var googleVertexTranscriptionProviderOptionsSchema = z5.object({
830
+ import { z as z7 } from "zod/v4";
831
+ var googleVertexTranscriptionProviderOptionsSchema = z7.object({
619
832
  /**
620
833
  * BCP-47 language codes to recognize (e.g. `['en-US']`), or `['auto']` to let
621
834
  * Chirp auto-detect the spoken language. Defaults to `['auto']`. For
622
835
  * `telephony`, pass a supported explicit language code.
623
836
  */
624
- languageCodes: z5.array(z5.string()).optional(),
837
+ languageCodes: z7.array(z7.string()).optional(),
625
838
  /**
626
839
  * Whether to add punctuation to the transcript. Defaults to `true`.
627
840
  */
628
- enableAutomaticPunctuation: z5.boolean().optional(),
841
+ enableAutomaticPunctuation: z7.boolean().optional(),
629
842
  /**
630
843
  * Whether to include word-level timestamps. Defaults to `true` so the
631
844
  * transcription result can include segments.
@@ -633,7 +846,7 @@ var googleVertexTranscriptionProviderOptionsSchema = z5.object({
633
846
  * Enabling word-level timestamps can reduce transcription quality and speed
634
847
  * for Chirp models.
635
848
  */
636
- enableWordTimeOffsets: z5.boolean().optional(),
849
+ enableWordTimeOffsets: z7.boolean().optional(),
637
850
  /**
638
851
  * The Cloud Speech-to-Text region for the request (e.g. `'us'`, `'eu'`,
639
852
  * `'us-central1'`). Defaults to the provider `location`.
@@ -642,7 +855,7 @@ var googleVertexTranscriptionProviderOptionsSchema = z5.object({
642
855
  * available in specific Speech-to-Text regions and is not available in the
643
856
  * `global` location.
644
857
  */
645
- region: z5.string().optional()
858
+ region: z7.string().optional()
646
859
  });
647
860
 
648
861
  // src/google-vertex-transcription-model.ts
@@ -679,7 +892,7 @@ var GoogleVertexTranscriptionModel = class {
679
892
  const warnings = [];
680
893
  let googleOptions;
681
894
  for (const provider of ["googleVertex", "vertex", "google"]) {
682
- googleOptions = await parseProviderOptions3({
895
+ googleOptions = await parseProviderOptions4({
683
896
  provider,
684
897
  providerOptions: options.providerOptions,
685
898
  schema: googleVertexTranscriptionProviderOptionsSchema
@@ -711,15 +924,15 @@ var GoogleVertexTranscriptionModel = class {
711
924
  value: response,
712
925
  responseHeaders,
713
926
  rawValue: rawResponse
714
- } = await postJsonToApi3({
927
+ } = await postJsonToApi4({
715
928
  url,
716
- headers: combineHeaders3(
717
- this.config.headers ? await resolve3(this.config.headers) : void 0,
929
+ headers: combineHeaders4(
930
+ this.config.headers ? await resolve4(this.config.headers) : void 0,
718
931
  options.headers
719
932
  ),
720
933
  body: requestBody,
721
934
  failedResponseHandler: googleVertexFailedResponseHandler,
722
- successfulResponseHandler: createJsonResponseHandler3(
935
+ successfulResponseHandler: createJsonResponseHandler4(
723
936
  googleVertexTranscriptionResponseSchema
724
937
  ),
725
938
  abortSignal: options.abortSignal,
@@ -758,26 +971,26 @@ var GoogleVertexTranscriptionModel = class {
758
971
  };
759
972
  }
760
973
  };
761
- var googleVertexTranscriptionResponseSchema = z6.object({
762
- results: z6.array(
763
- z6.object({
764
- alternatives: z6.array(
765
- z6.object({
766
- transcript: z6.string().nullish(),
767
- words: z6.array(
768
- z6.object({
769
- word: z6.string().nullish(),
770
- startOffset: z6.string().nullish(),
771
- endOffset: z6.string().nullish()
974
+ var googleVertexTranscriptionResponseSchema = z8.object({
975
+ results: z8.array(
976
+ z8.object({
977
+ alternatives: z8.array(
978
+ z8.object({
979
+ transcript: z8.string().nullish(),
980
+ words: z8.array(
981
+ z8.object({
982
+ word: z8.string().nullish(),
983
+ startOffset: z8.string().nullish(),
984
+ endOffset: z8.string().nullish()
772
985
  })
773
986
  ).nullish()
774
987
  })
775
988
  ).nullish(),
776
- languageCode: z6.string().nullish()
989
+ languageCode: z8.string().nullish()
777
990
  })
778
991
  ).nullish(),
779
- metadata: z6.object({
780
- totalBilledDuration: z6.string().nullish()
992
+ metadata: z8.object({
993
+ totalBilledDuration: z8.string().nullish()
781
994
  }).nullish()
782
995
  });
783
996
 
@@ -786,17 +999,17 @@ import {
786
999
  AISDKError
787
1000
  } from "@ai-sdk/provider";
788
1001
  import {
789
- combineHeaders as combineHeaders4,
1002
+ combineHeaders as combineHeaders5,
790
1003
  convertUint8ArrayToBase64 as convertUint8ArrayToBase643,
791
- createJsonResponseHandler as createJsonResponseHandler4,
1004
+ createJsonResponseHandler as createJsonResponseHandler5,
792
1005
  delay,
793
1006
  lazySchema,
794
- parseProviderOptions as parseProviderOptions4,
795
- postJsonToApi as postJsonToApi4,
796
- resolve as resolve4,
1007
+ parseProviderOptions as parseProviderOptions5,
1008
+ postJsonToApi as postJsonToApi5,
1009
+ resolve as resolve5,
797
1010
  zodSchema
798
1011
  } from "@ai-sdk/provider-utils";
799
- import { z as z7 } from "zod/v4";
1012
+ import { z as z9 } from "zod/v4";
800
1013
  function getFirstFrameImage(options) {
801
1014
  var _a, _b;
802
1015
  return (_b = (_a = options.frameImages) == null ? void 0 : _a.find((frame) => frame.frameType === "first_frame")) == null ? void 0 : _b.image;
@@ -856,7 +1069,7 @@ var GoogleVertexVideoModel = class {
856
1069
  var _a, _b, _c, _d, _e, _f, _g;
857
1070
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
858
1071
  const warnings = [];
859
- const vertexOptions = await parseProviderOptions4({
1072
+ const vertexOptions = await parseProviderOptions5({
860
1073
  provider: "vertex",
861
1074
  providerOptions: options.providerOptions,
862
1075
  schema: googleVertexVideoModelOptionsSchema
@@ -938,17 +1151,17 @@ var GoogleVertexVideoModel = class {
938
1151
  }
939
1152
  }
940
1153
  }
941
- const { value: operation } = await postJsonToApi4({
1154
+ const { value: operation } = await postJsonToApi5({
942
1155
  url: `${this.config.baseURL}/models/${this.modelId}:predictLongRunning`,
943
- headers: combineHeaders4(
944
- await resolve4(this.config.headers),
1156
+ headers: combineHeaders5(
1157
+ await resolve5(this.config.headers),
945
1158
  options.headers
946
1159
  ),
947
1160
  body: {
948
1161
  instances,
949
1162
  parameters
950
1163
  },
951
- successfulResponseHandler: createJsonResponseHandler4(
1164
+ successfulResponseHandler: createJsonResponseHandler5(
952
1165
  vertexOperationSchema
953
1166
  ),
954
1167
  failedResponseHandler: googleVertexFailedResponseHandler,
@@ -981,16 +1194,16 @@ var GoogleVertexVideoModel = class {
981
1194
  message: "Video generation request was aborted"
982
1195
  });
983
1196
  }
984
- const { value: statusOperation, responseHeaders: pollHeaders } = await postJsonToApi4({
1197
+ const { value: statusOperation, responseHeaders: pollHeaders } = await postJsonToApi5({
985
1198
  url: `${this.config.baseURL}/models/${this.modelId}:fetchPredictOperation`,
986
- headers: combineHeaders4(
987
- await resolve4(this.config.headers),
1199
+ headers: combineHeaders5(
1200
+ await resolve5(this.config.headers),
988
1201
  options.headers
989
1202
  ),
990
1203
  body: {
991
1204
  operationName
992
1205
  },
993
- successfulResponseHandler: createJsonResponseHandler4(
1206
+ successfulResponseHandler: createJsonResponseHandler5(
994
1207
  vertexOperationSchema
995
1208
  ),
996
1209
  failedResponseHandler: googleVertexFailedResponseHandler,
@@ -1059,38 +1272,38 @@ var GoogleVertexVideoModel = class {
1059
1272
  };
1060
1273
  }
1061
1274
  };
1062
- var vertexOperationSchema = z7.object({
1063
- name: z7.string().nullish(),
1064
- done: z7.boolean().nullish(),
1065
- error: z7.object({
1066
- code: z7.number().nullish(),
1067
- message: z7.string(),
1068
- status: z7.string().nullish()
1275
+ var vertexOperationSchema = z9.object({
1276
+ name: z9.string().nullish(),
1277
+ done: z9.boolean().nullish(),
1278
+ error: z9.object({
1279
+ code: z9.number().nullish(),
1280
+ message: z9.string(),
1281
+ status: z9.string().nullish()
1069
1282
  }).nullish(),
1070
- response: z7.object({
1071
- videos: z7.array(
1072
- z7.object({
1073
- bytesBase64Encoded: z7.string().nullish(),
1074
- gcsUri: z7.string().nullish(),
1075
- mimeType: z7.string().nullish()
1283
+ response: z9.object({
1284
+ videos: z9.array(
1285
+ z9.object({
1286
+ bytesBase64Encoded: z9.string().nullish(),
1287
+ gcsUri: z9.string().nullish(),
1288
+ mimeType: z9.string().nullish()
1076
1289
  })
1077
1290
  ).nullish(),
1078
- raiMediaFilteredCount: z7.number().nullish()
1291
+ raiMediaFilteredCount: z9.number().nullish()
1079
1292
  }).nullish()
1080
1293
  });
1081
1294
  var googleVertexVideoModelOptionsSchema = lazySchema(
1082
1295
  () => zodSchema(
1083
- z7.object({
1084
- pollIntervalMs: z7.number().positive().nullish(),
1085
- pollTimeoutMs: z7.number().positive().nullish(),
1086
- personGeneration: z7.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
1087
- negativePrompt: z7.string().nullish(),
1088
- generateAudio: z7.boolean().nullish(),
1089
- gcsOutputDirectory: z7.string().nullish(),
1090
- referenceImages: z7.array(
1091
- z7.object({
1092
- bytesBase64Encoded: z7.string().nullish(),
1093
- gcsUri: z7.string().nullish()
1296
+ z9.object({
1297
+ pollIntervalMs: z9.number().positive().nullish(),
1298
+ pollTimeoutMs: z9.number().positive().nullish(),
1299
+ personGeneration: z9.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
1300
+ negativePrompt: z9.string().nullish(),
1301
+ generateAudio: z9.boolean().nullish(),
1302
+ gcsOutputDirectory: z9.string().nullish(),
1303
+ referenceImages: z9.array(
1304
+ z9.object({
1305
+ bytesBase64Encoded: z9.string().nullish(),
1306
+ gcsUri: z9.string().nullish()
1094
1307
  })
1095
1308
  ).nullish()
1096
1309
  }).passthrough()
@@ -1149,7 +1362,7 @@ function createVertex(options = {}) {
1149
1362
  const createConfig = (name, { endpoint = false } = {}) => {
1150
1363
  const getHeaders = async () => {
1151
1364
  var _a;
1152
- const originalHeaders = await resolve5((_a = options.headers) != null ? _a : {});
1365
+ const originalHeaders = await resolve6((_a = options.headers) != null ? _a : {});
1153
1366
  return withUserAgentSuffix(
1154
1367
  originalHeaders,
1155
1368
  `ai-sdk/google-vertex/${VERSION}`
@@ -1218,6 +1431,14 @@ function createVertex(options = {}) {
1218
1431
  );
1219
1432
  }
1220
1433
  const config = createConfig("transcription");
1434
+ if (modelId.startsWith("gemini")) {
1435
+ return new GoogleVertexGeminiTranscriptionModel(modelId, {
1436
+ provider: config.provider,
1437
+ baseURL: loadBaseURL(),
1438
+ headers: config.headers,
1439
+ fetch: config.fetch
1440
+ });
1441
+ }
1221
1442
  return new GoogleVertexTranscriptionModel(modelId, {
1222
1443
  provider: config.provider,
1223
1444
  headers: config.headers,
@@ -1267,12 +1488,13 @@ function createVertex2(options = {}) {
1267
1488
  ...options,
1268
1489
  headers: async () => ({
1269
1490
  Authorization: `Bearer ${await generateAuthToken()}`,
1270
- ...await resolve6(options.headers)
1491
+ ...await resolve7(options.headers)
1271
1492
  })
1272
1493
  });
1273
1494
  }
1274
1495
  var vertex = createVertex2();
1275
1496
  export {
1497
+ GoogleVertexGeminiTranscriptionModel,
1276
1498
  VERSION,
1277
1499
  createVertex2 as createVertex,
1278
1500
  vertex