@ai-sdk/google 4.0.74 → 4.0.75

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.
@@ -2352,6 +2352,6 @@ in application code, for example `answers.requestsRefund.probability >= 0.5`. Se
2352
2352
 
2353
2353
  Evaluation models can also be accessed through `customProvider` aliases or
2354
2354
  `createProviderRegistry().evaluationModel('provider:model')`. Direct string IDs
2355
- require an explicitly configured default provider with an `evaluationModel`
2356
- method; they do not automatically use Gateway. See
2355
+ use Gateway by default, or an explicitly configured default provider with an
2356
+ `evaluationModel` method. See
2357
2357
  [model aliases and registries](/docs/ai-sdk-core/evaluation#model-aliases-and-registries).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/google",
3
- "version": "4.0.74",
3
+ "version": "4.0.75",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@ai-sdk/provider": "4.0.17",
39
- "@ai-sdk/provider-utils": "5.0.43"
39
+ "@ai-sdk/provider-utils": "5.0.44"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@ai-sdk/test-server": "2.0.1",
@@ -30,13 +30,15 @@ export function convertGoogleUsage(
30
30
 
31
31
  const promptTokens = usage.promptTokenCount ?? 0;
32
32
  const candidatesTokens = usage.candidatesTokenCount ?? 0;
33
+ const toolUsePromptTokens = usage.toolUsePromptTokenCount ?? 0;
33
34
  const cachedContentTokens = usage.cachedContentTokenCount ?? 0;
34
35
  const thoughtsTokens = usage.thoughtsTokenCount ?? 0;
36
+ const inputTokens = promptTokens + toolUsePromptTokens;
35
37
 
36
38
  return {
37
39
  inputTokens: {
38
- total: promptTokens,
39
- noCache: promptTokens - cachedContentTokens,
40
+ total: inputTokens,
41
+ noCache: inputTokens - cachedContentTokens,
40
42
  cacheRead: cachedContentTokens,
41
43
  cacheWrite: undefined,
42
44
  },
@@ -53,7 +53,7 @@ export class GoogleImageModel implements ImageModelV4 {
53
53
  if (this.settings.maxImagesPerCall != null) {
54
54
  return this.settings.maxImagesPerCall;
55
55
  }
56
- return 10;
56
+ return 1;
57
57
  }
58
58
 
59
59
  get provider(): string {
@@ -77,7 +77,6 @@ export class GoogleImageModel implements ImageModelV4 {
77
77
 
78
78
  const {
79
79
  prompt,
80
- n,
81
80
  size,
82
81
  aspectRatio,
83
82
  seed,
@@ -96,13 +95,6 @@ export class GoogleImageModel implements ImageModelV4 {
96
95
  );
97
96
  }
98
97
 
99
- // Gemini does not support generating multiple images per call via n parameter
100
- if (n != null && n > 1) {
101
- throw new Error(
102
- 'Gemini image models do not support generating a set number of images per call. Use n=1 or omit the n parameter.',
103
- );
104
- }
105
-
106
98
  if (size != null) {
107
99
  warnings.push({
108
100
  type: 'unsupported',
@@ -7,7 +7,7 @@ export type GoogleImageModelId =
7
7
 
8
8
  export interface GoogleImageSettings {
9
9
  /**
10
- * Override the maximum number of images per call (default 10)
10
+ * Override the maximum number of images per call (default 1)
11
11
  */
12
12
  maxImagesPerCall?: number;
13
13
  }
@@ -463,10 +463,15 @@ export class GoogleLanguageModel implements LanguageModelV4 {
463
463
  ) as SharedV4ProviderMetadata;
464
464
  const candidate = response.candidates?.[0];
465
465
  const promptBlockReason = response.promptFeedback?.blockReason;
466
+ const confirmedPromptBlockReason = isConfirmedPromptBlockReason(
467
+ promptBlockReason,
468
+ )
469
+ ? promptBlockReason
470
+ : undefined;
466
471
  const isPromptBlocked =
467
- candidate?.finishReason == null && promptBlockReason != null;
472
+ candidate?.finishReason == null && confirmedPromptBlockReason != null;
468
473
  const rawFinishReason =
469
- candidate?.finishReason ?? promptBlockReason ?? undefined;
474
+ candidate?.finishReason ?? confirmedPromptBlockReason;
470
475
  const content: Array<LanguageModelV4Content> = [];
471
476
 
472
477
  // map ordered parts to content: