@ai-sdk/google 4.0.22 → 4.0.23

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,11 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 4.0.23
4
+
5
+ ### Patch Changes
6
+
7
+ - f126649: feat(provider/google): default unknown Gemini model IDs to the newest supported capabilities
8
+
3
9
  ## 4.0.22
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  } from "@ai-sdk/provider-utils";
8
8
 
9
9
  // src/version.ts
10
- var VERSION = true ? "4.0.22" : "0.0.0-test";
10
+ var VERSION = true ? "4.0.23" : "0.0.0-test";
11
11
 
12
12
  // src/google-embedding-model.ts
13
13
  import {
@@ -556,7 +556,7 @@ function convertToGoogleMessages(prompt, options) {
556
556
  const contents = [];
557
557
  let systemMessagesAllowed = true;
558
558
  const isGemmaModel = (_a = options == null ? void 0 : options.isGemmaModel) != null ? _a : false;
559
- const isGemini3Model2 = (_b = options == null ? void 0 : options.isGemini3Model) != null ? _b : false;
559
+ const isGemini3Model = (_b = options == null ? void 0 : options.isGemini3Model) != null ? _b : false;
560
560
  const onWarning = options == null ? void 0 : options.onWarning;
561
561
  const providerOptionsNames = (_c = options == null ? void 0 : options.providerOptionsNames) != null ? _c : ["google"];
562
562
  const isVertexLike = !providerOptionsNames.includes("google");
@@ -758,7 +758,7 @@ function convertToGoogleMessages(prompt, options) {
758
758
  // model response legitimately have no signature.
759
759
  !isServerToolCall && thoughtSignature == null && modelResponseHasSignedFunctionCall
760
760
  );
761
- const effectiveThoughtSignature = thoughtSignature != null ? thoughtSignature : isGemini3Model2 && !shouldSkipMissingSignatureMitigation ? injectSkipSignature(part.toolName) : void 0;
761
+ const effectiveThoughtSignature = thoughtSignature != null ? thoughtSignature : isGemini3Model && !shouldSkipMissingSignatureMitigation ? injectSkipSignature(part.toolName) : void 0;
762
762
  if (!isServerToolCall && thoughtSignature != null) {
763
763
  modelResponseHasSignedFunctionCall = true;
764
764
  }
@@ -1079,6 +1079,27 @@ var googleLanguageModelOptions = lazySchema4(
1079
1079
  )
1080
1080
  );
1081
1081
 
1082
+ // src/google-model-capabilities.ts
1083
+ var gemini1ModelPattern = /(^|\/)gemini-1(?:[.-]|$)/i;
1084
+ var gemini2ModelPattern = /(^|\/)gemini-2(?:[.-]|$)/i;
1085
+ var gemini25ModelPattern = /(^|\/)gemini-2\.5(?:[.-]|$)/i;
1086
+ var geminiModelPattern = /(^|\/)gemini-/i;
1087
+ function isKnownPreGemini2Model(modelId) {
1088
+ return gemini1ModelPattern.test(modelId) || /(^|\/)gemini-pro(?:-vision)?$/i.test(modelId) || /(^|\/)gemini-robotics-er-1\.5(?:[.-]|$)/i.test(modelId);
1089
+ }
1090
+ function getGoogleModelCapabilities(modelId) {
1091
+ const isGeminiModel2 = geminiModelPattern.test(modelId);
1092
+ const isGemini2Model = gemini2ModelPattern.test(modelId);
1093
+ const isKnownPreGemini2 = isKnownPreGemini2Model(modelId);
1094
+ const isKnownOlderModel = isKnownPreGemini2 || isGemini2Model;
1095
+ const usesGemini3Features = isGeminiModel2 && !isKnownOlderModel;
1096
+ return {
1097
+ supportsGemini2Tools: isGeminiModel2 && !isKnownPreGemini2 || modelId.toLowerCase().includes("nano-banana"),
1098
+ supportsFileSearch: gemini25ModelPattern.test(modelId) || usesGemini3Features,
1099
+ usesGemini3Features
1100
+ };
1101
+ }
1102
+
1082
1103
  // src/google-prepare-tools.ts
1083
1104
  import {
1084
1105
  UnsupportedFunctionalityError as UnsupportedFunctionalityError2
@@ -1092,20 +1113,13 @@ function prepareTools({
1092
1113
  var _a, _b;
1093
1114
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
1094
1115
  const toolWarnings = [];
1095
- const isLatest = [
1096
- "gemini-flash-latest",
1097
- "gemini-flash-lite-latest",
1098
- "gemini-pro-latest"
1099
- ].some((id) => id === modelId);
1100
- const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || modelId.includes("nano-banana") || isLatest;
1101
- const isGemini3orNewer = modelId.includes("gemini-3");
1102
- const supportsFileSearch = modelId.includes("gemini-2.5") || modelId.includes("gemini-3");
1116
+ const { supportsGemini2Tools, supportsFileSearch, usesGemini3Features } = getGoogleModelCapabilities(modelId);
1103
1117
  if (tools == null) {
1104
1118
  return { tools: void 0, toolConfig: void 0, toolWarnings };
1105
1119
  }
1106
1120
  const hasFunctionTools = tools.some((tool) => tool.type === "function");
1107
1121
  const hasProviderTools = tools.some((tool) => tool.type === "provider");
1108
- if (hasFunctionTools && hasProviderTools && !isGemini3orNewer) {
1122
+ if (hasFunctionTools && hasProviderTools && !usesGemini3Features) {
1109
1123
  toolWarnings.push({
1110
1124
  type: "unsupported",
1111
1125
  feature: `combination of function and provider-defined tools`
@@ -1117,7 +1131,7 @@ function prepareTools({
1117
1131
  ProviderTools.forEach((tool) => {
1118
1132
  switch (tool.id) {
1119
1133
  case "google.google_search":
1120
- if (isGemini2orNewer) {
1134
+ if (supportsGemini2Tools) {
1121
1135
  googleTools2.push({ googleSearch: { ...tool.args } });
1122
1136
  } else {
1123
1137
  toolWarnings.push({
@@ -1128,7 +1142,7 @@ function prepareTools({
1128
1142
  }
1129
1143
  break;
1130
1144
  case "google.enterprise_web_search":
1131
- if (isGemini2orNewer) {
1145
+ if (supportsGemini2Tools) {
1132
1146
  googleTools2.push({ enterpriseWebSearch: {} });
1133
1147
  } else {
1134
1148
  toolWarnings.push({
@@ -1139,7 +1153,7 @@ function prepareTools({
1139
1153
  }
1140
1154
  break;
1141
1155
  case "google.url_context":
1142
- if (isGemini2orNewer) {
1156
+ if (supportsGemini2Tools) {
1143
1157
  googleTools2.push({ urlContext: {} });
1144
1158
  } else {
1145
1159
  toolWarnings.push({
@@ -1150,7 +1164,7 @@ function prepareTools({
1150
1164
  }
1151
1165
  break;
1152
1166
  case "google.code_execution":
1153
- if (isGemini2orNewer) {
1167
+ if (supportsGemini2Tools) {
1154
1168
  googleTools2.push({ codeExecution: {} });
1155
1169
  } else {
1156
1170
  toolWarnings.push({
@@ -1172,7 +1186,7 @@ function prepareTools({
1172
1186
  }
1173
1187
  break;
1174
1188
  case "google.vertex_rag_store":
1175
- if (isGemini2orNewer) {
1189
+ if (supportsGemini2Tools) {
1176
1190
  googleTools2.push({
1177
1191
  retrieval: {
1178
1192
  vertex_rag_store: {
@@ -1192,7 +1206,7 @@ function prepareTools({
1192
1206
  }
1193
1207
  break;
1194
1208
  case "google.google_maps":
1195
- if (isGemini2orNewer) {
1209
+ if (supportsGemini2Tools) {
1196
1210
  googleTools2.push({ googleMaps: {} });
1197
1211
  } else {
1198
1212
  toolWarnings.push({
@@ -1210,7 +1224,7 @@ function prepareTools({
1210
1224
  break;
1211
1225
  }
1212
1226
  });
1213
- if (hasFunctionTools && isGemini3orNewer && googleTools2.length > 0) {
1227
+ if (hasFunctionTools && usesGemini3Features && googleTools2.length > 0) {
1214
1228
  const functionDeclarations2 = [];
1215
1229
  for (const tool of tools) {
1216
1230
  if (tool.type === "function") {
@@ -1725,14 +1739,13 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1725
1739
  }
1726
1740
  }
1727
1741
  const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
1728
- const isGemini3Model2 = /^gemini-3[.-]/.test(this.modelId);
1729
- const supportsFunctionResponseParts = isGemini3Model2;
1742
+ const { usesGemini3Features } = getGoogleModelCapabilities(this.modelId);
1730
1743
  const { contents, systemInstruction } = convertToGoogleMessages(prompt, {
1731
1744
  isGemmaModel,
1732
- isGemini3Model: isGemini3Model2,
1745
+ isGemini3Model: usesGemini3Features,
1733
1746
  onWarning: (warning) => warnings.push(warning),
1734
1747
  providerOptionsNames,
1735
- supportsFunctionResponseParts
1748
+ supportsFunctionResponseParts: usesGemini3Features
1736
1749
  });
1737
1750
  const {
1738
1751
  tools: googleTools2,
@@ -2398,9 +2411,6 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2398
2411
  };
2399
2412
  }
2400
2413
  };
2401
- function isGemini3Model(modelId) {
2402
- return /gemini-3[\.\-]/i.test(modelId) || /gemini-3$/i.test(modelId);
2403
- }
2404
2414
  function getMaxOutputTokensForGemini25Model() {
2405
2415
  return 65536;
2406
2416
  }
@@ -2419,7 +2429,7 @@ function resolveThinkingConfig({
2419
2429
  if (!isCustomReasoning(reasoning)) {
2420
2430
  return void 0;
2421
2431
  }
2422
- if (isGemini3Model(modelId) && !modelId.includes("gemini-3-pro-image")) {
2432
+ if (getGoogleModelCapabilities(modelId).usesGemini3Features && !modelId.includes("gemini-3-pro-image")) {
2423
2433
  return resolveGemini3ThinkingConfig({ reasoning, warnings });
2424
2434
  }
2425
2435
  return resolveGemini25ThinkingConfig({ reasoning, modelId, warnings });