@depup/ai-sdk__google 4.0.64-depup.0 → 4.0.65-depup.0

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,18 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 4.0.65
4
+
5
+ ### Patch Changes
6
+
7
+ - a4ba394: feat: support per-request models in batch
8
+ - 45099da: Retry unclassified empty image results, preserve retry-attempt accounting, add provider-independent result retryability classification, and mark Google and Google Vertex prompt blocks as terminal.
9
+ - Updated dependencies [a4ba394]
10
+ - Updated dependencies [45099da]
11
+ - Updated dependencies [9e1d1b2]
12
+ - Updated dependencies [a495511]
13
+ - @ai-sdk/provider@4.0.11
14
+ - @ai-sdk/provider-utils@5.0.37
15
+
3
16
  ## 4.0.64
4
17
 
5
18
  ### Patch Changes
package/README.md CHANGED
@@ -13,8 +13,8 @@ npm install @depup/ai-sdk__google
13
13
 
14
14
  | Field | Value |
15
15
  |-------|-------|
16
- | Original | [@ai-sdk/google](https://www.npmjs.com/package/@ai-sdk/google) @ 4.0.64 |
17
- | Processed | 2026-09-05 |
16
+ | Original | [@ai-sdk/google](https://www.npmjs.com/package/@ai-sdk/google) @ 4.0.65 |
17
+ | Processed | 2026-09-09 |
18
18
  | Smoke test | failed |
19
19
  | Deps updated | 0 |
20
20
 
package/changes.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "bumped": {},
3
- "timestamp": "2026-09-05T00:30:34.968Z",
3
+ "timestamp": "2026-09-09T00:32:20.646Z",
4
4
  "totalUpdated": 0
5
5
  }
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
2
2
  import { InferSchema, FetchFunction, WebSocketConstructor, WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE, Resolvable } from '@ai-sdk/provider-utils';
3
3
  import { z } from 'zod/v4';
4
4
  import * as _ai_sdk_provider from '@ai-sdk/provider';
5
- import { ProviderV4, Experimental_BatchLanguageModelV4, ImageModelV4, EmbeddingModelV4, Experimental_VideoModelV4, Experimental_SpeechTranslationModelV4, SpeechModelV4, TranscriptionModelV4, FilesV4, LanguageModelV4, Experimental_RealtimeFactoryV4, Experimental_RealtimeModelV4, Experimental_RealtimeModelV4ClientSecretOptions, Experimental_RealtimeModelV4ClientSecretResult, Experimental_RealtimeModelV4ServerEvent, Experimental_RealtimeModelV4ClientEvent, Experimental_RealtimeModelV4SessionConfig, JSONObject, Experimental_TranscriptionModelV4StreamOptions, Experimental_SpeechTranslationModelV4StreamOptions } from '@ai-sdk/provider';
5
+ import { ProviderV4, LanguageModelV4, Experimental_BatchV4, ImageModelV4, EmbeddingModelV4, Experimental_VideoModelV4, Experimental_SpeechTranslationModelV4, SpeechModelV4, TranscriptionModelV4, FilesV4, Experimental_RealtimeFactoryV4, Experimental_RealtimeModelV4, Experimental_RealtimeModelV4ClientSecretOptions, Experimental_RealtimeModelV4ClientSecretResult, Experimental_RealtimeModelV4ServerEvent, Experimental_RealtimeModelV4ClientEvent, Experimental_RealtimeModelV4SessionConfig, JSONObject, Experimental_TranscriptionModelV4StreamOptions, Experimental_SpeechTranslationModelV4StreamOptions } from '@ai-sdk/provider';
6
6
 
7
7
  declare const googleErrorDataSchema: _ai_sdk_provider_utils.LazySchema<{
8
8
  error: {
@@ -589,9 +589,12 @@ declare const googleSpeechTranslationModelOptions: _ai_sdk_provider_utils.LazySc
589
589
  type GoogleSpeechTranslationModelOptions = InferSchema<typeof googleSpeechTranslationModelOptions>;
590
590
 
591
591
  interface GoogleProvider extends ProviderV4 {
592
- (modelId: GoogleModelId): Experimental_BatchLanguageModelV4;
593
- languageModel(modelId: GoogleModelId): Experimental_BatchLanguageModelV4;
594
- chat(modelId: GoogleModelId): Experimental_BatchLanguageModelV4;
592
+ (modelId: GoogleModelId): LanguageModelV4;
593
+ languageModel(modelId: GoogleModelId): LanguageModelV4;
594
+ chat(modelId: GoogleModelId): LanguageModelV4;
595
+ experimental_batch(): Experimental_BatchV4<{
596
+ text: GoogleModelId;
597
+ }>;
595
598
  /**
596
599
  * Creates a model for image generation.
597
600
  */
@@ -599,7 +602,7 @@ interface GoogleProvider extends ProviderV4 {
599
602
  /**
600
603
  * @deprecated Use `chat()` instead.
601
604
  */
602
- generativeAI(modelId: GoogleModelId): Experimental_BatchLanguageModelV4;
605
+ generativeAI(modelId: GoogleModelId): LanguageModelV4;
603
606
  /**
604
607
  * Creates a model for text embeddings.
605
608
  */
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.64" : "0.0.0-test";
10
+ var VERSION = true ? "4.0.65" : "0.0.0-test";
11
11
 
12
12
  // src/google-embedding-model.ts
13
13
  import {
@@ -269,8 +269,6 @@ import {
269
269
  postToApi,
270
270
  resolve as resolve3,
271
271
  safeValidateTypes,
272
- WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE3,
273
- WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE3,
274
272
  zodSchema as zodSchema6
275
273
  } from "@ai-sdk/provider-utils";
276
274
  import { z as z6 } from "zod/v4";
@@ -1840,25 +1838,32 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1840
1838
  var _a, _b, _c;
1841
1839
  return (_c = (_b = (_a = this.config).supportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
1842
1840
  }
1843
- async getArgs({
1844
- prompt,
1845
- maxOutputTokens,
1846
- temperature,
1847
- topP,
1848
- topK,
1849
- frequencyPenalty,
1850
- presencePenalty,
1851
- stopSequences,
1852
- responseFormat,
1853
- seed,
1854
- tools,
1855
- toolChoice,
1856
- reasoning,
1857
- providerOptions
1858
- }, { isStreaming = false } = {}) {
1841
+ static async prepareRequest({
1842
+ modelId,
1843
+ config,
1844
+ options: {
1845
+ prompt,
1846
+ maxOutputTokens,
1847
+ temperature,
1848
+ topP,
1849
+ topK,
1850
+ frequencyPenalty,
1851
+ presencePenalty,
1852
+ stopSequences,
1853
+ responseFormat,
1854
+ seed,
1855
+ tools,
1856
+ toolChoice,
1857
+ reasoning,
1858
+ providerOptions
1859
+ },
1860
+ isStreaming = false
1861
+ }) {
1859
1862
  var _a, _b, _c;
1860
1863
  const warnings = [];
1861
- const providerOptionsNames = this.config.provider.includes("vertex") ? ["googleVertex", "vertex"] : ["google"];
1864
+ const providerOptionsNames = config.provider.includes(
1865
+ "vertex"
1866
+ ) ? ["googleVertex", "vertex"] : ["google"];
1862
1867
  let googleOptions;
1863
1868
  for (const name of providerOptionsNames) {
1864
1869
  googleOptions = await parseProviderOptions2({
@@ -1875,19 +1880,19 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1875
1880
  schema: googleLanguageModelOptions
1876
1881
  });
1877
1882
  }
1878
- const isVertexProvider = this.config.provider.startsWith("google.vertex.");
1883
+ const isVertexProvider = config.provider.startsWith("google.vertex.");
1879
1884
  if ((tools == null ? void 0 : tools.some(
1880
1885
  (tool) => tool.type === "provider" && tool.id === "google.vertex_rag_store"
1881
1886
  )) && !isVertexProvider) {
1882
1887
  warnings.push({
1883
1888
  type: "other",
1884
- message: `The 'vertex_rag_store' tool is only supported with the Google Vertex provider and might not be supported or could behave unexpectedly with the current Google provider (${this.config.provider}).`
1889
+ message: `The 'vertex_rag_store' tool is only supported with the Google Vertex provider and might not be supported or could behave unexpectedly with the current Google provider (${config.provider}).`
1885
1890
  });
1886
1891
  }
1887
1892
  if ((googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) && !isVertexProvider) {
1888
1893
  warnings.push({
1889
1894
  type: "other",
1890
- message: `'streamFunctionCallArguments' is only supported on the Vertex AI API and will be ignored with the current Google provider (${this.config.provider}). See https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc`
1895
+ message: `'streamFunctionCallArguments' is only supported on the Vertex AI API and will be ignored with the current Google provider (${config.provider}). See https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc`
1891
1896
  });
1892
1897
  }
1893
1898
  if ((googleOptions == null ? void 0 : googleOptions.serviceTier) && isVertexProvider) {
@@ -1899,7 +1904,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1899
1904
  if (((googleOptions == null ? void 0 : googleOptions.sharedRequestType) || (googleOptions == null ? void 0 : googleOptions.requestType)) && !isVertexProvider) {
1900
1905
  warnings.push({
1901
1906
  type: "other",
1902
- message: `'sharedRequestType' and 'requestType' are Vertex AI options and are ignored with the current Google provider (${this.config.provider}).`
1907
+ message: `'sharedRequestType' and 'requestType' are Vertex AI options and are ignored with the current Google provider (${config.provider}).`
1903
1908
  });
1904
1909
  }
1905
1910
  const vertexPaygoHeaders = isVertexProvider && ((googleOptions == null ? void 0 : googleOptions.sharedRequestType) || (googleOptions == null ? void 0 : googleOptions.requestType)) ? {
@@ -1927,13 +1932,13 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1927
1932
  if (droppedImageConfigFields.length > 0) {
1928
1933
  warnings.push({
1929
1934
  type: "other",
1930
- message: `${droppedImageConfigFields.join(", ")} ${droppedImageConfigFields.length === 1 ? "is a Vertex AI option and is" : "are Vertex AI options and are"} ignored with the current Google provider (${this.config.provider}).`
1935
+ message: `${droppedImageConfigFields.join(", ")} ${droppedImageConfigFields.length === 1 ? "is a Vertex AI option and is" : "are Vertex AI options and are"} ignored with the current Google provider (${config.provider}).`
1931
1936
  });
1932
1937
  imageConfig = geminiApiImageConfig;
1933
1938
  }
1934
1939
  }
1935
- const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
1936
- const isGemini25DeveloperApiModel = !isVertexProvider && gemini25ModelPattern2.test(this.modelId);
1940
+ const isGemmaModel = modelId.toLowerCase().startsWith("gemma-");
1941
+ const isGemini25DeveloperApiModel = !isVertexProvider && gemini25ModelPattern2.test(modelId);
1937
1942
  if (isGemini25DeveloperApiModel && frequencyPenalty != null) {
1938
1943
  warnings.push({
1939
1944
  type: "unsupported",
@@ -1946,7 +1951,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1946
1951
  feature: "presencePenalty"
1947
1952
  });
1948
1953
  }
1949
- const { usesGemini3Features } = getGoogleModelCapabilities(this.modelId);
1954
+ const { usesGemini3Features } = getGoogleModelCapabilities(modelId);
1950
1955
  const { contents, systemInstruction } = convertToGoogleMessages(prompt, {
1951
1956
  isGemmaModel,
1952
1957
  isGemini3Model: usesGemini3Features,
@@ -1962,7 +1967,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1962
1967
  } = prepareTools({
1963
1968
  tools,
1964
1969
  toolChoice,
1965
- modelId: this.modelId,
1970
+ modelId,
1966
1971
  isVertexProvider
1967
1972
  });
1968
1973
  const toolNameMapping = createToolNameMapping({
@@ -1973,7 +1978,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1973
1978
  });
1974
1979
  const resolvedThinking = resolveThinkingConfig({
1975
1980
  reasoning,
1976
- modelId: this.modelId,
1981
+ modelId,
1977
1982
  warnings
1978
1983
  });
1979
1984
  const thinkingConfig = (googleOptions == null ? void 0 : googleOptions.thinkingConfig) || resolvedThinking ? { ...resolvedThinking, ...googleOptions == null ? void 0 : googleOptions.thinkingConfig } : void 0;
@@ -2039,7 +2044,16 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2039
2044
  toolNameMapping
2040
2045
  };
2041
2046
  }
2042
- convertGenerateContentResponse({
2047
+ getArgs(options, { isStreaming = false } = {}) {
2048
+ return _GoogleLanguageModel.prepareRequest({
2049
+ modelId: this.modelId,
2050
+ config: this.config,
2051
+ options,
2052
+ isStreaming
2053
+ });
2054
+ }
2055
+ static convertGenerateContentResponse({
2056
+ config,
2043
2057
  response,
2044
2058
  warnings,
2045
2059
  providerOptionsNames,
@@ -2060,7 +2074,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2060
2074
  let lastServerToolCallId;
2061
2075
  for (const part of parts) {
2062
2076
  if ("executableCode" in part && ((_g = part.executableCode) == null ? void 0 : _g.code)) {
2063
- const toolCallId = this.config.generateId();
2077
+ const toolCallId = config.generateId();
2064
2078
  lastCodeExecutionToolCallId = toolCallId;
2065
2079
  content.push({
2066
2080
  type: "tool-call",
@@ -2099,7 +2113,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2099
2113
  } else if ("functionCall" in part && part.functionCall.name != null) {
2100
2114
  content.push({
2101
2115
  type: "tool-call",
2102
- toolCallId: part.functionCall.id || this.config.generateId(),
2116
+ toolCallId: part.functionCall.id || config.generateId(),
2103
2117
  toolName: part.functionCall.name,
2104
2118
  input: JSON.stringify((_k = part.functionCall.args) != null ? _k : {}),
2105
2119
  providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
@@ -2118,7 +2132,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2118
2132
  }) : void 0
2119
2133
  });
2120
2134
  } else if ("toolCall" in part && part.toolCall) {
2121
- const toolCallId = part.toolCall.id || this.config.generateId();
2135
+ const toolCallId = part.toolCall.id || config.generateId();
2122
2136
  lastServerToolCallId = toolCallId;
2123
2137
  content.push({
2124
2138
  type: "tool-call",
@@ -2137,7 +2151,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2137
2151
  })
2138
2152
  });
2139
2153
  } else if ("toolResponse" in part && part.toolResponse) {
2140
- const responseToolCallId = lastServerToolCallId || part.toolResponse.id || this.config.generateId();
2154
+ const responseToolCallId = lastServerToolCallId || part.toolResponse.id || config.generateId();
2141
2155
  content.push({
2142
2156
  type: "tool-result",
2143
2157
  toolCallId: responseToolCallId,
@@ -2157,7 +2171,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2157
2171
  }
2158
2172
  const sources = (_n = extractSources({
2159
2173
  groundingMetadata: candidate == null ? void 0 : candidate.groundingMetadata,
2160
- generateId: this.config.generateId
2174
+ generateId: config.generateId
2161
2175
  })) != null ? _n : [];
2162
2176
  for (const source of sources) {
2163
2177
  content.push(source);
@@ -2219,7 +2233,8 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2219
2233
  abortSignal: options.abortSignal,
2220
2234
  fetch: this.config.fetch
2221
2235
  });
2222
- const result = this.convertGenerateContentResponse({
2236
+ const result = _GoogleLanguageModel.convertGenerateContentResponse({
2237
+ config: this.config,
2223
2238
  response,
2224
2239
  warnings,
2225
2240
  providerOptionsNames,
@@ -3125,20 +3140,17 @@ var googleBatchResponsePreviewSchema = lazySchema6(
3125
3140
  })
3126
3141
  )
3127
3142
  );
3128
- var GoogleBatchLanguageModel = class _GoogleBatchLanguageModel extends GoogleLanguageModel {
3129
- static [WORKFLOW_SERIALIZE3](model) {
3130
- return GoogleLanguageModel[WORKFLOW_SERIALIZE3](model);
3131
- }
3132
- static [WORKFLOW_DESERIALIZE3](options) {
3133
- return new _GoogleBatchLanguageModel(options.modelId, options.config);
3134
- }
3135
- constructor(modelId, config) {
3143
+ var GoogleBatch = class {
3144
+ constructor(options) {
3145
+ this.specificationVersion = "v4";
3136
3146
  var _a;
3137
- super(modelId, config);
3138
- this.batchConfig = config;
3139
- this.batchGenerateId = (_a = config.generateId) != null ? _a : generateId2;
3147
+ this.provider = options.provider;
3148
+ this.batchConfig = options.config;
3149
+ this.supportedUrls = options.supportedUrls;
3150
+ this.batchGenerateId = (_a = options.config.generateId) != null ? _a : generateId2;
3140
3151
  }
3141
- async experimental_doStartBatch(options) {
3152
+ async doStartBatch(options) {
3153
+ const modelId = getGoogleBatchModelId(options.requests);
3142
3154
  const warnings = [];
3143
3155
  const displayName = `ai-sdk-batch-${this.batchGenerateId()}`;
3144
3156
  const inlinedRequests = [];
@@ -3159,7 +3171,11 @@ var GoogleBatchLanguageModel = class _GoogleBatchLanguageModel extends GoogleLan
3159
3171
  ).byteLength;
3160
3172
  let fileParts;
3161
3173
  for (const request of options.requests) {
3162
- const preparedRequest = await this.getArgs(request.options);
3174
+ const preparedRequest = await GoogleLanguageModel.prepareRequest({
3175
+ modelId: request.modelId,
3176
+ config: this.batchConfig,
3177
+ options: request.options
3178
+ });
3163
3179
  const inlinedRequest = {
3164
3180
  request: preparedRequest.args,
3165
3181
  metadata: { key: request.id }
@@ -3207,7 +3223,7 @@ var GoogleBatchLanguageModel = class _GoogleBatchLanguageModel extends GoogleLan
3207
3223
  }
3208
3224
  const headers = await this.getHeaders(options.headers);
3209
3225
  const createUrl = `${this.batchConfig.baseURL}/${getModelPath(
3210
- this.modelId
3226
+ modelId
3211
3227
  )}:batchGenerateContent`;
3212
3228
  if (fileParts == null) {
3213
3229
  const { value: operation2 } = await postJsonToApi3({
@@ -3307,10 +3323,10 @@ var GoogleBatchLanguageModel = class _GoogleBatchLanguageModel extends GoogleLan
3307
3323
  warnings
3308
3324
  };
3309
3325
  }
3310
- async experimental_doGetBatchStatus(options) {
3326
+ async doGetBatchStatus(options) {
3311
3327
  return convertGoogleBatchStatus(await this.retrieveBatch(options));
3312
3328
  }
3313
- async experimental_doGetBatchResults(options) {
3329
+ async doGetBatchResults(options) {
3314
3330
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
3315
3331
  const operation = await this.retrieveBatch(options);
3316
3332
  const batchStatus = convertGoogleBatchStatus(operation);
@@ -3385,11 +3401,12 @@ var GoogleBatchLanguageModel = class _GoogleBatchLanguageModel extends GoogleLan
3385
3401
  "Google batch request failed."
3386
3402
  );
3387
3403
  const status = line.error.status === "CANCELLED" || String(line.error.code) === "1" ? "cancelled" : "failed";
3388
- yield { id: line.key, status, error };
3404
+ yield { type: "text", id: line.key, status, error };
3389
3405
  continue;
3390
3406
  }
3391
3407
  if (line.response == null) {
3392
3408
  yield {
3409
+ type: "text",
3393
3410
  id: line.key,
3394
3411
  status: "failed",
3395
3412
  error: {
@@ -3407,6 +3424,7 @@ var GoogleBatchLanguageModel = class _GoogleBatchLanguageModel extends GoogleLan
3407
3424
  const promptFeedback = (_a = preview.value.promptFeedback) != null ? _a : void 0;
3408
3425
  const blockReason = (_b = promptFeedback == null ? void 0 : promptFeedback.blockReason) != null ? _b : void 0;
3409
3426
  yield {
3427
+ type: "text",
3410
3428
  id: line.key,
3411
3429
  status: "failed",
3412
3430
  error: {
@@ -3432,6 +3450,7 @@ var GoogleBatchLanguageModel = class _GoogleBatchLanguageModel extends GoogleLan
3432
3450
  });
3433
3451
  if (!response.success) {
3434
3452
  yield {
3453
+ type: "text",
3435
3454
  id: line.key,
3436
3455
  status: "failed",
3437
3456
  error: {
@@ -3441,7 +3460,8 @@ var GoogleBatchLanguageModel = class _GoogleBatchLanguageModel extends GoogleLan
3441
3460
  };
3442
3461
  continue;
3443
3462
  }
3444
- const result = this.convertGenerateContentResponse({
3463
+ const result = GoogleLanguageModel.convertGenerateContentResponse({
3464
+ config: this.batchConfig,
3445
3465
  response: response.value,
3446
3466
  warnings: [],
3447
3467
  providerOptionsNames: ["google"]
@@ -3451,6 +3471,7 @@ var GoogleBatchLanguageModel = class _GoogleBatchLanguageModel extends GoogleLan
3451
3471
  );
3452
3472
  if (unsupportedPart != null) {
3453
3473
  yield {
3474
+ type: "text",
3454
3475
  id: line.key,
3455
3476
  status: "failed",
3456
3477
  error: {
@@ -3460,7 +3481,7 @@ var GoogleBatchLanguageModel = class _GoogleBatchLanguageModel extends GoogleLan
3460
3481
  };
3461
3482
  continue;
3462
3483
  }
3463
- yield { id: line.key, status: "succeeded", result };
3484
+ yield { type: "text", id: line.key, status: "succeeded", result };
3464
3485
  }
3465
3486
  }
3466
3487
  async getHeaders(headers) {
@@ -3556,6 +3577,25 @@ var googleUploadUrlResponseHandler = async ({
3556
3577
  }
3557
3578
  return { value: uploadUrl };
3558
3579
  };
3580
+ function getGoogleBatchModelId(requests) {
3581
+ var _a;
3582
+ const modelId = (_a = requests[0]) == null ? void 0 : _a.modelId;
3583
+ if (modelId == null) {
3584
+ throw new InvalidArgumentError({
3585
+ argument: "requests",
3586
+ message: "Google batches require at least one request."
3587
+ });
3588
+ }
3589
+ for (const request of requests) {
3590
+ if (request.modelId !== modelId) {
3591
+ throw new InvalidArgumentError({
3592
+ argument: "requests",
3593
+ message: "Google batches require every request to use the same model because the model is part of the batch endpoint."
3594
+ });
3595
+ }
3596
+ }
3597
+ return modelId;
3598
+ }
3559
3599
 
3560
3600
  // src/tool/code-execution.ts
3561
3601
  import { createProviderExecutedToolFactory } from "@ai-sdk/provider-utils";
@@ -3742,8 +3782,8 @@ import {
3742
3782
  generateId as defaultGenerateId,
3743
3783
  parseProviderOptions as parseProviderOptions3,
3744
3784
  serializeModelOptions as serializeModelOptions3,
3745
- WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE4,
3746
- WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE4
3785
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE3,
3786
+ WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE3
3747
3787
  } from "@ai-sdk/provider-utils";
3748
3788
 
3749
3789
  // src/google-image-model-options.ts
@@ -3774,13 +3814,13 @@ var GoogleImageModel = class _GoogleImageModel {
3774
3814
  this.config = config;
3775
3815
  this.specificationVersion = "v4";
3776
3816
  }
3777
- static [WORKFLOW_SERIALIZE4](model) {
3817
+ static [WORKFLOW_SERIALIZE3](model) {
3778
3818
  return serializeModelOptions3({
3779
3819
  modelId: model.modelId,
3780
3820
  config: model.config
3781
3821
  });
3782
3822
  }
3783
- static [WORKFLOW_DESERIALIZE4](options) {
3823
+ static [WORKFLOW_DESERIALIZE3](options) {
3784
3824
  return new _GoogleImageModel(options.modelId, {}, options.config);
3785
3825
  }
3786
3826
  get maxImagesPerCall() {
@@ -3910,6 +3950,7 @@ var GoogleImageModel = class _GoogleImageModel {
3910
3950
  const languageModelGoogleMetadata = (_h = (_g = result.providerMetadata) == null ? void 0 : _g.google) != null ? _h : {};
3911
3951
  return {
3912
3952
  images,
3953
+ ...result.finishReason.unified === "content-filter" ? { isRetryable: false } : {},
3913
3954
  warnings,
3914
3955
  providerMetadata: {
3915
3956
  google: {
@@ -4467,8 +4508,8 @@ import {
4467
4508
  postJsonToApi as postJsonToApi5,
4468
4509
  resolve as resolve5,
4469
4510
  serializeModelOptions as serializeModelOptions4,
4470
- WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE5,
4471
- WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE5
4511
+ WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE4,
4512
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE4
4472
4513
  } from "@ai-sdk/provider-utils";
4473
4514
 
4474
4515
  // src/google-speech-api.ts
@@ -4538,13 +4579,13 @@ var GoogleSpeechModel = class _GoogleSpeechModel {
4538
4579
  this.config = config;
4539
4580
  this.specificationVersion = "v4";
4540
4581
  }
4541
- static [WORKFLOW_SERIALIZE5](model) {
4582
+ static [WORKFLOW_SERIALIZE4](model) {
4542
4583
  return serializeModelOptions4({
4543
4584
  modelId: model.modelId,
4544
4585
  config: model.config
4545
4586
  });
4546
4587
  }
4547
- static [WORKFLOW_DESERIALIZE5](options) {
4588
+ static [WORKFLOW_DESERIALIZE4](options) {
4548
4589
  return new _GoogleSpeechModel(options.modelId, options.config);
4549
4590
  }
4550
4591
  get provider() {
@@ -4741,8 +4782,8 @@ import {
4741
4782
  postJsonToApi as postJsonToApi6,
4742
4783
  resolve as resolve6,
4743
4784
  serializeModelOptions as serializeModelOptions5,
4744
- WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE6,
4745
- WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE6
4785
+ WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE5,
4786
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE5
4746
4787
  } from "@ai-sdk/provider-utils";
4747
4788
 
4748
4789
  // src/interactions/build-google-interactions-stream-transform.ts
@@ -7308,7 +7349,7 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
7308
7349
  }
7309
7350
  this.config = config;
7310
7351
  }
7311
- static [WORKFLOW_SERIALIZE6](model) {
7352
+ static [WORKFLOW_SERIALIZE5](model) {
7312
7353
  return {
7313
7354
  ...serializeModelOptions5({
7314
7355
  modelId: model.modelId,
@@ -7317,7 +7358,7 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
7317
7358
  agent: model.agent
7318
7359
  };
7319
7360
  }
7320
- static [WORKFLOW_DESERIALIZE6](options) {
7361
+ static [WORKFLOW_DESERIALIZE5](options) {
7321
7362
  return new _GoogleInteractionsLanguageModel(
7322
7363
  options.agent != null ? { agent: options.agent } : options.modelId,
7323
7364
  options.config
@@ -8253,8 +8294,8 @@ import {
8253
8294
  safeParseJSON as safeParseJSON2,
8254
8295
  serializeModelOptions as serializeModelOptions6,
8255
8296
  waitForWebSocketBufferDrain,
8256
- WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE7,
8257
- WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE7
8297
+ WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE6,
8298
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE6
8258
8299
  } from "@ai-sdk/provider-utils";
8259
8300
  import { z as z23 } from "zod/v4";
8260
8301
 
@@ -8308,13 +8349,13 @@ var GoogleTranscriptionModel = class _GoogleTranscriptionModel {
8308
8349
  this.config = config;
8309
8350
  this.specificationVersion = "v4";
8310
8351
  }
8311
- static [WORKFLOW_SERIALIZE7](model) {
8352
+ static [WORKFLOW_SERIALIZE6](model) {
8312
8353
  return serializeModelOptions6({
8313
8354
  modelId: model.modelId,
8314
8355
  config: model.config
8315
8356
  });
8316
8357
  }
8317
- static [WORKFLOW_DESERIALIZE7](options) {
8358
+ static [WORKFLOW_DESERIALIZE6](options) {
8318
8359
  return new _GoogleTranscriptionModel(options.modelId, options.config);
8319
8360
  }
8320
8361
  get provider() {
@@ -8767,8 +8808,8 @@ import {
8767
8808
  parseProviderOptions as parseProviderOptions9,
8768
8809
  safeParseJSON as safeParseJSON3,
8769
8810
  serializeModelOptions as serializeModelOptions7,
8770
- WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE8,
8771
- WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE8,
8811
+ WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE7,
8812
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE7,
8772
8813
  waitForWebSocketBufferDrain as waitForWebSocketBufferDrain2
8773
8814
  } from "@ai-sdk/provider-utils";
8774
8815
 
@@ -8806,13 +8847,13 @@ var GoogleSpeechTranslationModel = class _GoogleSpeechTranslationModel {
8806
8847
  this.modelId = modelId;
8807
8848
  this.config = config;
8808
8849
  }
8809
- static [WORKFLOW_SERIALIZE8](model) {
8850
+ static [WORKFLOW_SERIALIZE7](model) {
8810
8851
  return serializeModelOptions7({
8811
8852
  modelId: model.modelId,
8812
8853
  config: model.config
8813
8854
  });
8814
8855
  }
8815
- static [WORKFLOW_DESERIALIZE8](options) {
8856
+ static [WORKFLOW_DESERIALIZE7](options) {
8816
8857
  return new _GoogleSpeechTranslationModel(options.modelId, options.config);
8817
8858
  }
8818
8859
  get provider() {
@@ -9240,7 +9281,7 @@ function supportsExternalFileUrls(modelId) {
9240
9281
  return /(^|\/)gemini-/.test(modelId) && !/(^|\/)gemini-2\.0/.test(modelId);
9241
9282
  }
9242
9283
  function createGoogle(options = {}) {
9243
- var _a, _b;
9284
+ var _a, _b, _c;
9244
9285
  const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : DEFAULT_BASE_URL;
9245
9286
  const providerName = (_b = options.name) != null ? _b : "google.generative-ai";
9246
9287
  const getHeaders = () => withUserAgentSuffix2(
@@ -9254,36 +9295,40 @@ function createGoogle(options = {}) {
9254
9295
  },
9255
9296
  `ai-sdk/google/${VERSION}`
9256
9297
  );
9257
- const createChatModel = (modelId) => {
9258
- var _a2;
9259
- return new GoogleBatchLanguageModel(modelId, {
9260
- provider: providerName,
9261
- baseURL,
9262
- headers: getHeaders,
9263
- generateId: (_a2 = options.generateId) != null ? _a2 : generateId3,
9264
- supportedUrls: () => ({
9265
- "*": [
9266
- // Default Google Generative Language "files" endpoint
9267
- // e.g. https://generativelanguage.googleapis.com/v1beta/files/...
9268
- googleFilesUrlPattern,
9269
- // Configured Google Generative Language "files" endpoint
9270
- new RegExp(`^${baseURL}/files/.*$`),
9271
- // YouTube URLs (public or unlisted videos)
9272
- new RegExp(
9273
- `^https://(?:www\\.)?youtube\\.com/watch\\?v=[\\w-]+(?:&[\\w=&.-]*)?$`
9274
- ),
9275
- new RegExp(`^https://youtu\\.be/[\\w-]+(?:\\?[\\w=&.-]*)?$`)
9276
- ],
9277
- ...supportsExternalFileUrls(modelId) ? Object.fromEntries(
9278
- supportedExternalUrlMediaTypes.map((mediaType) => [
9279
- mediaType,
9280
- [externalHttpsUrlPattern]
9281
- ])
9282
- ) : {}
9283
- }),
9284
- fetch: options.fetch
9285
- });
9298
+ const getSupportedUrls = (modelId, includeExternalUrls = modelId == null || supportsExternalFileUrls(modelId)) => ({
9299
+ "*": [
9300
+ googleFilesUrlPattern,
9301
+ new RegExp(`^${baseURL}/files/.*$`),
9302
+ new RegExp(
9303
+ `^https://(?:www\\.)?youtube\\.com/watch\\?v=[\\w-]+(?:&[\\w=&.-]*)?$`
9304
+ ),
9305
+ new RegExp(`^https://youtu\\.be/[\\w-]+(?:\\?[\\w=&.-]*)?$`)
9306
+ ],
9307
+ ...includeExternalUrls ? Object.fromEntries(
9308
+ supportedExternalUrlMediaTypes.map((mediaType) => [
9309
+ mediaType,
9310
+ [externalHttpsUrlPattern]
9311
+ ])
9312
+ ) : {}
9313
+ });
9314
+ const languageModelConfig = {
9315
+ provider: providerName,
9316
+ baseURL,
9317
+ headers: getHeaders,
9318
+ generateId: (_c = options.generateId) != null ? _c : generateId3,
9319
+ fetch: options.fetch
9286
9320
  };
9321
+ const createChatModel = (modelId) => new GoogleLanguageModel(modelId, {
9322
+ ...languageModelConfig,
9323
+ supportedUrls: () => getSupportedUrls(modelId)
9324
+ });
9325
+ const createBatch = () => new GoogleBatch({
9326
+ provider: `${providerName.replace(/\.generative-ai$/, "")}.batch`,
9327
+ config: languageModelConfig,
9328
+ // Batch prompt conversion happens before the model is available to the
9329
+ // provider. Only advertise URL support shared by every batch model.
9330
+ supportedUrls: getSupportedUrls(void 0, false)
9331
+ });
9287
9332
  const createEmbeddingModel = (modelId) => new GoogleEmbeddingModel(modelId, {
9288
9333
  provider: providerName,
9289
9334
  baseURL,
@@ -9379,6 +9424,7 @@ function createGoogle(options = {}) {
9379
9424
  provider.languageModel = createChatModel;
9380
9425
  provider.chat = createChatModel;
9381
9426
  provider.generativeAI = createChatModel;
9427
+ provider.experimental_batch = createBatch;
9382
9428
  provider.embedding = createEmbeddingModel;
9383
9429
  provider.embeddingModel = createEmbeddingModel;
9384
9430
  provider.textEmbedding = createEmbeddingModel;