@ai-sdk/google-vertex 5.0.92 → 5.0.95

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.
@@ -18,7 +18,7 @@ import {
18
18
  } from "@ai-sdk/provider-utils";
19
19
 
20
20
  // src/version.ts
21
- var VERSION = true ? "5.0.92" : "0.0.0-test";
21
+ var VERSION = true ? "5.0.95" : "0.0.0-test";
22
22
 
23
23
  // src/google-vertex-embedding-model.ts
24
24
  import {
@@ -127,7 +127,6 @@ var GoogleVertexEmbeddingModel = class _GoogleVertexEmbeddingModel {
127
127
  abortSignal,
128
128
  providerOptions
129
129
  }) {
130
- var _a;
131
130
  let googleOptions = await parseProviderOptions({
132
131
  provider: "googleVertex",
133
132
  providerOptions,
@@ -147,7 +146,7 @@ var GoogleVertexEmbeddingModel = class _GoogleVertexEmbeddingModel {
147
146
  schema: googleVertexEmbeddingModelOptions
148
147
  });
149
148
  }
150
- googleOptions = googleOptions != null ? googleOptions : {};
149
+ googleOptions = googleOptions ?? {};
151
150
  if (values.length > this.maxEmbeddingsPerCall) {
152
151
  throw new TooManyEmbeddingValuesForCallError({
153
152
  provider: this.provider,
@@ -187,7 +186,7 @@ var GoogleVertexEmbeddingModel = class _GoogleVertexEmbeddingModel {
187
186
  return {
188
187
  warnings: [],
189
188
  embeddings: [response2.embedding.values],
190
- usage: ((_a = response2.usageMetadata) == null ? void 0 : _a.promptTokenCount) == null ? void 0 : { tokens: response2.usageMetadata.promptTokenCount },
189
+ usage: response2.usageMetadata?.promptTokenCount == null ? void 0 : { tokens: response2.usageMetadata.promptTokenCount },
191
190
  response: { headers: responseHeaders2, body: rawValue2 }
192
191
  };
193
192
  }
@@ -285,7 +284,6 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
285
284
  return this.config.provider;
286
285
  }
287
286
  async doGenerate(options) {
288
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
289
287
  if (!this.modelId.startsWith("gemini-")) {
290
288
  throw new Error(
291
289
  "Google image models other than Gemini are no longer supported. Use a model ID that starts with `gemini-`."
@@ -345,9 +343,9 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
345
343
  const languageModel = new GoogleLanguageModel(this.modelId, {
346
344
  provider: this.config.provider,
347
345
  baseURL: this.config.baseURL,
348
- headers: (_a = this.config.headers) != null ? _a : {},
346
+ headers: this.config.headers ?? {},
349
347
  fetch: this.config.fetch,
350
- generateId: (_b = this.config.generateId) != null ? _b : defaultGenerateId,
348
+ generateId: this.config.generateId ?? defaultGenerateId,
351
349
  supportedUrls: () => ({
352
350
  "*": [/^https?:\/\/.*$/, /^gs:\/\/.*$/]
353
351
  })
@@ -356,7 +354,7 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
356
354
  responseModalities: _strippedResponseModalities,
357
355
  imageConfig: userImageConfig,
358
356
  ...userVertexOptions
359
- } = (_d = (_c = providerOptions == null ? void 0 : providerOptions.googleVertex) != null ? _c : providerOptions == null ? void 0 : providerOptions.vertex) != null ? _d : {};
357
+ } = providerOptions?.googleVertex ?? providerOptions?.vertex ?? {};
360
358
  const innerVertexOptions = {
361
359
  ...userVertexOptions,
362
360
  responseModalities: ["IMAGE"],
@@ -377,7 +375,7 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
377
375
  headers,
378
376
  abortSignal
379
377
  });
380
- const currentDate = (_g = (_f = (_e = this.config._internal) == null ? void 0 : _e.currentDate) == null ? void 0 : _f.call(_e)) != null ? _g : /* @__PURE__ */ new Date();
378
+ const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
381
379
  const images = [];
382
380
  for (const part of result.content) {
383
381
  if (part.type === "file" && part.mediaType.startsWith("image/") && part.data.type === "data") {
@@ -398,12 +396,12 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
398
396
  response: {
399
397
  timestamp: currentDate,
400
398
  modelId: this.modelId,
401
- headers: (_h = result.response) == null ? void 0 : _h.headers
399
+ headers: result.response?.headers
402
400
  },
403
401
  usage: result.usage ? {
404
402
  inputTokens: result.usage.inputTokens.total,
405
403
  outputTokens: result.usage.outputTokens.total,
406
- totalTokens: ((_i = result.usage.inputTokens.total) != null ? _i : 0) + ((_j = result.usage.outputTokens.total) != null ? _j : 0)
404
+ totalTokens: (result.usage.inputTokens.total ?? 0) + (result.usage.outputTokens.total ?? 0)
407
405
  } : void 0
408
406
  };
409
407
  }
@@ -444,8 +442,7 @@ var GoogleVertexCloudTTSSpeechModel = class _GoogleVertexCloudTTSSpeechModel {
444
442
  return this.config.provider;
445
443
  }
446
444
  async doGenerate(options) {
447
- var _a, _b, _c;
448
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
445
+ const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
449
446
  const warnings = [];
450
447
  const {
451
448
  text,
@@ -460,9 +457,9 @@ var GoogleVertexCloudTTSSpeechModel = class _GoogleVertexCloudTTSSpeechModel {
460
457
  if (voice.includes(CHIRP3_HD_VOICE_INFIX)) {
461
458
  voiceName = voice;
462
459
  const localePrefix = voice.split(CHIRP3_HD_VOICE_INFIX)[0].replace(/-$/, "");
463
- languageCode = language != null ? language : localePrefix || DEFAULT_LANGUAGE;
460
+ languageCode = language ?? (localePrefix || DEFAULT_LANGUAGE);
464
461
  } else {
465
- languageCode = language != null ? language : DEFAULT_LANGUAGE;
462
+ languageCode = language ?? DEFAULT_LANGUAGE;
466
463
  voiceName = `${languageCode}-${CHIRP3_HD_VOICE_INFIX}-${voice}`;
467
464
  }
468
465
  if (instructions != null) {
@@ -603,7 +600,7 @@ function convertBcp47ToIso6391(value) {
603
600
  try {
604
601
  const language = new Intl.Locale(value).language;
605
602
  return language.length === 2 ? language : void 0;
606
- } catch (e) {
603
+ } catch {
607
604
  return void 0;
608
605
  }
609
606
  }
@@ -626,8 +623,7 @@ var GoogleVertexTranscriptionModel = class _GoogleVertexTranscriptionModel {
626
623
  return this.config.provider;
627
624
  }
628
625
  async doGenerate(options) {
629
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
630
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
626
+ const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
631
627
  const warnings = [];
632
628
  let googleOptions;
633
629
  for (const provider of ["googleVertex", "vertex", "google"]) {
@@ -640,8 +636,8 @@ var GoogleVertexTranscriptionModel = class _GoogleVertexTranscriptionModel {
640
636
  break;
641
637
  }
642
638
  }
643
- const region = (_d = googleOptions == null ? void 0 : googleOptions.region) != null ? _d : this.config.location;
644
- const languageCodes = (_e = googleOptions == null ? void 0 : googleOptions.languageCodes) != null ? _e : ["auto"];
639
+ const region = googleOptions?.region ?? this.config.location;
640
+ const languageCodes = googleOptions?.languageCodes ?? ["auto"];
645
641
  const content = typeof options.audio === "string" ? options.audio : convertUint8ArrayToBase64(options.audio);
646
642
  const requestBody = {
647
643
  config: {
@@ -651,8 +647,8 @@ var GoogleVertexTranscriptionModel = class _GoogleVertexTranscriptionModel {
651
647
  autoDecodingConfig: {},
652
648
  features: {
653
649
  // Word timing populates `segments`.
654
- enableWordTimeOffsets: (_f = googleOptions == null ? void 0 : googleOptions.enableWordTimeOffsets) != null ? _f : true,
655
- enableAutomaticPunctuation: (_g = googleOptions == null ? void 0 : googleOptions.enableAutomaticPunctuation) != null ? _g : true
650
+ enableWordTimeOffsets: googleOptions?.enableWordTimeOffsets ?? true,
651
+ enableAutomaticPunctuation: googleOptions?.enableAutomaticPunctuation ?? true
656
652
  }
657
653
  },
658
654
  content
@@ -677,28 +673,22 @@ var GoogleVertexTranscriptionModel = class _GoogleVertexTranscriptionModel {
677
673
  abortSignal: options.abortSignal,
678
674
  fetch: this.config.fetch
679
675
  });
680
- const results = (_h = response.results) != null ? _h : [];
681
- const text = results.map((result) => {
682
- var _a2, _b2, _c2;
683
- return (_c2 = (_b2 = (_a2 = result.alternatives) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.transcript) != null ? _c2 : "";
684
- }).join(" ").trim();
676
+ const results = response.results ?? [];
677
+ const text = results.map((result) => result.alternatives?.[0]?.transcript ?? "").join(" ").trim();
685
678
  const segments = results.flatMap(
686
- (result) => {
687
- var _a2, _b2, _c2, _d2;
688
- return (_d2 = (_c2 = (_b2 = (_a2 = result.alternatives) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.words) == null ? void 0 : _c2.flatMap((word) => {
689
- const startSecond = parseDurationSeconds(word.startOffset);
690
- const endSecond = parseDurationSeconds(word.endOffset);
691
- return word.word == null || startSecond == null || endSecond == null ? [] : [{ text: word.word, startSecond, endSecond }];
692
- })) != null ? _d2 : [];
693
- }
679
+ (result) => result.alternatives?.[0]?.words?.flatMap((word) => {
680
+ const startSecond = parseDurationSeconds(word.startOffset);
681
+ const endSecond = parseDurationSeconds(word.endOffset);
682
+ return word.word == null || startSecond == null || endSecond == null ? [] : [{ text: word.word, startSecond, endSecond }];
683
+ }) ?? []
694
684
  );
695
- const language = convertBcp47ToIso6391((_i = results[0]) == null ? void 0 : _i.languageCode);
685
+ const language = convertBcp47ToIso6391(results[0]?.languageCode);
696
686
  return {
697
687
  text,
698
688
  segments,
699
689
  language,
700
690
  durationInSeconds: parseDurationSeconds(
701
- (_j = response.metadata) == null ? void 0 : _j.totalBilledDuration
691
+ response.metadata?.totalBilledDuration
702
692
  ),
703
693
  warnings,
704
694
  response: {
@@ -831,14 +821,13 @@ var GoogleVertexGeminiTranscriptionModel = class _GoogleVertexGeminiTranscriptio
831
821
  }
832
822
  }
833
823
  async doGenerate(options) {
834
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
835
824
  if (isLiveTranscriptionModelId(this.modelId)) {
836
825
  throw new InvalidArgumentError({
837
826
  argument: "modelId",
838
827
  message: `Model '${this.modelId}' only supports streaming transcription. Use experimental_streamTranscribe, or a unary model such as 'gemini-3.5-transcribe'.`
839
828
  });
840
829
  }
841
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
830
+ const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
842
831
  const warnings = [];
843
832
  const googleOptions = await this.parseOptions(options.providerOptions);
844
833
  const audioTranscriptionConfig = buildAudioTranscriptionConfig(googleOptions);
@@ -876,23 +865,17 @@ var GoogleVertexGeminiTranscriptionModel = class _GoogleVertexGeminiTranscriptio
876
865
  abortSignal: options.abortSignal,
877
866
  fetch: this.config.fetch
878
867
  });
879
- 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 : [];
880
- const plainText = parts.map((part) => {
881
- var _a2;
882
- return (_a2 = part.text) != null ? _a2 : "";
883
- }).join("");
884
- const transcriptionText = parts.map((part) => {
885
- var _a2, _b2;
886
- return (_b2 = (_a2 = part.audioTranscription) == null ? void 0 : _a2.text) != null ? _b2 : "";
887
- }).join("");
868
+ const parts = response.candidates?.[0]?.content?.parts ?? [];
869
+ const plainText = parts.map((part) => part.text ?? "").join("");
870
+ const transcriptionText = parts.map((part) => part.audioTranscription?.text ?? "").join("");
888
871
  const text = plainText !== "" ? plainText : transcriptionText;
889
872
  let language;
890
873
  const segments = [];
891
874
  for (const part of parts) {
892
875
  const transcription = part.audioTranscription;
893
876
  if (transcription == null) continue;
894
- language != null ? language : language = (_h = transcription.languageCode) != null ? _h : void 0;
895
- for (const word of (_i = transcription.words) != null ? _i : []) {
877
+ language ??= transcription.languageCode ?? void 0;
878
+ for (const word of transcription.words ?? []) {
896
879
  const startSecond = parseOffsetSeconds(word.startOffset);
897
880
  const endSecond = parseOffsetSeconds(word.endOffset);
898
881
  if (word.word == null || startSecond == null || endSecond == null) {
@@ -921,14 +904,13 @@ var GoogleVertexGeminiTranscriptionModel = class _GoogleVertexGeminiTranscriptio
921
904
  };
922
905
  }
923
906
  async doStream(options) {
924
- var _a, _b, _c, _d, _e, _f, _g;
925
907
  if (!isLiveTranscriptionModelId(this.modelId)) {
926
908
  throw new InvalidArgumentError({
927
909
  argument: "modelId",
928
910
  message: `Model '${this.modelId}' does not support streaming transcription. Use a live model such as 'gemini-3.5-transcribe-live'.`
929
911
  });
930
912
  }
931
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
913
+ const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
932
914
  const warnings = [];
933
915
  const googleOptions = await this.parseOptions(options.providerOptions);
934
916
  validateLiveInputAudioFormat(options.inputAudioFormat);
@@ -943,7 +925,7 @@ var GoogleVertexGeminiTranscriptionModel = class _GoogleVertexGeminiTranscriptio
943
925
  );
944
926
  const setup = {
945
927
  model: modelResource,
946
- inputAudioTranscription: (_d = buildAudioTranscriptionConfig(googleOptions)) != null ? _d : {}
928
+ inputAudioTranscription: buildAudioTranscriptionConfig(googleOptions) ?? {}
947
929
  };
948
930
  return {
949
931
  request: { body: setup },
@@ -956,8 +938,8 @@ var GoogleVertexGeminiTranscriptionModel = class _GoogleVertexGeminiTranscriptio
956
938
  url,
957
939
  headers,
958
940
  setup,
959
- inputAudioRate: (_e = options.inputAudioFormat.rate) != null ? _e : 16e3,
960
- finishGraceMs: (_g = (_f = this.config._internal) == null ? void 0 : _f.finishGraceMs) != null ? _g : defaultFinishGraceMs,
941
+ inputAudioRate: options.inputAudioFormat.rate ?? 16e3,
942
+ finishGraceMs: this.config._internal?.finishGraceMs ?? defaultFinishGraceMs,
961
943
  warnings,
962
944
  audio: options.audio,
963
945
  abortSignal: options.abortSignal,
@@ -1021,7 +1003,7 @@ function createVertexLiveTranscriptionStream({
1021
1003
  void audio.cancel().catch(() => {
1022
1004
  });
1023
1005
  }
1024
- connection == null ? void 0 : connection.close(closeCode);
1006
+ connection?.close(closeCode);
1025
1007
  };
1026
1008
  const finishWithError = (error) => {
1027
1009
  if (finished) return;
@@ -1102,7 +1084,6 @@ function createVertexLiveTranscriptionStream({
1102
1084
  void setupComplete.then(() => finished ? void 0 : sendAudio(socket)).catch(finishWithError);
1103
1085
  },
1104
1086
  onMessageText: async (text) => {
1105
- var _a, _b;
1106
1087
  if (finished) return;
1107
1088
  const parsed = await safeParseJSON({ text });
1108
1089
  if (!parsed.success) return;
@@ -1118,13 +1099,13 @@ function createVertexLiveTranscriptionStream({
1118
1099
  }
1119
1100
  if (message.error != null) {
1120
1101
  finishWithError(
1121
- new Error((_a = message.error.message) != null ? _a : "Vertex Live API error")
1102
+ new Error(message.error.message ?? "Vertex Live API error")
1122
1103
  );
1123
1104
  return;
1124
1105
  }
1125
1106
  const serverContent = message.serverContent;
1126
- const interim = serverContent == null ? void 0 : serverContent.interimInputTranscription;
1127
- if (interim == null ? void 0 : interim.text) {
1107
+ const interim = serverContent?.interimInputTranscription;
1108
+ if (interim?.text) {
1128
1109
  schedulePendingFinish();
1129
1110
  latestInterim = interim.text;
1130
1111
  controller.enqueue({
@@ -1133,7 +1114,7 @@ function createVertexLiveTranscriptionStream({
1133
1114
  text: interim.text
1134
1115
  });
1135
1116
  }
1136
- const transcription = (_b = serverContent == null ? void 0 : serverContent.inputTranscription) != null ? _b : message.inputTranscription;
1117
+ const transcription = serverContent?.inputTranscription ?? message.inputTranscription;
1137
1118
  if (transcription != null) {
1138
1119
  if (transcription.languageCode != null) {
1139
1120
  language = transcription.languageCode;
@@ -1152,11 +1133,11 @@ function createVertexLiveTranscriptionStream({
1152
1133
  completeSegment();
1153
1134
  }
1154
1135
  }
1155
- if (serverContent == null ? void 0 : serverContent.turnComplete) {
1136
+ if (serverContent?.turnComplete) {
1156
1137
  completeSegment();
1157
1138
  }
1158
- const interactionStatus = serverContent == null ? void 0 : serverContent.interactionStatus;
1159
- if (audioEnded && (interactionStatus === "IDLE" || interactionStatus === "REQUIRES_ACTION" || (serverContent == null ? void 0 : serverContent.turnComplete) === true && interactionStatus == null)) {
1139
+ const interactionStatus = serverContent?.interactionStatus;
1140
+ if (audioEnded && (interactionStatus === "IDLE" || interactionStatus === "REQUIRES_ACTION" || serverContent?.turnComplete === true && interactionStatus == null)) {
1160
1141
  finish();
1161
1142
  }
1162
1143
  },
@@ -1175,7 +1156,7 @@ function createVertexLiveTranscriptionStream({
1175
1156
  }
1176
1157
  finishWithError(
1177
1158
  new Error(
1178
- `Vertex Live transcription WebSocket closed unexpectedly before finishing (code ${code != null ? code : "unknown"}${reason ? `, reason: ${reason}` : ""}).`
1159
+ `Vertex Live transcription WebSocket closed unexpectedly before finishing (code ${code ?? "unknown"}${reason ? `, reason: ${reason}` : ""}).`
1179
1160
  )
1180
1161
  );
1181
1162
  }
@@ -1285,16 +1266,13 @@ var googleVertexVideoModelOptionsSchema = lazySchema(
1285
1266
 
1286
1267
  // src/google-vertex-video-model.ts
1287
1268
  function getFirstFrameImage(options) {
1288
- var _a, _b;
1289
- return (_b = (_a = options.frameImages) == null ? void 0 : _a.find((frame) => frame.frameType === "first_frame")) == null ? void 0 : _b.image;
1269
+ return options.frameImages?.find((frame) => frame.frameType === "first_frame")?.image;
1290
1270
  }
1291
1271
  function resolveStartImage(options) {
1292
- var _a;
1293
- return (_a = getFirstFrameImage(options)) != null ? _a : options.image;
1272
+ return getFirstFrameImage(options) ?? options.image;
1294
1273
  }
1295
1274
  function getLastFrameImage(options) {
1296
- var _a, _b;
1297
- return (_b = (_a = options.frameImages) == null ? void 0 : _a.find((frame) => frame.frameType === "last_frame")) == null ? void 0 : _b.image;
1275
+ return options.frameImages?.find((frame) => frame.frameType === "last_frame")?.image;
1298
1276
  }
1299
1277
  function getInputReferences(options) {
1300
1278
  if (options.frameImages != null && options.frameImages.length > 0) {
@@ -1340,13 +1318,12 @@ var GoogleVertexVideoModel = class {
1340
1318
  return 4;
1341
1319
  }
1342
1320
  async buildRequest(options) {
1343
- var _a, _b;
1344
1321
  const warnings = [];
1345
- const googleVertexOptions = (_a = await parseProviderOptions4({
1322
+ const googleVertexOptions = await parseProviderOptions4({
1346
1323
  provider: "googleVertex",
1347
1324
  providerOptions: options.providerOptions,
1348
1325
  schema: googleVertexVideoModelOptionsSchema
1349
- })) != null ? _a : await parseProviderOptions4({
1326
+ }) ?? await parseProviderOptions4({
1350
1327
  provider: "vertex",
1351
1328
  providerOptions: options.providerOptions,
1352
1329
  schema: googleVertexVideoModelOptionsSchema
@@ -1376,7 +1353,7 @@ var GoogleVertexVideoModel = class {
1376
1353
  const converted = convertInputReferenceImage(reference, warnings);
1377
1354
  return converted != null ? [converted] : [];
1378
1355
  });
1379
- } else if ((googleVertexOptions == null ? void 0 : googleVertexOptions.referenceImages) != null) {
1356
+ } else if (googleVertexOptions?.referenceImages != null) {
1380
1357
  instance.referenceImages = googleVertexOptions.referenceImages;
1381
1358
  }
1382
1359
  const parameters = {
@@ -1399,7 +1376,7 @@ var GoogleVertexVideoModel = class {
1399
1376
  if (options.seed) {
1400
1377
  parameters.seed = options.seed;
1401
1378
  }
1402
- const generateAudio = (_b = options.generateAudio) != null ? _b : googleVertexOptions == null ? void 0 : googleVertexOptions.generateAudio;
1379
+ const generateAudio = options.generateAudio ?? googleVertexOptions?.generateAudio;
1403
1380
  if (generateAudio != null) {
1404
1381
  parameters.generateAudio = generateAudio;
1405
1382
  }
@@ -1437,7 +1414,7 @@ var GoogleVertexVideoModel = class {
1437
1414
  currentDate
1438
1415
  }) {
1439
1416
  const response = finalOperation.response;
1440
- if (!(response == null ? void 0 : response.videos) || response.videos.length === 0) {
1417
+ if (!response?.videos || response.videos.length === 0) {
1441
1418
  throw new AISDKError({
1442
1419
  name: "VERTEX_VIDEO_GENERATION_ERROR",
1443
1420
  message: `No videos in response. Response: ${JSON.stringify(finalOperation)}`
@@ -1494,8 +1471,7 @@ var GoogleVertexVideoModel = class {
1494
1471
  };
1495
1472
  }
1496
1473
  async doStart(options) {
1497
- var _a, _b, _c;
1498
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
1474
+ const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
1499
1475
  const { instances, parameters, warnings } = await this.buildRequest(options);
1500
1476
  const { value: operation, responseHeaders } = await postJsonToApi5({
1501
1477
  url: `${this.config.baseURL}/models/${this.modelId}:predictLongRunning`,
@@ -1532,8 +1508,7 @@ var GoogleVertexVideoModel = class {
1532
1508
  };
1533
1509
  }
1534
1510
  async doStatus(options) {
1535
- var _a, _b, _c;
1536
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
1511
+ const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
1537
1512
  const { operationName } = options.operation;
1538
1513
  const { value: statusOperation, responseHeaders } = await postJsonToApi5({
1539
1514
  url: `${this.config.baseURL}/models/${this.modelId}:fetchPredictOperation`,
@@ -1611,11 +1586,11 @@ function createExpressModeFetch(apiKey, customFetch) {
1611
1586
  const modifiedInit = {
1612
1587
  ...init,
1613
1588
  headers: {
1614
- ...(init == null ? void 0 : init.headers) ? normalizeHeaders(init.headers) : {},
1589
+ ...init?.headers ? normalizeHeaders(init.headers) : {},
1615
1590
  "x-goog-api-key": apiKey
1616
1591
  }
1617
1592
  };
1618
- return (customFetch != null ? customFetch : fetch)(url.toString(), modifiedInit);
1593
+ return (customFetch ?? fetch)(url.toString(), modifiedInit);
1619
1594
  };
1620
1595
  }
1621
1596
  function createGoogleVertex(options = {}) {
@@ -1636,9 +1611,8 @@ function createGoogleVertex(options = {}) {
1636
1611
  description: "Google Vertex location"
1637
1612
  });
1638
1613
  const loadBaseURL = ({ endpoint = false } = {}) => {
1639
- var _a, _b;
1640
1614
  if (apiKey) {
1641
- return (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : EXPRESS_MODE_BASE_URL;
1615
+ return withoutTrailingSlash(options.baseURL) ?? EXPRESS_MODE_BASE_URL;
1642
1616
  }
1643
1617
  const region = loadGoogleVertexLocation();
1644
1618
  const project = loadGoogleVertexProject();
@@ -1651,12 +1625,11 @@ function createGoogleVertex(options = {}) {
1651
1625
  return `${region}-aiplatform.googleapis.com`;
1652
1626
  }
1653
1627
  };
1654
- return (_b = withoutTrailingSlash(options.baseURL)) != null ? _b : `https://${getHost()}/v1beta1/projects/${project}/locations/${region}${endpoint ? "" : "/publishers/google"}`;
1628
+ return withoutTrailingSlash(options.baseURL) ?? `https://${getHost()}/v1beta1/projects/${project}/locations/${region}${endpoint ? "" : "/publishers/google"}`;
1655
1629
  };
1656
1630
  const createConfig = (name, { endpoint = false } = {}) => {
1657
1631
  const getHeaders = async () => {
1658
- var _a;
1659
- const originalHeaders = await resolve6((_a = options.headers) != null ? _a : {});
1632
+ const originalHeaders = await resolve6(options.headers ?? {});
1660
1633
  return withUserAgentSuffix(
1661
1634
  originalHeaders,
1662
1635
  `ai-sdk/google-vertex/${VERSION}`
@@ -1670,7 +1643,6 @@ function createGoogleVertex(options = {}) {
1670
1643
  };
1671
1644
  };
1672
1645
  const createChatModel = (modelId) => {
1673
- var _a, _b, _c;
1674
1646
  const endpoint = isEndpointModelId(modelId);
1675
1647
  if (endpoint && apiKey) {
1676
1648
  throw new Error(
@@ -1679,7 +1651,7 @@ function createGoogleVertex(options = {}) {
1679
1651
  }
1680
1652
  return new GoogleLanguageModel2(modelId, {
1681
1653
  ...createConfig("chat", { endpoint }),
1682
- generateId: (_a = options.generateId) != null ? _a : generateId,
1654
+ generateId: options.generateId ?? generateId,
1683
1655
  supportedUrls: () => ({
1684
1656
  "*": [
1685
1657
  // HTTP URLs:
@@ -1689,12 +1661,12 @@ function createGoogleVertex(options = {}) {
1689
1661
  ]
1690
1662
  }),
1691
1663
  downloadToolResultFiles: {
1692
- maxBytes: (_c = (_b = options.toolResultDownloads) == null ? void 0 : _b.maxBytes) != null ? _c : 7 * 1024 * 1024
1664
+ maxBytes: options.toolResultDownloads?.maxBytes ?? 7 * 1024 * 1024,
1665
+ supportsGoogleCloudStorageUrls: true
1693
1666
  }
1694
1667
  });
1695
1668
  };
1696
1669
  const createInteractionsModel = (modelIdOrAgent) => {
1697
- var _a;
1698
1670
  if (apiKey) {
1699
1671
  throw new Error(
1700
1672
  "Google Vertex Interactions models do not support Express Mode API keys. Use standard Google Cloud credentials instead."
@@ -1708,25 +1680,19 @@ function createGoogleVertex(options = {}) {
1708
1680
  // endpoint-style base URL without the `/publishers/google` suffix that
1709
1681
  // the base-model paths carry.
1710
1682
  ...createConfig("interactions", { endpoint: true }),
1711
- generateId: (_a = options.generateId) != null ? _a : generateId
1683
+ generateId: options.generateId ?? generateId
1712
1684
  }
1713
1685
  );
1714
1686
  };
1715
1687
  const createEmbeddingModel = (modelId) => new GoogleVertexEmbeddingModel(modelId, createConfig("embedding"));
1716
- const createImageModel = (modelId) => {
1717
- var _a;
1718
- return new GoogleVertexImageModel(modelId, {
1719
- ...createConfig("image"),
1720
- generateId: (_a = options.generateId) != null ? _a : generateId
1721
- });
1722
- };
1723
- const createVideoModel = (modelId) => {
1724
- var _a;
1725
- return new GoogleVertexVideoModel(modelId, {
1726
- ...createConfig("video"),
1727
- generateId: (_a = options.generateId) != null ? _a : generateId
1728
- });
1729
- };
1688
+ const createImageModel = (modelId) => new GoogleVertexImageModel(modelId, {
1689
+ ...createConfig("image"),
1690
+ generateId: options.generateId ?? generateId
1691
+ });
1692
+ const createVideoModel = (modelId) => new GoogleVertexVideoModel(modelId, {
1693
+ ...createConfig("video"),
1694
+ generateId: options.generateId ?? generateId
1695
+ });
1730
1696
  const createSpeechModel = (modelId) => {
1731
1697
  if (modelId.startsWith("chirp")) {
1732
1698
  if (apiKey) {