@ai-sdk/google 3.0.89 → 3.0.91

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/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 3.0.91
4
+
5
+ ### Patch Changes
6
+
7
+ - bbac4da: Fix Google tool result conversion to send file data as inline data instead of JSON text on the legacy tool-result path.
8
+ - 3fda3bc: Expand standalone Google `threshold` provider options into safety settings.
9
+ - e1af05f: feat (video): support video (not just image) reference inputs in `inputReferences` for reference-to-video generation
10
+ - Updated dependencies [e1af05f]
11
+ - @ai-sdk/provider@3.0.14
12
+ - @ai-sdk/provider-utils@4.0.38
13
+
14
+ ## 3.0.90
15
+
16
+ ### Patch Changes
17
+
18
+ - b585445: Backport Gemini Interactions video output parsing and per-modality output token breakdown for AI SDK v6.
19
+ - 1825ecc: Backport `vertex.interactions()` for the Gemini Interactions API on Vertex AI for AI SDK v6.
20
+ - afee362: Pass documented Gemini external HTTPS file URLs through without downloading them.
21
+ - 327642b: fix: more precise default message for tool execution denial
22
+ - Updated dependencies [d559de9]
23
+ - @ai-sdk/provider-utils@4.0.37
24
+
3
25
  ## 3.0.89
4
26
 
