@ai-sdk/google-vertex 5.0.93 → 5.0.96

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
@@ -9,10 +9,9 @@ function createAuthTokenGenerator(options) {
9
9
  ...options
10
10
  });
11
11
  return async function generateAuthToken() {
12
- var _a;
13
12
  const client = await auth.getClient();
14
13
  const token = await client.getAccessToken();
15
- return (_a = token == null ? void 0 : token.token) != null ? _a : null;
14
+ return token?.token ?? null;
16
15
  };
17
16
  }
18
17
 
@@ -33,7 +32,7 @@ import {
33
32
  } from "@ai-sdk/provider-utils";
34
33
 
35
34
  // src/version.ts
36
- var VERSION = true ? "5.0.93" : "0.0.0-test";
35
+ var VERSION = true ? "5.0.96" : "0.0.0-test";
37
36
 
38
37
  // src/google-vertex-embedding-model.ts
39
38
  import {
@@ -142,7 +141,6 @@ var GoogleVertexEmbeddingModel = class _GoogleVertexEmbeddingModel {
142
141
  abortSignal,
143
142
  providerOptions
144
143
  }) {
145
- var _a;
146
144
  let googleOptions = await parseProviderOptions({
147
145
  provider: "googleVertex",
148
146
  providerOptions,
@@ -162,7 +160,7 @@ var GoogleVertexEmbeddingModel = class _GoogleVertexEmbeddingModel {
162
160
  schema: googleVertexEmbeddingModelOptions
163
161
  });
164
162
  }
165
- googleOptions = googleOptions != null ? googleOptions : {};
163
+ googleOptions = googleOptions ?? {};
166
164
  if (values.length > this.maxEmbeddingsPerCall) {
167
165
  throw new TooManyEmbeddingValuesForCallError({
168
166
  provider: this.provider,
@@ -202,7 +200,7 @@ var GoogleVertexEmbeddingModel = class _GoogleVertexEmbeddingModel {
202
200
  return {
203
201
  warnings: [],
204
202
  embeddings: [response2.embedding.values],
205
- usage: ((_a = response2.usageMetadata) == null ? void 0 : _a.promptTokenCount) == null ? void 0 : { tokens: response2.usageMetadata.promptTokenCount },
203
+ usage: response2.usageMetadata?.promptTokenCount == null ? void 0 : { tokens: response2.usageMetadata.promptTokenCount },
206
204
  response: { headers: responseHeaders2, body: rawValue2 }
207
205
  };
208
206
  }
@@ -280,6 +278,11 @@ import {
280
278
  WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE2,
281
279
  WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE2
282
280
  } from "@ai-sdk/provider-utils";
281
+ var googleVertexImageModelsWithFileInputSupport = /* @__PURE__ */ new Set([
282
+ "gemini-2.5-flash-image",
283
+ "gemini-3-pro-image-preview",
284
+ "gemini-3.1-flash-image-preview"
285
+ ]);
283
286
  var GoogleVertexImageModel = class _GoogleVertexImageModel {
284
287
  constructor(modelId, config) {
285
288
  this.modelId = modelId;
@@ -296,11 +299,16 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
296
299
  static [WORKFLOW_DESERIALIZE2](options) {
297
300
  return new _GoogleVertexImageModel(options.modelId, options.config);
298
301
  }
302
+ get supportsFileInputs() {
303
+ return googleVertexImageModelsWithFileInputSupport.has(this.modelId) ? true : void 0;
304
+ }
305
+ get supportsMaskInputs() {
306
+ return this.supportsFileInputs === true ? false : void 0;
307
+ }
299
308
  get provider() {
300
309
  return this.config.provider;
301
310
  }
302
311
  async doGenerate(options) {
303
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
304
312
  if (!this.modelId.startsWith("gemini-")) {
305
313
  throw new Error(
306
314
  "Google image models other than Gemini are no longer supported. Use a model ID that starts with `gemini-`."
@@ -360,9 +368,9 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
360
368
  const languageModel = new GoogleLanguageModel(this.modelId, {
361
369
  provider: this.config.provider,
362
370
  baseURL: this.config.baseURL,
363
- headers: (_a = this.config.headers) != null ? _a : {},
371
+ headers: this.config.headers ?? {},
364
372
  fetch: this.config.fetch,
365
- generateId: (_b = this.config.generateId) != null ? _b : defaultGenerateId,
373
+ generateId: this.config.generateId ?? defaultGenerateId,
366
374
  supportedUrls: () => ({
367
375
  "*": [/^https?:\/\/.*$/, /^gs:\/\/.*$/]
368
376
  })
@@ -371,7 +379,7 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
371
379
  responseModalities: _strippedResponseModalities,
372
380
  imageConfig: userImageConfig,
373
381
  ...userVertexOptions
374
- } = (_d = (_c = providerOptions == null ? void 0 : providerOptions.googleVertex) != null ? _c : providerOptions == null ? void 0 : providerOptions.vertex) != null ? _d : {};
382
+ } = providerOptions?.googleVertex ?? providerOptions?.vertex ?? {};
375
383
  const innerVertexOptions = {
376
384
  ...userVertexOptions,
377
385
  responseModalities: ["IMAGE"],
@@ -392,7 +400,7 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
392
400
  headers,
393
401
  abortSignal
394
402
  });
395
- const currentDate = (_g = (_f = (_e = this.config._internal) == null ? void 0 : _e.currentDate) == null ? void 0 : _f.call(_e)) != null ? _g : /* @__PURE__ */ new Date();
403
+ const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
396
404
  const images = [];
397
405
  for (const part of result.content) {
398
406
  if (part.type === "file" && part.mediaType.startsWith("image/") && part.data.type === "data") {
@@ -413,12 +421,12 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
413
421
  response: {
414
422
  timestamp: currentDate,
415
423
  modelId: this.modelId,
416
- headers: (_h = result.response) == null ? void 0 : _h.headers
424
+ headers: result.response?.headers
417
425
  },
418
426
  usage: result.usage ? {
419
427
  inputTokens: result.usage.inputTokens.total,
420
428
  outputTokens: result.usage.outputTokens.total,
421
- totalTokens: ((_i = result.usage.inputTokens.total) != null ? _i : 0) + ((_j = result.usage.outputTokens.total) != null ? _j : 0)
429
+ totalTokens: (result.usage.inputTokens.total ?? 0) + (result.usage.outputTokens.total ?? 0)
422
430
  } : void 0
423
431
  };
424
432
  }
@@ -459,8 +467,7 @@ var GoogleVertexCloudTTSSpeechModel = class _GoogleVertexCloudTTSSpeechModel {
459
467
  return this.config.provider;
460
468
  }
461
469
  async doGenerate(options) {
462
- var _a, _b, _c;
463
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
470
+ const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
464
471
  const warnings = [];
465
472
  const {
466
473
  text,
@@ -475,9 +482,9 @@ var GoogleVertexCloudTTSSpeechModel = class _GoogleVertexCloudTTSSpeechModel {
475
482
  if (voice.includes(CHIRP3_HD_VOICE_INFIX)) {
476
483
  voiceName = voice;
477
484
  const localePrefix = voice.split(CHIRP3_HD_VOICE_INFIX)[0].replace(/-$/, "");
478
- languageCode = language != null ? language : localePrefix || DEFAULT_LANGUAGE;
485
+ languageCode = language ?? (localePrefix || DEFAULT_LANGUAGE);
479
486
  } else {
480
- languageCode = language != null ? language : DEFAULT_LANGUAGE;
487
+ languageCode = language ?? DEFAULT_LANGUAGE;
481
488
  voiceName = `${languageCode}-${CHIRP3_HD_VOICE_INFIX}-${voice}`;
482
489
  }
483
490
  if (instructions != null) {
@@ -618,7 +625,7 @@ function convertBcp47ToIso6391(value) {
618
625
  try {
619
626
  const language = new Intl.Locale(value).language;
620
627
  return language.length === 2 ? language : void 0;
621
- } catch (e) {
628
+ } catch {
622
629
  return void 0;
623
630
  }
624
631
  }
@@ -641,8 +648,7 @@ var GoogleVertexTranscriptionModel = class _GoogleVertexTranscriptionModel {
641
648
  return this.config.provider;
642
649
  }
643
650
  async doGenerate(options) {
644
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
645
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
651
+ const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
646
652
  const warnings = [];
647
653
  let googleOptions;
648
654
  for (const provider of ["googleVertex", "vertex", "google"]) {
@@ -655,8 +661,8 @@ var GoogleVertexTranscriptionModel = class _GoogleVertexTranscriptionModel {
655
661
  break;
656
662
  }
657
663
  }
658
- const region = (_d = googleOptions == null ? void 0 : googleOptions.region) != null ? _d : this.config.location;
659
- const languageCodes = (_e = googleOptions == null ? void 0 : googleOptions.languageCodes) != null ? _e : ["auto"];
664
+ const region = googleOptions?.region ?? this.config.location;
665
+ const languageCodes = googleOptions?.languageCodes ?? ["auto"];
660
666
  const content = typeof options.audio === "string" ? options.audio : convertUint8ArrayToBase64(options.audio);
661
667
  const requestBody = {
662
668
  config: {
@@ -666,8 +672,8 @@ var GoogleVertexTranscriptionModel = class _GoogleVertexTranscriptionModel {
666
672
  autoDecodingConfig: {},
667
673
  features: {
668
674
  // Word timing populates `segments`.
669
- enableWordTimeOffsets: (_f = googleOptions == null ? void 0 : googleOptions.enableWordTimeOffsets) != null ? _f : true,
670
- enableAutomaticPunctuation: (_g = googleOptions == null ? void 0 : googleOptions.enableAutomaticPunctuation) != null ? _g : true
675
+ enableWordTimeOffsets: googleOptions?.enableWordTimeOffsets ?? true,
676
+ enableAutomaticPunctuation: googleOptions?.enableAutomaticPunctuation ?? true
671
677
  }
672
678
  },
673
679
  content
@@ -692,28 +698,22 @@ var GoogleVertexTranscriptionModel = class _GoogleVertexTranscriptionModel {
692
698
  abortSignal: options.abortSignal,
693
699
  fetch: this.config.fetch
694
700
  });
695
- const results = (_h = response.results) != null ? _h : [];
696
- const text = results.map((result) => {
697
- var _a2, _b2, _c2;
698
- return (_c2 = (_b2 = (_a2 = result.alternatives) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.transcript) != null ? _c2 : "";
699
- }).join(" ").trim();
701
+ const results = response.results ?? [];
702
+ const text = results.map((result) => result.alternatives?.[0]?.transcript ?? "").join(" ").trim();
700
703
  const segments = results.flatMap(
701
- (result) => {
702
- var _a2, _b2, _c2, _d2;
703
- return (_d2 = (_c2 = (_b2 = (_a2 = result.alternatives) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.words) == null ? void 0 : _c2.flatMap((word) => {
704
- const startSecond = parseDurationSeconds(word.startOffset);
705
- const endSecond = parseDurationSeconds(word.endOffset);
706
- return word.word == null || startSecond == null || endSecond == null ? [] : [{ text: word.word, startSecond, endSecond }];
707
- })) != null ? _d2 : [];
708
- }
704
+ (result) => result.alternatives?.[0]?.words?.flatMap((word) => {
705
+ const startSecond = parseDurationSeconds(word.startOffset);
706
+ const endSecond = parseDurationSeconds(word.endOffset);
707
+ return word.word == null || startSecond == null || endSecond == null ? [] : [{ text: word.word, startSecond, endSecond }];
708
+ }) ?? []
709
709
  );
710
- const language = convertBcp47ToIso6391((_i = results[0]) == null ? void 0 : _i.languageCode);
710
+ const language = convertBcp47ToIso6391(results[0]?.languageCode);
711
711
  return {
712
712
  text,
713
713
  segments,
714
714
  language,
715
715
  durationInSeconds: parseDurationSeconds(
716
- (_j = response.metadata) == null ? void 0 : _j.totalBilledDuration
716
+ response.metadata?.totalBilledDuration
717
717
  ),
718
718
  warnings,
719
719
  response: {
@@ -846,14 +846,13 @@ var GoogleVertexGeminiTranscriptionModel = class _GoogleVertexGeminiTranscriptio
846
846
  }
847
847
  }
848
848
  async doGenerate(options) {
849
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
850
849
  if (isLiveTranscriptionModelId(this.modelId)) {
851
850
  throw new InvalidArgumentError({
852
851
  argument: "modelId",
853
852
  message: `Model '${this.modelId}' only supports streaming transcription. Use experimental_streamTranscribe, or a unary model such as 'gemini-3.5-transcribe'.`
854
853
  });
855
854
  }
856
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
855
+ const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
857
856
  const warnings = [];
858
857
  const googleOptions = await this.parseOptions(options.providerOptions);
859
858
  const audioTranscriptionConfig = buildAudioTranscriptionConfig(googleOptions);
@@ -891,23 +890,17 @@ var GoogleVertexGeminiTranscriptionModel = class _GoogleVertexGeminiTranscriptio
891
890
  abortSignal: options.abortSignal,
892
891
  fetch: this.config.fetch
893
892
  });
894
- 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 : [];
895
- const plainText = parts.map((part) => {
896
- var _a2;
897
- return (_a2 = part.text) != null ? _a2 : "";
898
- }).join("");
899
- const transcriptionText = parts.map((part) => {
900
- var _a2, _b2;
901
- return (_b2 = (_a2 = part.audioTranscription) == null ? void 0 : _a2.text) != null ? _b2 : "";
902
- }).join("");
893
+ const parts = response.candidates?.[0]?.content?.parts ?? [];
894
+ const plainText = parts.map((part) => part.text ?? "").join("");
895
+ const transcriptionText = parts.map((part) => part.audioTranscription?.text ?? "").join("");
903
896
  const text = plainText !== "" ? plainText : transcriptionText;
904
897
  let language;
905
898
  const segments = [];
906
899
  for (const part of parts) {
907
900
  const transcription = part.audioTranscription;
908
901
  if (transcription == null) continue;
909
- language != null ? language : language = (_h = transcription.languageCode) != null ? _h : void 0;
910
- for (const word of (_i = transcription.words) != null ? _i : []) {
902
+ language ??= transcription.languageCode ?? void 0;
903
+ for (const word of transcription.words ?? []) {
911
904
  const startSecond = parseOffsetSeconds(word.startOffset);
912
905
  const endSecond = parseOffsetSeconds(word.endOffset);
913
906
  if (word.word == null || startSecond == null || endSecond == null) {
@@ -936,14 +929,13 @@ var GoogleVertexGeminiTranscriptionModel = class _GoogleVertexGeminiTranscriptio
936
929
  };
937
930
  }
938
931
  async doStream(options) {
939
- var _a, _b, _c, _d, _e, _f, _g;
940
932
  if (!isLiveTranscriptionModelId(this.modelId)) {
941
933
  throw new InvalidArgumentError({
942
934
  argument: "modelId",
943
935
  message: `Model '${this.modelId}' does not support streaming transcription. Use a live model such as 'gemini-3.5-transcribe-live'.`
944
936
  });
945
937
  }
946
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
938
+ const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
947
939
  const warnings = [];
948
940
  const googleOptions = await this.parseOptions(options.providerOptions);
949
941
  validateLiveInputAudioFormat(options.inputAudioFormat);
@@ -958,7 +950,7 @@ var GoogleVertexGeminiTranscriptionModel = class _GoogleVertexGeminiTranscriptio
958
950
  );
959
951
  const setup = {
960
952
  model: modelResource,
961
- inputAudioTranscription: (_d = buildAudioTranscriptionConfig(googleOptions)) != null ? _d : {}
953
+ inputAudioTranscription: buildAudioTranscriptionConfig(googleOptions) ?? {}
962
954
  };
963
955
  return {
964
956
  request: { body: setup },
@@ -971,8 +963,8 @@ var GoogleVertexGeminiTranscriptionModel = class _GoogleVertexGeminiTranscriptio
971
963
  url,
972
964
  headers,
973
965
  setup,
974
- inputAudioRate: (_e = options.inputAudioFormat.rate) != null ? _e : 16e3,
975
- finishGraceMs: (_g = (_f = this.config._internal) == null ? void 0 : _f.finishGraceMs) != null ? _g : defaultFinishGraceMs,
966
+ inputAudioRate: options.inputAudioFormat.rate ?? 16e3,
967
+ finishGraceMs: this.config._internal?.finishGraceMs ?? defaultFinishGraceMs,
976
968
  warnings,
977
969
  audio: options.audio,
978
970
  abortSignal: options.abortSignal,
@@ -1036,7 +1028,7 @@ function createVertexLiveTranscriptionStream({
1036
1028
  void audio.cancel().catch(() => {
1037
1029
  });
1038
1030
  }
1039
- connection == null ? void 0 : connection.close(closeCode);
1031
+ connection?.close(closeCode);
1040
1032
  };
1041
1033
  const finishWithError = (error) => {
1042
1034
  if (finished) return;
@@ -1117,7 +1109,6 @@ function createVertexLiveTranscriptionStream({
1117
1109
  void setupComplete.then(() => finished ? void 0 : sendAudio(socket)).catch(finishWithError);
1118
1110
  },
1119
1111
  onMessageText: async (text) => {
1120
- var _a, _b;
1121
1112
  if (finished) return;
1122
1113
  const parsed = await safeParseJSON({ text });
1123
1114
  if (!parsed.success) return;
@@ -1133,13 +1124,13 @@ function createVertexLiveTranscriptionStream({
1133
1124
  }
1134
1125
  if (message.error != null) {
1135
1126
  finishWithError(
1136
- new Error((_a = message.error.message) != null ? _a : "Vertex Live API error")
1127
+ new Error(message.error.message ?? "Vertex Live API error")
1137
1128
  );
1138
1129
  return;
1139
1130
  }
1140
1131
  const serverContent = message.serverContent;
1141
- const interim = serverContent == null ? void 0 : serverContent.interimInputTranscription;
1142
- if (interim == null ? void 0 : interim.text) {
1132
+ const interim = serverContent?.interimInputTranscription;
1133
+ if (interim?.text) {
1143
1134
  schedulePendingFinish();
1144
1135
  latestInterim = interim.text;
1145
1136
  controller.enqueue({
@@ -1148,7 +1139,7 @@ function createVertexLiveTranscriptionStream({
1148
1139
  text: interim.text
1149
1140
  });
1150
1141
  }
1151
- const transcription = (_b = serverContent == null ? void 0 : serverContent.inputTranscription) != null ? _b : message.inputTranscription;
1142
+ const transcription = serverContent?.inputTranscription ?? message.inputTranscription;
1152
1143
  if (transcription != null) {
1153
1144
  if (transcription.languageCode != null) {
1154
1145
  language = transcription.languageCode;
@@ -1167,11 +1158,11 @@ function createVertexLiveTranscriptionStream({
1167
1158
  completeSegment();
1168
1159
  }
1169
1160
  }
1170
- if (serverContent == null ? void 0 : serverContent.turnComplete) {
1161
+ if (serverContent?.turnComplete) {
1171
1162
  completeSegment();
1172
1163
  }
1173
- const interactionStatus = serverContent == null ? void 0 : serverContent.interactionStatus;
1174
- if (audioEnded && (interactionStatus === "IDLE" || interactionStatus === "REQUIRES_ACTION" || (serverContent == null ? void 0 : serverContent.turnComplete) === true && interactionStatus == null)) {
1164
+ const interactionStatus = serverContent?.interactionStatus;
1165
+ if (audioEnded && (interactionStatus === "IDLE" || interactionStatus === "REQUIRES_ACTION" || serverContent?.turnComplete === true && interactionStatus == null)) {
1175
1166
  finish();
1176
1167
  }
1177
1168
  },
@@ -1190,7 +1181,7 @@ function createVertexLiveTranscriptionStream({
1190
1181
  }
1191
1182
  finishWithError(
1192
1183
  new Error(
1193
- `Vertex Live transcription WebSocket closed unexpectedly before finishing (code ${code != null ? code : "unknown"}${reason ? `, reason: ${reason}` : ""}).`
1184
+ `Vertex Live transcription WebSocket closed unexpectedly before finishing (code ${code ?? "unknown"}${reason ? `, reason: ${reason}` : ""}).`
1194
1185
  )
1195
1186
  );
1196
1187
  }
@@ -1300,16 +1291,13 @@ var googleVertexVideoModelOptionsSchema = lazySchema(
1300
1291
 
1301
1292
  // src/google-vertex-video-model.ts
1302
1293
  function getFirstFrameImage(options) {
1303
- var _a, _b;
1304
- return (_b = (_a = options.frameImages) == null ? void 0 : _a.find((frame) => frame.frameType === "first_frame")) == null ? void 0 : _b.image;
1294
+ return options.frameImages?.find((frame) => frame.frameType === "first_frame")?.image;
1305
1295
  }
1306
1296
  function resolveStartImage(options) {
1307
- var _a;
1308
- return (_a = getFirstFrameImage(options)) != null ? _a : options.image;
1297
+ return getFirstFrameImage(options) ?? options.image;
1309
1298
  }
1310
1299
  function getLastFrameImage(options) {
1311
- var _a, _b;
1312
- return (_b = (_a = options.frameImages) == null ? void 0 : _a.find((frame) => frame.frameType === "last_frame")) == null ? void 0 : _b.image;
1300
+ return options.frameImages?.find((frame) => frame.frameType === "last_frame")?.image;
1313
1301
  }
1314
1302
  function getInputReferences(options) {
1315
1303
  if (options.frameImages != null && options.frameImages.length > 0) {
@@ -1355,13 +1343,12 @@ var GoogleVertexVideoModel = class {
1355
1343
  return 4;
1356
1344
  }
1357
1345
  async buildRequest(options) {
1358
- var _a, _b;
1359
1346
  const warnings = [];
1360
- const googleVertexOptions = (_a = await parseProviderOptions4({
1347
+ const googleVertexOptions = await parseProviderOptions4({
1361
1348
  provider: "googleVertex",
1362
1349
  providerOptions: options.providerOptions,
1363
1350
  schema: googleVertexVideoModelOptionsSchema
1364
- })) != null ? _a : await parseProviderOptions4({
1351
+ }) ?? await parseProviderOptions4({
1365
1352
  provider: "vertex",
1366
1353
  providerOptions: options.providerOptions,
1367
1354
  schema: googleVertexVideoModelOptionsSchema
@@ -1391,7 +1378,7 @@ var GoogleVertexVideoModel = class {
1391
1378
  const converted = convertInputReferenceImage(reference, warnings);
1392
1379
  return converted != null ? [converted] : [];
1393
1380
  });
1394
- } else if ((googleVertexOptions == null ? void 0 : googleVertexOptions.referenceImages) != null) {
1381
+ } else if (googleVertexOptions?.referenceImages != null) {
1395
1382
  instance.referenceImages = googleVertexOptions.referenceImages;
1396
1383
  }
1397
1384
  const parameters = {
@@ -1414,7 +1401,7 @@ var GoogleVertexVideoModel = class {
1414
1401
  if (options.seed) {
1415
1402
  parameters.seed = options.seed;
1416
1403
  }
1417
- const generateAudio = (_b = options.generateAudio) != null ? _b : googleVertexOptions == null ? void 0 : googleVertexOptions.generateAudio;
1404
+ const generateAudio = options.generateAudio ?? googleVertexOptions?.generateAudio;
1418
1405
  if (generateAudio != null) {
1419
1406
  parameters.generateAudio = generateAudio;
1420
1407
  }
@@ -1452,7 +1439,7 @@ var GoogleVertexVideoModel = class {
1452
1439
  currentDate
1453
1440
  }) {
1454
1441
  const response = finalOperation.response;
1455
- if (!(response == null ? void 0 : response.videos) || response.videos.length === 0) {
1442
+ if (!response?.videos || response.videos.length === 0) {
1456
1443
  throw new AISDKError({
1457
1444
  name: "VERTEX_VIDEO_GENERATION_ERROR",
1458
1445
  message: `No videos in response. Response: ${JSON.stringify(finalOperation)}`
@@ -1509,8 +1496,7 @@ var GoogleVertexVideoModel = class {
1509
1496
  };
1510
1497
  }
1511
1498
  async doStart(options) {
1512
- var _a, _b, _c;
1513
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
1499
+ const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
1514
1500
  const { instances, parameters, warnings } = await this.buildRequest(options);
1515
1501
  const { value: operation, responseHeaders } = await postJsonToApi5({
1516
1502
  url: `${this.config.baseURL}/models/${this.modelId}:predictLongRunning`,
@@ -1547,8 +1533,7 @@ var GoogleVertexVideoModel = class {
1547
1533
  };
1548
1534
  }
1549
1535
  async doStatus(options) {
1550
- var _a, _b, _c;
1551
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
1536
+ const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
1552
1537
  const { operationName } = options.operation;
1553
1538
  const { value: statusOperation, responseHeaders } = await postJsonToApi5({
1554
1539
  url: `${this.config.baseURL}/models/${this.modelId}:fetchPredictOperation`,
@@ -1626,11 +1611,11 @@ function createExpressModeFetch(apiKey, customFetch) {
1626
1611
  const modifiedInit = {
1627
1612
  ...init,
1628
1613
  headers: {
1629
- ...(init == null ? void 0 : init.headers) ? normalizeHeaders(init.headers) : {},
1614
+ ...init?.headers ? normalizeHeaders(init.headers) : {},
1630
1615
  "x-goog-api-key": apiKey
1631
1616
  }
1632
1617
  };
1633
- return (customFetch != null ? customFetch : fetch)(url.toString(), modifiedInit);
1618
+ return (customFetch ?? fetch)(url.toString(), modifiedInit);
1634
1619
  };
1635
1620
  }
1636
1621
  function createGoogleVertex(options = {}) {
@@ -1651,9 +1636,8 @@ function createGoogleVertex(options = {}) {
1651
1636
  description: "Google Vertex location"
1652
1637
  });
1653
1638
  const loadBaseURL = ({ endpoint = false } = {}) => {
1654
- var _a, _b;
1655
1639
  if (apiKey) {
1656
- return (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : EXPRESS_MODE_BASE_URL;
1640
+ return withoutTrailingSlash(options.baseURL) ?? EXPRESS_MODE_BASE_URL;
1657
1641
  }
1658
1642
  const region = loadGoogleVertexLocation();
1659
1643
  const project = loadGoogleVertexProject();
@@ -1666,12 +1650,11 @@ function createGoogleVertex(options = {}) {
1666
1650
  return `${region}-aiplatform.googleapis.com`;
1667
1651
  }
1668
1652
  };
1669
- return (_b = withoutTrailingSlash(options.baseURL)) != null ? _b : `https://${getHost()}/v1beta1/projects/${project}/locations/${region}${endpoint ? "" : "/publishers/google"}`;
1653
+ return withoutTrailingSlash(options.baseURL) ?? `https://${getHost()}/v1beta1/projects/${project}/locations/${region}${endpoint ? "" : "/publishers/google"}`;
1670
1654
  };
1671
1655
  const createConfig = (name, { endpoint = false } = {}) => {
1672
1656
  const getHeaders = async () => {
1673
- var _a;
1674
- const originalHeaders = await resolve6((_a = options.headers) != null ? _a : {});
1657
+ const originalHeaders = await resolve6(options.headers ?? {});
1675
1658
  return withUserAgentSuffix(
1676
1659
  originalHeaders,
1677
1660
  `ai-sdk/google-vertex/${VERSION}`
@@ -1685,7 +1668,6 @@ function createGoogleVertex(options = {}) {
1685
1668
  };
1686
1669
  };
1687
1670
  const createChatModel = (modelId) => {
1688
- var _a, _b, _c;
1689
1671
  const endpoint = isEndpointModelId(modelId);
1690
1672
  if (endpoint && apiKey) {
1691
1673
  throw new Error(
@@ -1694,7 +1676,7 @@ function createGoogleVertex(options = {}) {
1694
1676
  }
1695
1677
  return new GoogleLanguageModel2(modelId, {
1696
1678
  ...createConfig("chat", { endpoint }),
1697
- generateId: (_a = options.generateId) != null ? _a : generateId,
1679
+ generateId: options.generateId ?? generateId,
1698
1680
  supportedUrls: () => ({
1699
1681
  "*": [
1700
1682
  // HTTP URLs:
@@ -1704,12 +1686,12 @@ function createGoogleVertex(options = {}) {
1704
1686
  ]
1705
1687
  }),
1706
1688
  downloadToolResultFiles: {
1707
- maxBytes: (_c = (_b = options.toolResultDownloads) == null ? void 0 : _b.maxBytes) != null ? _c : 7 * 1024 * 1024
1689
+ maxBytes: options.toolResultDownloads?.maxBytes ?? 7 * 1024 * 1024,
1690
+ supportsGoogleCloudStorageUrls: true
1708
1691
  }
1709
1692
  });
1710
1693
  };
1711
1694
  const createInteractionsModel = (modelIdOrAgent) => {
1712
- var _a;
1713
1695
  if (apiKey) {
1714
1696
  throw new Error(
1715
1697
  "Google Vertex Interactions models do not support Express Mode API keys. Use standard Google Cloud credentials instead."
@@ -1723,25 +1705,19 @@ function createGoogleVertex(options = {}) {
1723
1705
  // endpoint-style base URL without the `/publishers/google` suffix that
1724
1706
  // the base-model paths carry.
1725
1707
  ...createConfig("interactions", { endpoint: true }),
1726
- generateId: (_a = options.generateId) != null ? _a : generateId
1708
+ generateId: options.generateId ?? generateId
1727
1709
  }
1728
1710
  );
1729
1711
  };
1730
1712
  const createEmbeddingModel = (modelId) => new GoogleVertexEmbeddingModel(modelId, createConfig("embedding"));
1731
- const createImageModel = (modelId) => {
1732
- var _a;
1733
- return new GoogleVertexImageModel(modelId, {
1734
- ...createConfig("image"),
1735
- generateId: (_a = options.generateId) != null ? _a : generateId
1736
- });
1737
- };
1738
- const createVideoModel = (modelId) => {
1739
- var _a;
1740
- return new GoogleVertexVideoModel(modelId, {
1741
- ...createConfig("video"),
1742
- generateId: (_a = options.generateId) != null ? _a : generateId
1743
- });
1744
- };
1713
+ const createImageModel = (modelId) => new GoogleVertexImageModel(modelId, {
1714
+ ...createConfig("image"),
1715
+ generateId: options.generateId ?? generateId
1716
+ });
1717
+ const createVideoModel = (modelId) => new GoogleVertexVideoModel(modelId, {
1718
+ ...createConfig("video"),
1719
+ generateId: options.generateId ?? generateId
1720
+ });
1745
1721
  const createSpeechModel = (modelId) => {
1746
1722
  if (modelId.startsWith("chirp")) {
1747
1723
  if (apiKey) {