5
27
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -373,6 +373,13 @@ type GoogleInteractionsProviderMetadata = {
373
373
  * Service tier used for this interaction (passthrough for observability).
374
374
  */
375
375
  serviceTier?: string;
376
+ /**
377
+ * Output token counts keyed by modality (e.g. `{ video: 57920 }`), sourced
378
+ * from the Interactions API `output_tokens_by_modality`. Present only when
379
+ * the response reports a breakdown. Preview surface for per-modality billing;
380
+ * may be promoted to a first-class usage field later.
381
+ */
382
+ outputTokensByModality?: Record<string, number>;
376
383
  /**
377
384
  * Per-block signature hash for backend validation. Set by the SDK on output
378
385
  * reasoning / tool-call parts and round-tripped on input parts.
package/dist/index.d.ts CHANGED
@@ -373,6 +373,13 @@ type GoogleInteractionsProviderMetadata = {
373
373
  * Service tier used for this interaction (passthrough for observability).
374
374
  */
375
375
  serviceTier?: string;
376
+ /**
377
+ * Output token counts keyed by modality (e.g. `{ video: 57920 }`), sourced
378
+ * from the Interactions API `output_tokens_by_modality`. Present only when
379
+ * the response reports a breakdown. Preview surface for per-modality billing;
380
+ * may be promoted to a first-class usage field later.
381
+ */
382
+ outputTokensByModality?: Record<string, number>;
376
383
  /**
377
384
  * Per-block signature hash for backend validation. Set by the SDK on output
378
385
  * reasoning / tool-call parts and round-tripped on input parts.
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(index_exports);
30
30
  var import_provider_utils23 = require("@ai-sdk/provider-utils");
31
31
 
32
32
  // src/version.ts
33
- var VERSION = true ? "3.0.89" : "0.0.0-test";
33
+ var VERSION = true ? "3.0.91" : "0.0.0-test";
34
34
 
35
35
  // src/google-generative-ai-embedding-model.ts
36
36
  var import_provider = require("@ai-sdk/provider");
@@ -511,6 +511,8 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
511
511
  });
512
512
  break;
513
513
  case "image-data":
514
+ case "file-data": {
515
+ const topLevelMediaType = String(contentPart.mediaType).split("/")[0];
514
516
  parts.push(
515
517
  {
516
518
  inlineData: {
@@ -519,10 +521,11 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
519
521
  }
520
522
  },
521
523
  {
522
- text: "Tool executed successfully and returned this image as a response"
524
+ text: `Tool executed successfully and returned this ${topLevelMediaType === "image" ? "image" : "file"} as a response`
523
525
  }
524
526
  );
525
527
  break;
528
+ }
526
529
  default:
527
530
  parts.push({ text: JSON.stringify(contentPart) });
528
531
  break;
@@ -724,7 +727,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
724
727
  name: part.toolName,
725
728
  response: {
726
729
  name: part.toolName,
727
- content: output.type === "execution-denied" ? (_e = output.reason) != null ? _e : "Tool execution denied." : output.value
730
+ content: output.type === "execution-denied" ? (_e = output.reason) != null ? _e : "Tool call execution denied." : output.value
728
731
  }
729
732
  }
730
733
  });
@@ -1434,6 +1437,12 @@ function mapGoogleGenerativeAIFinishReason({
1434
1437
  }
1435
1438
 
1436
1439
  // src/google-generative-ai-language-model.ts
1440
+ var configurableSafetySettingCategories = [
1441
+ "HARM_CATEGORY_HATE_SPEECH",
1442
+ "HARM_CATEGORY_DANGEROUS_CONTENT",
1443
+ "HARM_CATEGORY_HARASSMENT",
1444
+ "HARM_CATEGORY_SEXUALLY_EXPLICIT"
1445
+ ];
1437
1446
  var GoogleGenerativeAILanguageModel = class {
1438
1447
  constructor(modelId, config) {
1439
1448
  this.specificationVersion = "v3";
@@ -1464,7 +1473,7 @@ var GoogleGenerativeAILanguageModel = class {
1464
1473
  toolChoice,
1465
1474
  providerOptions
1466
1475
  }, { isStreaming = false } = {}) {
1467
- var _a, _b;
1476
+ var _a, _b, _c;
1468
1477
  const warnings = [];
1469
1478
  const providerOptionsName = this.config.provider.includes("vertex") ? "vertex" : "google";
1470
1479
  let googleOptions = await (0, import_provider_utils6.parseProviderOptions)({
@@ -1539,6 +1548,11 @@ var GoogleGenerativeAILanguageModel = class {
1539
1548
  isVertexProvider
1540
1549
  });
1541
1550
  const streamFunctionCallArguments = isStreaming && isVertexProvider ? (_a = googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) != null ? _a : false : void 0;
1551
+ const safetyThreshold = googleOptions == null ? void 0 : googleOptions.threshold;
1552
+ const safetySettings = (_b = googleOptions == null ? void 0 : googleOptions.safetySettings) != null ? _b : safetyThreshold != null ? configurableSafetySettingCategories.map((category) => ({
1553
+ category,
1554
+ threshold: safetyThreshold
1555
+ })) : void 0;
1542
1556
  const toolConfig = googleToolConfig || streamFunctionCallArguments || (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
1543
1557
  ...googleToolConfig,
1544
1558
  ...streamFunctionCallArguments && {
@@ -1568,7 +1582,7 @@ var GoogleGenerativeAILanguageModel = class {
1568
1582
  responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
1569
1583
  // so this is needed as an escape hatch:
1570
1584
  // TODO convert into provider option
1571
- ((_b = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _b : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
1585
+ ((_c = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _c : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
1572
1586
  ...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
1573
1587
  audioTimestamp: googleOptions.audioTimestamp
1574
1588
  },
@@ -1584,7 +1598,7 @@ var GoogleGenerativeAILanguageModel = class {
1584
1598
  },
1585
1599
  contents,
1586
1600
  systemInstruction: isGemmaModel ? void 0 : systemInstruction,
1587
- safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
1601
+ safetySettings,
1588
1602
  tools: googleTools2,
1589
1603
  toolConfig,
1590
1604
  cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
@@ -2957,31 +2971,32 @@ function convertFileToGoogleImage(file, warnings) {
2957
2971
  }
2958
2972
  const base64Data = typeof file.data === "string" ? file.data : (0, import_provider_utils15.convertUint8ArrayToBase64)(file.data);
2959
2973
  return {
2960
- inlineData: {
2961
- mimeType: file.mediaType || "image/png",
2962
- data: base64Data
2963
- }
2974
+ bytesBase64Encoded: base64Data,
2975
+ mimeType: file.mediaType || "image/png"
2964
2976
  };
2965
2977
  }
2966
2978
  function convertProviderReferenceImage(refImg) {
2967
2979
  if (refImg.bytesBase64Encoded) {
2968
2980
  return {
2969
- inlineData: {
2970
- mimeType: "image/png",
2971
- data: refImg.bytesBase64Encoded
2981
+ image: {
2982
+ bytesBase64Encoded: refImg.bytesBase64Encoded,
2983
+ mimeType: "image/png"
2972
2984
  }
2973
2985
  };
2974
2986
  }
2975
2987
  if (refImg.gcsUri) {
2976
2988
  return {
2977
- gcsUri: refImg.gcsUri
2989
+ image: {
2990
+ gcsUri: refImg.gcsUri,
2991
+ mimeType: "image/png"
2992
+ }
2978
2993
  };
2979
2994
  }
2980
2995
  return refImg;
2981
2996
  }
2982
2997
  function convertInputReferenceImage(file, warnings) {
2983
2998
  const image = convertFileToGoogleImage(file, warnings);
2984
- return image != null ? { image, referenceType: "asset" } : void 0;
2999
+ return image != null ? { image } : void 0;
2985
3000
  }
2986
3001
  var GoogleGenerativeAIVideoModel = class {
2987
3002
  constructor(modelId, config) {
@@ -3263,6 +3278,19 @@ function convertGoogleInteractionsUsage(usage) {
3263
3278
  raw: usage
3264
3279
  };
3265
3280
  }
3281
+ function getGoogleInteractionsOutputTokensByModality(usage) {
3282
+ const byModality = usage == null ? void 0 : usage.output_tokens_by_modality;
3283
+ if (byModality == null) {
3284
+ return void 0;
3285
+ }
3286
+ const result = {};
3287
+ for (const entry of byModality) {
3288
+ if ((entry == null ? void 0 : entry.modality) != null && entry.tokens != null) {
3289
+ result[entry.modality] = entry.tokens;
3290
+ }
3291
+ }
3292
+ return Object.keys(result).length > 0 ? result : void 0;
3293
+ }
3266
3294
 
3267
3295
  // src/interactions/extract-google-interactions-sources.ts
3268
3296
  var KNOWN_DOC_EXTENSIONS = {
@@ -3514,7 +3542,7 @@ function buildGoogleInteractionsStreamTransform({
3514
3542
  controller.enqueue({ type: "stream-start", warnings });
3515
3543
  },
3516
3544
  transform(chunk, controller) {
3517
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
3545
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
3518
3546
  if (includeRawChunks) {
3519
3547
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
3520
3548
  }
@@ -3703,9 +3731,37 @@ function buildGoogleInteractionsStreamTransform({
3703
3731
  }
3704
3732
  break;
3705
3733
  }
3734
+ if (dtype === "video" && (open.kind === "pending_model_output" || open.kind === "text")) {
3735
+ const videoDelta = event.delta;
3736
+ const google2 = {};
3737
+ if (interactionId != null) google2.interactionId = interactionId;
3738
+ const providerMetadata = Object.keys(google2).length > 0 ? { google: google2 } : void 0;
3739
+ if ((videoDelta == null ? void 0 : videoDelta.data) != null && videoDelta.data.length > 0) {
3740
+ controller.enqueue({
3741
+ type: "file",
3742
+ mediaType: (_m = videoDelta.mime_type) != null ? _m : "video/mp4",
3743
+ data: videoDelta.data,
3744
+ ...providerMetadata ? { providerMetadata } : {}
3745
+ });
3746
+ } else if ((videoDelta == null ? void 0 : videoDelta.uri) != null && videoDelta.uri.length > 0) {
3747
+ const uriProviderMetadata = {
3748
+ google: {
3749
+ ...interactionId != null ? { interactionId } : {},
3750
+ videoUri: videoDelta.uri
3751
+ }
3752
+ };
3753
+ controller.enqueue({
3754
+ type: "file",
3755
+ mediaType: (_n = videoDelta.mime_type) != null ? _n : "video/mp4",
3756
+ data: "",
3757
+ providerMetadata: uriProviderMetadata
3758
+ });
3759
+ }
3760
+ break;
3761
+ }
3706
3762
  const delta = event.delta;
3707
3763
  if (open.kind === "text" && (delta == null ? void 0 : delta.type) === "text") {
3708
- const text = (_m = delta.text) != null ? _m : "";
3764
+ const text = (_o = delta.text) != null ? _o : "";
3709
3765
  if (text.length > 0) {
3710
3766
  controller.enqueue({
3711
3767
  type: "text-delta",
@@ -3808,7 +3864,7 @@ function buildGoogleInteractionsStreamTransform({
3808
3864
  if (open.data != null && open.data.length > 0) {
3809
3865
  controller.enqueue({
3810
3866
  type: "file",
3811
- mediaType: (_n = open.mimeType) != null ? _n : "image/png",
3867
+ mediaType: (_p = open.mimeType) != null ? _p : "image/png",
3812
3868
  data: open.data,
3813
3869
  ...providerMetadata ? { providerMetadata } : {}
3814
3870
  });
@@ -3821,7 +3877,7 @@ function buildGoogleInteractionsStreamTransform({
3821
3877
  };
3822
3878
  controller.enqueue({
3823
3879
  type: "file",
3824
- mediaType: (_o = open.mimeType) != null ? _o : "image/png",
3880
+ mediaType: (_q = open.mimeType) != null ? _q : "image/png",
3825
3881
  data: "",
3826
3882
  providerMetadata: uriProviderMetadata
3827
3883
  });
@@ -3848,7 +3904,7 @@ function buildGoogleInteractionsStreamTransform({
3848
3904
  type: "tool-call",
3849
3905
  toolCallId: open.toolCallId,
3850
3906
  toolName: open.toolName,
3851
- input: JSON.stringify((_p = open.arguments) != null ? _p : {}),
3907
+ input: JSON.stringify((_r = open.arguments) != null ? _r : {}),
3852
3908
  providerExecuted: true
3853
3909
  });
3854
3910
  open.callEmitted = true;
@@ -3857,7 +3913,7 @@ function buildGoogleInteractionsStreamTransform({
3857
3913
  type: "tool-result",
3858
3914
  toolCallId: open.callId,
3859
3915
  toolName: open.toolName,
3860
- result: (_q = open.result) != null ? _q : null
3916
+ result: (_s = open.result) != null ? _s : null
3861
3917
  });
3862
3918
  open.resultEmitted = true;
3863
3919
  const sources = builtinToolResultToSources({
@@ -3911,7 +3967,7 @@ function buildGoogleInteractionsStreamTransform({
3911
3967
  case "error": {
3912
3968
  const event = value;
3913
3969
  finishStatus = "failed";
3914
- const errorPayload = (_r = event.error) != null ? _r : {
3970
+ const errorPayload = (_t = event.error) != null ? _t : {
3915
3971
  message: "Unknown interaction error"
3916
3972
  };
3917
3973
  controller.enqueue({ type: "error", error: errorPayload });
@@ -3929,10 +3985,12 @@ function buildGoogleInteractionsStreamTransform({
3929
3985
  }),
3930
3986
  raw: finishStatus
3931
3987
  };
3988
+ const outputTokensByModality = getGoogleInteractionsOutputTokensByModality(usage);
3932
3989
  const providerMetadata = {
3933
3990
  google: {
3934
3991
  ...interactionId != null ? { interactionId } : {},
3935
- ...serviceTier != null ? { serviceTier } : {}
3992
+ ...serviceTier != null ? { serviceTier } : {},
3993
+ ...outputTokensByModality != null ? { outputTokensByModality } : {}
3936
3994
  }
3937
3995
  };
3938
3996
  controller.enqueue({
@@ -4421,9 +4479,16 @@ var contentBlockSchema = () => {
4421
4479
  resolution: import_v415.z.enum(["low", "medium", "high", "ultra_high"]).nullish(),
4422
4480
  uri: import_v415.z.string().nullish()
4423
4481
  }).loose();
4482
+ const videoContent = import_v415.z.object({
4483
+ type: import_v415.z.literal("video"),
4484
+ data: import_v415.z.string().nullish(),
4485
+ mime_type: import_v415.z.string().nullish(),
4486
+ uri: import_v415.z.string().nullish()
4487
+ }).loose();
4424
4488
  return import_v415.z.union([
4425
4489
  textContent,
4426
4490
  imageContent,
4491
+ videoContent,
4427
4492
  import_v415.z.object({ type: import_v415.z.string() }).loose()
4428
4493
  ]);
4429
4494
  };
@@ -4570,6 +4635,12 @@ var googleInteractionsEventSchema = (0, import_provider_utils17.lazySchema)(
4570
4635
  resolution: import_v415.z.enum(["low", "medium", "high", "ultra_high"]).nullish(),
4571
4636
  uri: import_v415.z.string().nullish()
4572
4637
  }).loose();
4638
+ const stepDeltaVideo = import_v415.z.object({
4639
+ type: import_v415.z.literal("video"),
4640
+ data: import_v415.z.string().nullish(),
4641
+ mime_type: import_v415.z.string().nullish(),
4642
+ uri: import_v415.z.string().nullish()
4643
+ }).loose();
4573
4644
  const stepDeltaBuiltinToolCall = import_v415.z.object({
4574
4645
  type: import_v415.z.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
4575
4646
  id: import_v415.z.string().nullish(),
@@ -4592,6 +4663,7 @@ var googleInteractionsEventSchema = (0, import_provider_utils17.lazySchema)(
4592
4663
  const stepDeltaUnion = import_v415.z.union([
4593
4664
  stepDeltaText,
4594
4665
  stepDeltaImage,
4666
+ stepDeltaVideo,
4595
4667
  stepDeltaThoughtSummary,
4596
4668
  stepDeltaThoughtSignature,
4597
4669
  stepDeltaArgumentsDelta,
@@ -4880,7 +4952,7 @@ function parseGoogleInteractionsOutputs({
4880
4952
  generateId: generateId3,
4881
4953
  interactionId
4882
4954
  }) {
4883
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
4955
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
4884
4956
  const content = [];
4885
4957
  let hasFunctionCall = false;
4886
4958
  if (steps == null) {
@@ -4933,6 +5005,28 @@ function parseGoogleInteractionsOutputs({
4933
5005
  }
4934
5006
  });
4935
5007
  }
5008
+ } else if (blockType === "video") {
5009
+ const video = block;
5010
+ if (video.data != null && video.data.length > 0) {
5011
+ content.push({
5012
+ type: "file",
5013
+ mediaType: (_e = video.mime_type) != null ? _e : "video/mp4",
5014
+ data: video.data,
5015
+ ...googleProviderMetadata({ interactionId })
5016
+ });
5017
+ } else if (video.uri != null && video.uri.length > 0) {
5018
+ content.push({
5019
+ type: "file",
5020
+ mediaType: (_f = video.mime_type) != null ? _f : "video/mp4",
5021
+ data: "",
5022
+ providerMetadata: {
5023
+ google: {
5024
+ ...interactionId != null ? { interactionId } : {},
5025
+ videoUri: video.uri
5026
+ }
5027
+ }
5028
+ });
5029
+ }
4936
5030
  }
4937
5031
  }
4938
5032
  break;
@@ -4960,7 +5054,7 @@ function parseGoogleInteractionsOutputs({
4960
5054
  type: "tool-call",
4961
5055
  toolCallId: call.id,
4962
5056
  toolName: call.name,
4963
- input: JSON.stringify((_e = call.arguments) != null ? _e : {}),
5057
+ input: JSON.stringify((_g = call.arguments) != null ? _g : {}),
4964
5058
  ...googleProviderMetadata({
4965
5059
  signature: call.signature,
4966
5060
  interactionId
@@ -4971,23 +5065,23 @@ function parseGoogleInteractionsOutputs({
4971
5065
  default: {
4972
5066
  if (BUILTIN_TOOL_CALL_TYPES2.has(type)) {
4973
5067
  const call = step;
4974
- const toolName = type === "mcp_server_tool_call" ? (_f = call.name) != null ? _f : "mcp_server_tool" : builtinToolNameFromCallType2(type);
4975
- const input = JSON.stringify((_g = call.arguments) != null ? _g : {});
5068
+ const toolName = type === "mcp_server_tool_call" ? (_h = call.name) != null ? _h : "mcp_server_tool" : builtinToolNameFromCallType2(type);
5069
+ const input = JSON.stringify((_i = call.arguments) != null ? _i : {});
4976
5070
  content.push({
4977
5071
  type: "tool-call",
4978
- toolCallId: (_h = call.id) != null ? _h : generateId3(),
5072
+ toolCallId: (_j = call.id) != null ? _j : generateId3(),
4979
5073
  toolName,
4980
5074
  input,
4981
5075
  providerExecuted: true
4982
5076
  });
4983
5077
  } else if (BUILTIN_TOOL_RESULT_TYPES2.has(type)) {
4984
5078
  const result = step;
4985
- const toolName = type === "mcp_server_tool_result" ? (_i = result.name) != null ? _i : "mcp_server_tool" : builtinToolNameFromResultType2(type);
5079
+ const toolName = type === "mcp_server_tool_result" ? (_k = result.name) != null ? _k : "mcp_server_tool" : builtinToolNameFromResultType2(type);
4986
5080
  content.push({
4987
5081
  type: "tool-result",
4988
- toolCallId: (_j = result.call_id) != null ? _j : generateId3(),
5082
+ toolCallId: (_l = result.call_id) != null ? _l : generateId3(),
4989
5083
  toolName,
4990
- result: (_k = result.result) != null ? _k : null
5084
+ result: (_m = result.result) != null ? _m : null
4991
5085
  });
4992
5086
  const sources = builtinToolResultToSources({
4993
5087
  block: step,
@@ -5871,10 +5965,14 @@ var GoogleInteractionsLanguageModel = class {
5871
5965
  raw: response.status
5872
5966
  };
5873
5967
  const serviceTier = (_e = (_d = response.service_tier) != null ? _d : responseHeaders == null ? void 0 : responseHeaders["x-gemini-service-tier"]) != null ? _e : void 0;
5968
+ const outputTokensByModality = getGoogleInteractionsOutputTokensByModality(
5969
+ response.usage
5970
+ );
5874
5971
  const providerMetadata = {
5875
5972
  google: {
5876
5973
  ...interactionId != null ? { interactionId } : {},
5877
- ...serviceTier != null ? { serviceTier } : {}
5974
+ ...serviceTier != null ? { serviceTier } : {},
5975
+ ...outputTokensByModality != null ? { outputTokensByModality } : {}
5878
5976
  }
5879
5977
  };
5880
5978
  let timestamp;
@@ -6038,6 +6136,34 @@ function pruneUndefined(obj) {
6038
6136
  }
6039
6137
 
6040
6138
  // src/google-provider.ts
6139
+ var supportedExternalUrlMediaTypes = [
6140
+ "text/html",
6141
+ "text/css",
6142
+ "text/plain",
6143
+ "text/xml",
6144
+ "text/csv",
6145
+ "text/rtf",
6146
+ "text/javascript",
6147
+ "application/json",
6148
+ "application/pdf",
6149
+ "image/bmp",
6150
+ "image/jpeg",
6151
+ "image/png",
6152
+ "image/webp",
6153
+ "video/mp4",
6154
+ "video/mpeg",
6155
+ "video/quicktime",
6156
+ "video/avi",
6157
+ "video/x-flv",
6158
+ "video/mpg",
6159
+ "video/webm",
6160
+ "video/wmv",
6161
+ "video/3gpp"
6162
+ ];
6163
+ var externalHttpsUrlPattern = /^https:\/\/.*$/;
6164
+ function supportsExternalFileUrls(modelId) {
6165
+ return /(^|\/)gemini-/.test(modelId) && !/(^|\/)gemini-2\.0/.test(modelId);
6166
+ }
6041
6167
  function createGoogleGenerativeAI(options = {}) {
6042
6168
  var _a, _b;
6043
6169
  const baseURL = (_a = (0, import_provider_utils23.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
@@ -6070,7 +6196,13 @@ function createGoogleGenerativeAI(options = {}) {
6070
6196
  `^https://(?:www\\.)?youtube\\.com/watch\\?v=[\\w-]+(?:&[\\w=&.-]*)?$`
6071
6197
  ),
6072
6198
  new RegExp(`^https://youtu\\.be/[\\w-]+(?:\\?[\\w=&.-]*)?$`)
6073
- ]
6199
+ ],
6200
+ ...supportsExternalFileUrls(modelId) ? Object.fromEntries(
6201
+ supportedExternalUrlMediaTypes.map((mediaType) => [
6202
+ mediaType,
6203
+ [externalHttpsUrlPattern]
6204
+ ])
6205
+ ) : {}
6074
6206
  }),
6075
6207
  fetch: options.fetch
6076
6208
  });